views:

59

answers:

2

How do I navigate, programmatically in java, an Ecore model to extract the elements information?

A: 

You can use EObject's api like eContents(), eSet(), eGet() etc..or you can use oAW's xText.

EObject API: http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.emf.doc/references/javadoc/org/eclipse/emf/ecore/EObject.html

http://www.eclipse.org/Xtext/

Pangea
+1  A: 

The best single resource on EMF is the "Eclipse Modeling Framework" book (2nd edition).

@Pangea's answer links to the EObject interfaces. But a better way to use a model instance is to use the generated interfaces. If you read the "A Tour of the Eclipse Modeling Framework" article by Lars Vogel, it includes a simple example of accessing a model using the generated APIs. And "the book" has a lot more on this subject.

Stephen C
I did not suggest the generated code because I believe it is a maintenance issue if the model keeps changing. The EObject API provides a generic interface much like Reflection API
Pangea
@Pangea - you have the same problem using EObject, except that you get runtime exceptions instead of compilation errors.
Stephen C