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.
Pangea
2010-07-18 23:32:28
+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
2010-07-19 02:32:07
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
2010-07-19 02:55:41
@Pangea - you have the same problem using EObject, except that you get runtime exceptions instead of compilation errors.
Stephen C
2010-07-19 02:57:44