|
Re: how can i access/get into my ###Imp Objects [message #499856 is a reply to message #499851] |
Tue, 24 November 2009 11:56 |
Ed Merks Messages: 33113 Registered: July 2009 |
Senior Member |
|
|
Burkut,
Comments below.
burkut wrote:
> hallo,
>
> i am a newbie in EMF. i want some help from you.
>
> i have defined an ecore model and created model code over generator
> model. then i have made a plugin of this model and created an EMF
> example model of my Model. After that i saved my Example Model and
> tried to load it (as XMI Resource) anywhere else in my another Java
> Application. All of these Steps are ok. I have no problem.
>
> the Problem is now:
> if i load my Resource in XMI, then i am getting the contents with
> resource.getContents(0); then i will get an EObject. What i want to
> get, is that, the really Data, that i have filled in my Examples out
> or its Objects in order to i can access in to my Data at any time.
>
> how can i get that?
It's possible that the root EObject of a resource could be of any type,
but if you expect it to be an instance of some class in your model, you
could test for that with instanceof or just assume and cast directly to
your type, e.g., (Data)resource.getContents(0).
>
> thank you
>
> Burkut
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
|
|
|
Re: how can i access/get into my ###Imp Objects [message #499968 is a reply to message #499936] |
Tue, 24 November 2009 15:37 |
Ed Merks Messages: 33113 Registered: July 2009 |
Senior Member |
|
|
Burkut,
The implementation classes are intended to be hidden behind the
interface. One thing many folks overlook is the fact that the generated
Abc interface might not eve be implemented by AbcImpl. With multiple
inheritance, you might have C which inherits from A and B, so there's a
CImpl, AImpl, and BImpl. But CImpl doesn't extend BImpl but rather
AImpl, so the B interface would be directly implemented by CImpl without
extending BImpl. Therefore, code that casts to Impl classes is
generally making a bad assumption about the implementation details. Yet
I seem folks doing this constantly (casting to Impl classes) but no one
has ever answered the question, what compelled you to do this?
burkut wrote:
> i see, what do you mean and thank you very much. that helps me a
> little bit. let me try to solve my problem.
> but i can get the Graph_Children by both of the way, by casting to
> NodeInterface and NodeImpl. what ist difference?
>
>
> Thank you
>
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
|
Powered by
FUDForum. Page generated in 0.03891 seconds