Home » Modeling » OCL » Creating context-free queries
|
Re: Creating context-free queries [message #52055 is a reply to message #52029] |
Mon, 03 March 2008 23:23 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Stefan,
OCL doesn't have a concept of context-free queries. All OCL expressions
have a context classifier.
The stack-overflow on an untyped variable looks like a bug.
HTH,
Christian
Stefan Schulze wrote:
> Hi...
>
> I'm trying to create a simple context-free query
> ("SomeClass.allInstances()") with OCLHelper#createQuery(String), but I
> always get an Exception because I never set the context-classifier with
> Environment#setSelfVariable(Variable).
> If I set the self-variable to any valid classifier, everything works fine.
> If I set it to an empty variable (no setType(EClassifier)), I run into a
> StackOverflow.
>
> So what is the right way to create a context-free query?
>
> Stefan
|
|
| |
Re: Creating context-free queries [message #52132 is a reply to message #52081] |
Tue, 04 March 2008 13:58 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Stefan,
I see, now. That API is a bit of an anachronism. I suppose that any
EClassifier will do. You might just grab EcorePackage.Literals.ESTRING.
I suppose it depends on what your application is doing, but often it isn't
practical for an application to know a priori whether an expression will
reference 'self.' Hence, my previous reply was more OCL-oriented than
API-oriented.
Cheers,
Christian
Stefan Schulze wrote:
> Hi Christian,
>
> the method Query#evaluate() seems to be designed for context-free usage.
> If I want to use that method, what should I set as self-variable? Is it
> correct to set it to a random EClass from my metamodel?
>
> Stefan
>
> "Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
> news:fqi1a4$6du$1@build.eclipse.org...
>> Hi, Stefan,
>>
>> OCL doesn't have a concept of context-free queries. All OCL expressions
>> have a context classifier.
>>
>> The stack-overflow on an untyped variable looks like a bug.
>>
>> HTH,
>>
>> Christian
>>
>>
>> Stefan Schulze wrote:
>>
>>> Hi...
>>>
>>> I'm trying to create a simple context-free query
>>> ("SomeClass.allInstances()") with OCLHelper#createQuery(String), but I
>>> always get an Exception because I never set the context-classifier with
>>> Environment#setSelfVariable(Variable).
>>> If I set the self-variable to any valid classifier, everything works
>>> fine.
>>> If I set it to an empty variable (no setType(EClassifier)), I run into a
>>> StackOverflow.
>>>
>>> So what is the right way to create a context-free query?
>>>
>>> Stefan
>>
|
|
|
Re: Creating context-free queries [message #52491 is a reply to message #52132] |
Sun, 09 March 2008 02:14 |
Stefan Schulze Messages: 70 Registered: July 2009 |
Member |
|
|
Hi Christian,
using EcorePackage.Literals.ESTRING works fine on one condition. If the
first self-variable I set to an Environment is an
EcorePackage.Literals.EString, the contextPackage of this Environment is set
to EcorePackage.eINSTANCE.
Because the contextPackage will never be updated, all subsequent evaluations
are failing.
It's not hard to work around this problem, but I thought it'd be good to
know for other people with the same problems. ;)
Bye,
Stefan
"Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
news:fqjki2$nqc$1@build.eclipse.org...
> Hi, Stefan,
>
> I see, now. That API is a bit of an anachronism. I suppose that any
> EClassifier will do. You might just grab EcorePackage.Literals.ESTRING.
>
> I suppose it depends on what your application is doing, but often it isn't
> practical for an application to know a priori whether an expression will
> reference 'self.' Hence, my previous reply was more OCL-oriented than
> API-oriented.
|
|
|
Re: Creating context-free queries [message #52545 is a reply to message #52491] |
Mon, 10 March 2008 13:32 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, stefan,
Right, that's a good point that I neglected to mention. The context
classifier also determines what is the default package for resolution of
unqualified classifier names.
You should be able to use the fully-qualified name to reference any type in
any package (so long as its name is unique, of course).
This sounds like a good FAQ item for the Wiki ...
Cheers,
Christian
Stefan Schulze wrote:
> Hi Christian,
>
> using EcorePackage.Literals.ESTRING works fine on one condition. If the
> first self-variable I set to an Environment is an
> EcorePackage.Literals.EString, the contextPackage of this Environment is
> set to EcorePackage.eINSTANCE.
> Because the contextPackage will never be updated, all subsequent
> evaluations are failing.
>
> It's not hard to work around this problem, but I thought it'd be good to
> know for other people with the same problems. ;)
>
> Bye,
> Stefan
>
> "Christian W. Damus" <cdamus@ca.ibm.com> schrieb im Newsbeitrag
> news:fqjki2$nqc$1@build.eclipse.org...
>> Hi, Stefan,
>>
>> I see, now. That API is a bit of an anachronism. I suppose that any
>> EClassifier will do. You might just grab EcorePackage.Literals.ESTRING.
>>
>> I suppose it depends on what your application is doing, but often it
>> isn't practical for an application to know a priori whether an expression
>> will
>> reference 'self.' Hence, my previous reply was more OCL-oriented than
>> API-oriented.
|
|
|
Goto Forum:
Current Time: Thu Dec 26 11:43:13 GMT 2024
Powered by FUDForum. Page generated in 0.03331 seconds
|