Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

EMF Model Query Developer Guide
Previous Page Home Next Page

EMF Model Query Overview

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:

  1. The IEObjectSource interface defines the search scope of elements to be used in a query.
  2. The 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 IQueryResult object and returns it to the caller.
  3. The FROM class represents the elements to search. It is responsible of providing an appropriate iterator for the elements in the search space.
  4. The WHERE class applies the search conditions over the elements in the search set.
  5. The 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.
  6. The IQueryResult interface provides the set of elements retrieved by a query.
  7. The 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.
  8. The 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) quantifier semantics.
  9. The 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.
  10. 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 OCL constraints.

Using the above classes follow the steps outlined below to create and execute queries.

  1. Create an implementation of the IEObjectSource interface.
  2. Extend the EObjectCondition class to define custom conditions or use one of the pre-defined conditions available as in the query framework.
  3. Create a statement using the SELECT or UPDATE clause.
  4. Execute the statement to produce the results.
  5. Check to ensure that the query did not generate any exceptions during its execution.

Please refer to the tutorial Query Framework Tutorial and OCL Query Tutorial for reviewing some code samples.


Copyright (c) 2000, 2007 IBM Corporation and others. All Rights Reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire