Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » how can i access/get into my ###Imp Objects
how can i access/get into my ###Imp Objects [message #499851] Tue, 24 November 2009 11:36 Go to next message
burkut  is currently offline burkut Friend
Messages: 13
Registered: November 2009
Junior Member
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?

thank you

Burkut
Re: how can i access/get into my ###Imp Objects [message #499856 is a reply to message #499851] Tue, 24 November 2009 11:56 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
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
Re: how can i access/get into my ###Imp Objects [message #499892 is a reply to message #499856] Tue, 24 November 2009 13:41 Go to previous messageGo to next message
burkut  is currently offline burkut Friend
Messages: 13
Registered: November 2009
Junior Member
yes, i did so. but. it is not a solution of my problem.
f.e. i have a Graphmodel, which includes many graphs.
so i get root EObject with resource.getContents(); that means all Graphs . so i want to get one of them per index thend cast it to GraphImpl. then go into the graph and try again same way to get one of the Nodes and do same way try to get one of the values of the Nodes......it is not prety good.

i want to get only Graph object and in this graph object i want to get every children with an access at any time;

Burkut
Re: how can i access/get into my ###Imp Objects [message #499917 is a reply to message #499892] Tue, 24 November 2009 14:12 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
Registered: July 2009
Senior Member
Burkut,

Comments below.

burkut wrote:
> yes, i did so. but. it is not a solution of my problem.
> f.e. i have a Graphmodel, which includes many graphs.
> so i get root EObject with resource.getContents(); that means all
> Graphs . so i want to get one of them per index thend cast it to
> GraphImpl.
You should never need to case to a generated Impl class.
> then go into the graph and try again same way to get one of the Nodes
> and do same way try to get one of the values of the Nodes......it is
> not prety good.
> i want to get only Graph object and in this graph object i want to get
> every children with an access at any time;
Are these questions about a specific model of yours? In the end, all
questions like this will be answered by determining what type of object
is in your resource, casting to the generate API (interface, not
implementation class), and then using that API to access the rest of the
data.
>
> Burkut
>
Re: how can i access/get into my ###Imp Objects [message #499936 is a reply to message #499917] Tue, 24 November 2009 14:54 Go to previous messageGo to next message
burkut  is currently offline burkut Friend
Messages: 13
Registered: November 2009
Junior Member
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

burkut

[Updated on: Tue, 24 November 2009 14:57]

Report message to a moderator

Re: how can i access/get into my ###Imp Objects [message #499939 is a reply to message #499851] Tue, 24 November 2009 14:57 Go to previous messageGo to next message
burkut  is currently offline burkut Friend
Messages: 13
Registered: November 2009
Junior Member
No Message Body
Re: how can i access/get into my ###Imp Objects [message #499968 is a reply to message #499936] Tue, 24 November 2009 15:37 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30653
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
>
>
Re: how can i access/get into my ###Imp Objects [message #499995 is a reply to message #499968] Tue, 24 November 2009 16:37 Go to previous message
burkut  is currently offline burkut Friend
Messages: 13
Registered: November 2009
Junior Member
thank you. it is clearly to me now. Then i prefer to use to cast to Interface.

Burkut.
Previous Topic:Problem performance getString of ItemProvider
Next Topic:[CDO] Is there a way to get the 'diff' of two CDO Audit views?
Goto Forum:
  


Current Time: Thu Nov 21 19:11:07 GMT 2019

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

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

Back to the top