Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » using @pre. operator.(OCL Postconditions for a java method)
using @pre. operator. [message #655710] Tue, 22 February 2011 12:02 Go to next message
Hussam  is currently offline Hussam Friend
Messages: 19
Registered: January 2011
Junior Member
Hello every experts ,

I am writing a program in Java,using Eclipse for providing the user by the ability to apply some operators on a per developed UML Model of any software. one of this operators is to add a new Operation into an interface , so that all the related elements that interface has to be updated.

I need to use the @pre in the post conditions as you see in the following short code.:

String test="Dependency.allInstances()->select(getAppliedStereotypes().name- > includes('AddPhenomenon')).source.oclAsType(Interface).owned Member.oclAsType(Operation)- > forAll(op:Operation|Operation.allInstances()->select(name=op.name)- >size()=1)";

Constraint consTest=(Constraint)oclHelper.createInvariant(test); existsDepndency_AddPheno=ocl2.check(this.model, consTest);

if(existsDepndency_AddPheno)


The result is that : the @pre is to be used in the method post conditions, so how can I use it. where exactly I could embed the code of post conditions in the Java program?

Re: using @pre. operator. [message #655743 is a reply to message #655710] Tue, 22 February 2011 14:37 Go to previous messageGo to next message
Axel Uhl is currently offline Axel UhlFriend
Messages: 41
Registered: July 2009
Member
Hi Hussam,

you should be able to use @pre as a postfix to the property you're trying to access in a postcondition. The parser will then mark the expression correspondingly internally.

Evaluation time is a different question. I don't know how the values prior to a single change or a whole set of changes are preserved for OCL evaluation. The evaluator code doesn't make reference to isMarkedPre() on PropertyCallExp, so I would assume it doesn't have an impact on evaluation. Maybe Ed Willink is able to answer this. Ed?

As an additional hint, although I understand you're using the UML implementation of MDT/OCL and not the Ecore implementation, maybe have a look at PartialEvaluator and PartialEvaluatorFactory. For the Ecore flavor of MDT/OCL it can take an EMF change Notification and compute an expression based on the state of the model *before* the change happened.

Best regards,
-- Axel
Re: using @pre. operator. [message #655749 is a reply to message #655743] Tue, 22 February 2011 14:47 Go to previous message
Hussam  is currently offline Hussam Friend
Messages: 19
Registered: January 2011
Junior Member
Hi Axel,

I really did mistake in the example code in this topic, but I did create a new topic with the correct example, and the correct error message from the ocl parser.

I am using Eclips, in Plugin perspective, and UML model in Papyrus.

best regards,
Previous Topic:toLower() or toLowerCase()
Next Topic:using @pre. operator. in the PostConditions
Goto Forum:
  


Current Time: Sat Apr 20 15:44:56 GMT 2024

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

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

Back to the top