Package as Ocl Context [message #894051] |
Fri, 06 July 2012 09:48  |
Eclipse User |
|
|
|
Hi,
up to now I'm using a function parseOCL(org.eclipse.uml2.uml.Class c, java.lang.String s) which parses an OCL Constraint.
The body of this function consists basically of the following lines:
oclhelper.setContext(c);
constraint = (Constraint)oclhelper.createInvariant(s);
Now, I have an OCL Constraint which uses several classes (let's say A and B) which are not connected through an association. The constraint has the following expression:
A.id + B.id >= 0
Is it possible to parse such an OCL Constraint?
What do I have to give setContext() as parameter? If I use Class A as parameter, the raised error tells me:
Unrecognized Variable(id)
which is correct because Class A can't see B.id (because of the missing association)
I'm wondering if it's possible to call setContext with the package which contains the classes (A and B in the example) but I get the following error:
java.lang.ClassCastException: org.eclipse.uml2.uml.internal.impl.PackageImpl cannot be cast to org.eclipse.uml2.uml.Classifier
at org.eclipse.ocl.uml.internal.UMLReflectionImpl.asOCLType(UMLReflectionImpl.java:1)
at org.eclipse.ocl.AbstractEnvironmentFactory.createClassifierContext(AbstractEnvironmentFactory.java:135)
at org.eclipse.ocl.internal.helper.OCLHelperImpl.setContext(OCLHelperImpl.java:119)
Is there a possiblity to parse such a Constraint?
Thank's!
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05443 seconds