The query framework defined in the org.eclipse.emf.query
plug-in provides an 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 defines the search scope of
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 an
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
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 query result object and returns it to the caller.
IQueryResult interface provides the set of elements
retrieved by a 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 multi-valued structural features of
model elements. It supports both the: exists (ANY) and for-all (ALL)
EObjectStructuralFeatureValueCondition class is the parent
class for conditions that are check the values stored in model elements'
features. It uses the help of two other condition objects. The first is an
EObjectCondition that is used to decide on the validity of the 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 feature and whether or not it matches
what the user is looking for.
The org.eclipse.emf.query.ocl plug-in provides OCL
extensions to the EMF Model Query framework. It defines the
BooleanOCLCondition class for specifying query conditions using
Using the above classes follow the steps outlined below to create and execute
Create an implementation of the
EObjectCondition class to define custom conditions
or use one of the pre-defined conditions available as in the query framework.
Create a statement using the
Execute the statement to produce the results.
Check to ensure that the query did not generate any exceptions during its
Please refer to the tutorial
Query Framework Tutorial
OCL Query Tutorial for reviewing some code samples.
Copyright (c) 2000, 2007 IBM Corporation and others. All Rights Reserved.