Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Printing EMF EObject properties
Printing EMF EObject properties [message #755979] Thu, 10 November 2011 11:33 Go to next message
Darie Moldovan is currently offline Darie MoldovanFriend
Messages: 67
Registered: November 2010
Location: Darmstadt, Germany
Member
Hi @ all,

I'm trying to print the properties/attributes of an EMF EObject separately, so that I can for example use the values of the properties of the EObject.

The following code

for(EObject myObject : list)
{
    System.out.println(myObject);
}


would print something like

org.eclipse.blabla.ObjectImpl (id: _m2ldKfDYEd-OE8QHx93Sow) (name: SomeName)


Okay, I want to save the two attributes locally (id and name), but I don't know how to access them. Any ideas?

Thanks in advance.
Re: Printing EMF EObject properties [message #756008 is a reply to message #755979] Thu, 10 November 2011 13:08 Go to previous message
Darie Moldovan is currently offline Darie MoldovanFriend
Messages: 67
Registered: November 2010
Location: Darmstadt, Germany
Member
Okay, solved it myself. Here's the solution for all of you who want to do the same:

EList<EAttribute> attrs = myEObject.eClass().getEAllAttributes();
for(EAttribute a : attrs) {
    System.out.println(a.getName() + " = " + myObject.eGet(a));
}


prints the name of the current attribute and it's actual value. myEObject is an instance of org.eclipse.emf.ecore.EObject.

Hope this helps.
Previous Topic:Creating plugin operating on UML metamodel
Next Topic:Using fully qualified Ids for non containment cross-documents references
Goto Forum:
  


Current Time: Fri Apr 19 22:22:29 GMT 2024

Powered by FUDForum. Page generated in 0.02503 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top