Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to get the parent of an EAttribute ??
How to get the parent of an EAttribute ?? [message #410299] Tue, 19 June 2007 11:07 Go to next message
Nicholas Loulloudes is currently offline Nicholas LoulloudesFriend
Messages: 54
Registered: July 2009
Location: Cyprus
Member

Hello,

I have the following model

<DocumentRoot>
<Ident>
<ID>123</ID>
<Anot>A1</Anot>
<Anot>A2</Anot>
<Anot>A3</Anot>
</Ident>
</DocumentRoot>


The IdentType has two attributes, ID and Anot. Anot returns an EList of strings.

Now if i do EObject eObject = this.identType; and then

System.out.println(eObject), i get the JobIdentImpl with all the content and values.

Now, in one of my methods, i iterate within the JobIdent and try to get the parent of Anot via:

EObject parent = eAttribute.eContainer();

and then try to print parent, i only get the following:

org.eclipse.emf.ecore.impl.EClassImpl@1c10834 (name: JobIdentificationType)....


This causes problem for me since i cannot get the values of Annot via:

Object value = parent.eGet(eAttribute);


any suggestions?

Thanks.
Re: How to get the parent of an EAttribute ?? [message #410301 is a reply to message #410299] Tue, 19 June 2007 11:13 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Nicholas,

Comments below.

Nicholas Loulloudes wrote:
> Hello,
>
> I have the following model
>
> <DocumentRoot>
> <Ident>
> <ID>123</ID>
> <Anot>A1</Anot>
> <Anot>A2</Anot>
> <Anot>A3</Anot>
> </Ident>
> </DocumentRoot>
>
>
> The IdentType has two attributes, ID and Anot. Anot returns an EList of strings.
>
> Now if i do EObject eObject = this.identType; and then
>
> System.out.println(eObject), i get the JobIdentImpl with all the content and values.
>
> Now, in one of my methods, i iterate within the JobIdent and try to get the parent of Anot via:
>
> EObject parent = eAttribute.eContainer();
>
This is asking the parent of the meta data object, which will be another
meta data object and will have nothing to do with your particular instance.
> and then try to print parent, i only get the following:
>
> org.eclipse.emf.ecore.impl.EClassImpl@1c10834 (name: JobIdentificationType)....
>
>
> This causes problem for me since i cannot get the values of Annot via:
>
> Object value = parent.eGet(eAttribute);
>
>
There is no EObject representing the Anot element (unless it was an
element that had a complex type with simple content rather than an
element with a simple type). So this is like wanting to know the parent
of a java.lang.String. A String don't know who is all referencing it,
and, in general, the value of an EAttribute will not know that it's
being referenced by one or more EObjects.
> any suggestions?
>
> Thanks.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:convert EMF URI to file URI
Next Topic:EReference.eKeys
Goto Forum:
  


Current Time: Thu Apr 25 23:06:12 GMT 2024

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

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

Back to the top