Expression syntax for getEObject method [message #632756] |
Thu, 14 October 2010 03:43  |
Eclipse User |
|
|
|
Originally posted by: templth.yahoo.fr
Hello,
I wonder which syntax can be used within the parameter of the getEObject
method for the EMF Resource class. Is there a documentation somewhere
describing it?
Thanks very much for your answer!
Thierry
|
|
|
|
|
Re: Expression syntax for getEObject method [message #634679 is a reply to message #634611] |
Fri, 22 October 2010 13:35   |
Eclipse User |
|
|
|
Thierry,
Comments below.
Thierry Templier wrote:
> Hello Ed,
>
> I looked at documentations you gave me and here are what I understood...
>
> The first level needs to be necessary empty since it corresponds to
> the root node of the model.
By default it's the index of the root object in Resource.getContents(),
e.g., /0, /1/, /2, but a resource can specialize this to be whatever it
decides is a good thing. It should always accept index-based reference
though. Also, an empty segment implies 0, which is why you see // so
often in full paths.
> Then you need to explicitly specify complete path within the model
> from the top to target node using feature name with eventually
> conditions and index.
>
> I use the following model for my sample expressions:
>
> <uml:Model name="TestModel">
> <packagedElement xmi:type="uml:Package" name="TestPackage">
> <packagedElement xmi:type="uml:Class" name="TestClass"/>
> </packagedElement>
> </uml:Model>
>
> For example to access the Class with name TestClass, I can use both
> syntax:
>
> //@packagedElement.0/packagedElement.0
> //@packageElement.0/packagedElement[name='TestClass']
> //@packageElement[name='TestPackage]/packagedElement[name='T estClass']
>
> Am I right?
Yes, it's generally @<feature-name>[.<index-in-feature>]. If the
referenced object has a key, then a key test replaces the index. It
could be a multi-feature key. It's also possible to specialize this
syntax in the model, the way EModelElementImpl does.
> Is there other features regarding conditions in such expressions
> (within [])?
It should be of the form <attributeName>='<string-value>'.
> Moreover is it possible to specify an expression to look for an
> element in the complete model without having specified its complete path?
Yes, ResourceImpl.getEObject can do arbitrary things you implement by
hand, but should always support the default syntax.
>
> Thanks very much!
> Thierry
>
>> Thierry,
>>
>> I think if you followed the Javadoc links to methods you'd learn the
>> syntax for the segments. Looking at ResourceImpl.getURIFragment
>> illustrates how a fragment path is constructed and
>> ResourceImpl.getEObject illustrates how it's interpreted.
>>
>>
>> Thierry Templier wrote:
>>> Hello,
>>>
>>> I wonder which syntax can be used within the parameter of the
>>> getEObject method for the EMF Resource class. Is there a
>>> documentation somewhere describing it?
>>>
>>> Thanks very much for your answer!
>>> Thierry
|
|
|
Re: Expression syntax for getEObject method [message #635231 is a reply to message #634679] |
Tue, 26 October 2010 02:19  |
Eclipse User |
|
|
|
Originally posted by: templth.yahoo.fr
Thanks very much, Ed, for these explanations!
Thierry
> Thierry,
>
> Comments below.
>
> Thierry Templier wrote:
>> Hello Ed,
>>
>> I looked at documentations you gave me and here are what I understood...
>>
>> The first level needs to be necessary empty since it corresponds to
>> the root node of the model.
> By default it's the index of the root object in Resource.getContents(),
> e.g., /0, /1/, /2, but a resource can specialize this to be whatever it
> decides is a good thing. It should always accept index-based reference
> though. Also, an empty segment implies 0, which is why you see // so
> often in full paths.
>> Then you need to explicitly specify complete path within the model
>> from the top to target node using feature name with eventually
>> conditions and index.
>>
>> I use the following model for my sample expressions:
>>
>> <uml:Model name="TestModel">
>> <packagedElement xmi:type="uml:Package" name="TestPackage">
>> <packagedElement xmi:type="uml:Class" name="TestClass"/>
>> </packagedElement>
>> </uml:Model>
>>
>> For example to access the Class with name TestClass, I can use both
>> syntax:
>>
>> //@packagedElement.0/packagedElement.0
>> //@packageElement.0/packagedElement[name='TestClass']
>> //@packageElement[name='TestPackage]/packagedElement[name='T estClass']
>>
>> Am I right?
> Yes, it's generally @<feature-name>[.<index-in-feature>]. If the
> referenced object has a key, then a key test replaces the index. It
> could be a multi-feature key. It's also possible to specialize this
> syntax in the model, the way EModelElementImpl does.
>> Is there other features regarding conditions in such expressions
>> (within [])?
> It should be of the form <attributeName>='<string-value>'.
>> Moreover is it possible to specify an expression to look for an
>> element in the complete model without having specified its complete path?
> Yes, ResourceImpl.getEObject can do arbitrary things you implement by
> hand, but should always support the default syntax.
>>
>> Thanks very much!
>> Thierry
>>
>>> Thierry,
>>>
>>> I think if you followed the Javadoc links to methods you'd learn the
>>> syntax for the segments. Looking at ResourceImpl.getURIFragment
>>> illustrates how a fragment path is constructed and
>>> ResourceImpl.getEObject illustrates how it's interpreted.
>>>
>>>
>>> Thierry Templier wrote:
>>>> Hello,
>>>>
>>>> I wonder which syntax can be used within the parameter of the
>>>> getEObject method for the EMF Resource class. Is there a
>>>> documentation somewhere describing it?
>>>>
>>>> Thanks very much for your answer!
>>>> Thierry
|
|
|
Powered by
FUDForum. Page generated in 0.05426 seconds