javaeclipse-emf

Use eStorage in EMF


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...
}

Solution

  • Chances are that eStorage is a private field.

    So either,

    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?