How to get the parent of an EAttribute ?? [message #410299] |
Tue, 19 June 2007 11:07 |
|
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 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.02940 seconds