1

In my EObject I have the field eStorage, which contains data, I want to use.

Is there a possibility to read out the eStorage?

I tried the code below but it doesn't work:

doIt(EObject object) {
    object.getEStorage;
    // use the eStorage...
}
Jason Aller
  • 3,541
  • 28
  • 38
  • 38
John
  • 795
  • 3
  • 15
  • 38

1 Answers1

1

Chances are that eStorage is a private field.

So either,

  • Re-read the javadoc of the EObject interface and/or the javadoc of the particular implementation of EObject you're using. You may find a method offering the data you're looking for.
  • Access the private field via Reflection
try {
    Field f = object.getClass().getDeclaredField("eStorage"); 
    f.setAccessible(true);
    Object theDataYouWant = f.get(object);
} catch(Exception e) {
    // Handle exception here...
}

References: How do I read a private field in Java?

Community
  • 1
  • 1
Stephan
  • 41,764
  • 65
  • 238
  • 329