Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Expression syntax for getEObject method
Expression syntax for getEObject method [message #632756] Thu, 14 October 2010 07:43 Go to next message
Eclipse UserFriend
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 #632932 is a reply to message #632756] Thu, 14 October 2010 17:22 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Expression syntax for getEObject method [message #634611 is a reply to message #632932] Fri, 22 October 2010 12:39 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: templth.yahoo.fr

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. 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? Is there other features regarding conditions in such
expressions (within [])? Moreover is it possible to specify an
expression to look for an element in the complete model without having
specified its complete path?

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 #634679 is a reply to message #634611] Fri, 22 October 2010 17:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
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


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Expression syntax for getEObject method [message #635231 is a reply to message #634679] Tue, 26 October 2010 06:19 Go to previous message
Eclipse UserFriend
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
Previous Topic:Update site for your EMF 2.7 milestone builds?
Next Topic:EMFCompare and compare with Repository
Goto Forum:
  


Current Time: Thu Mar 28 16:55:59 GMT 2024

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

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

Back to the top