Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Playing with setContext
Playing with setContext [message #17057] Thu, 12 April 2007 10:32 Go to next message
Youmm P. is currently offline Youmm P.Friend
Messages: 140
Registered: July 2009
Senior Member
Hello,

Is it possible to play with setContext / setOperationContext with OCL /
OCLHelper to parse a string like this

"context myMethod(i : MyObject) : MyObject
pre
cond1: true = true
"

or like this

"context myMethod(i : MyObject) : MyObject
pre
true = true
"
and setting the good EPackage / EClass for the method ?

It's the same question as yesterday but I don't need the class name in
the condition (I can infer it with the model).
Re: Playing with setContext [message #17119 is a reply to message #17057] Thu, 12 April 2007 16:20 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Youmm,

Using the OCLHelper.setOperationContext(...) method, you specify both the
classifier and operation context of the constraint (note that the
classifier could be one that inherits but does not define the operation).

With the helper, you provide only the constraint expression to the
createPrecondition() method, e.g.:

EClass myEClass;
EOperation myEOperation;

helper.setOperationContext(myEClass, myEOperation);
Constraint ct = helper.createPrecondition("true = true");

ct.setName("cond1");

The OCLHelper is intended primarily for parsing constraints embedded in
models, where normally the constraint text consists of the expression only
(the constraint name and context being provided via separate attributes of
the constraint element).

HTH,

Christian


Youmm P. wrote:

> Hello,
>
> Is it possible to play with setContext / setOperationContext with OCL /
> OCLHelper to parse a string like this
>
> "context myMethod(i : MyObject) : MyObject
> pre
> cond1: true = true
> "
>
> or like this
>
> "context myMethod(i : MyObject) : MyObject
> pre
> true = true
> "
> and setting the good EPackage / EClass for the method ?
>
> It's the same question as yesterday but I don't need the class name in
> the condition (I can infer it with the model).
Previous Topic:OCL to Java
Next Topic:OCL pre conditions and specific parsing
Goto Forum:
  


Current Time: Sat Apr 27 05:22:00 GMT 2024

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

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

Back to the top