The query framework provides the basic infrastructure for specifying and executing queries against a set of EMF-Model elements and their contents. The following are the main classes to be used when formulating query statements:
IEObjectSource
interface provides the search scope elements to be used in a query.
SELECT
class implements a template-function that does the iteration over model
elements and applies the search condition on each; it collects the resulting elements
into a QueryResultSet
object and returns it to the caller.
FROM
class represents the elements to search. It is responsible of providing
an appropriate iterator for the elements in the search space.
WHERE
class applies the search conditions over the elements in the search set.
UPDATE
class passes the elements who satisfy the search condition to a caller-supplied
modification function. It collects the modified elements into a QueryResultSet object
and returns it to the caller.
QueryResultSet
class represents the set of elements returned by a given query.
EObjectCondition
class is the abstract parent of all conditions that deal with model-elements (i.e., EObjects).
It incorporates the services of a PruneHandler in order to answers whether or not to prune the element
tree at a specific element and thus ignore its children.
ConditionPolicy
class is used to allow the user to decide how to apply a given condition
on a collection of a model-element EAttributes
or EReferences
values. Supports both the: exists (ANY) and
for-all (ALL) semantics.
EObjectStructuralFeatureValueCondition
class is the parent class for conditions that are responsible
for checking the values held in model-elements' attributes or references. It uses the help of two other
condition objects. The first is an EObjectCondition that it used to decide on the validity of
context element (a context element is the model element whose attribute we are evaluating) and the other
condition is an evaluator Condition that it uses to evaluate the value held in the attribute or the reference
and whether or not it matches what the user is looking for.
IOclQueryHelper
for performing
OCL queries on EMF models. It supports Boolean-valued OCL expressions as query conditions that are used to formulate OCL
queries over EMF models. The class OclCondition
applies OCL expressions to EObjects
. Allows the
integration of OCL expressions with other EObjectConditions
.
Using the above classes follow the steps described below to create and execute queries.
IEObjectSource
interface.
EObjectCondition
class to define custom conditions or use one of the pre-defined conditions
available as part of the query framework.
SELECT
or UPDATE
clauses.
Please refer to the tutorial Query Framework Tutorial and OCL Query Tutorial for reviewing some code samples.
Copyright (c) 2000,2005 IBM Corporation and others. All Rights Reserved.