Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » EDataType support in OCL
EDataType support in OCL [message #44923] Tue, 27 November 2007 12:49 Go to next message
Matthew Rawlings is currently offline Matthew RawlingsFriend
Messages: 39
Registered: July 2009
Member
I am looking for information on EType support in OCL.

My eCore model frequently uses EBigInteger [java.math.BigInteger]. OCL
constraints of the kind {self.number > 0} don't work when number is of
type EBigInteger. I get the message "ERROR inm (operationalCallExpCS):
(Cannot find operation (>(Integer)) for the type (EBigInteger))". When I
change the EBigInteger to EInt [int] the OCL works fine.

1. How do I make this OCL work for an attribute of type EBigInteger?
2. What is different between EBigInteger and EInt that triggers this
difference in behaviour?
3. Where can I find a list of all supported values for EType and their
mapping to OCL types. All I can find so far is this post from Christian
Damus:
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.o cl/msg00833.html.
This helps but is only a partial mapping.
4. Is there any documentation or references for this?
Re: EDataType support in OCL [message #44957 is a reply to message #44923] Tue, 27 November 2007 13:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Matthew,

See some replies in-line, below.

HTH,

Christian

Matthew Rawlings wrote:

> I am looking for information on EType support in OCL.
>
> My eCore model frequently uses EBigInteger [java.math.BigInteger]. OCL
> constraints of the kind {self.number > 0} don't work when number is of
> type EBigInteger. I get the message "ERROR inm (operationalCallExpCS):
> (Cannot find operation (>(Integer)) for the type (EBigInteger))". When I
> change the EBigInteger to EInt [int] the OCL works fine.

Right. The Ecore binding of MDT OCL currently does not recognize
EBigInteger as corresponding to the Integer data type from the OCL Standard
Library. So, it's just an opaque value type as far as OCL can tell.


> 1. How do I make this OCL work for an attribute of type EBigInteger?

Until MDT OCL is changed, you can work around this by specializing the
EcoreEnvironment, extending the lookupOperation(...) method to return a an
EOperation matching the signature that you need. Implement a corresponding
subclass of the EcoreEvaluationEnvironment, then, to evaluate this
operation by extending the callOperation(...) method.

This would be very similar to the "Defining Helper Operations in Java"
example shown in the "Customizing the Environment" topic in the OCL
Developer Guide in the Eclipse help viewer. It is also available on-line:

http://help.eclipse.org/help33/topic/org.eclipse.ocl.doc/ref erences/overview/advanced/customization.html

Of course, not everyone should have to work around this, so you might raise
an enhancement request and even contribute a patch (with JUnit tests) that
updates the code I cite, below.


> 2. What is different between EBigInteger and EInt that triggers this
> difference in behaviour?

The
org.eclipse.ocl.ecore.internal.UMLReflectionImpl::getOCLType For(EDataType)
method maps any EDataType whose instance-class is Integer or int to OCL
Integer (along with Long/long and Short/short). EInt has the expected
instance-class, EBigInteger does not.


> 3. Where can I find a list of all supported values for EType and their
> mapping to OCL types. All I can find so far is this post from Christian
> Damus:
>
http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.o cl/msg00833.html.
> This helps but is only a partial mapping.

This is the getOCLTypeFor(EDataType) method I mentioned, above.

> 4. Is there any documentation or references for this?

If it's not in the SDK documentation, then no.
Re: EDataType support in OCL. ELong supported? [message #60394 is a reply to message #44957] Mon, 11 August 2008 18:42 Go to previous message
Eclipse UserFriend
Originally posted by: birar01.ca.com

I'm having problems with ELong. I wanted to confirm if I should also be
using the helper operation method described below or if I'm doing something
wrong.

thanks,
-Arvinder Birdi

In ocl I specify a maximum value for a field which EInt cannot store but
then get a parse error:

java.lang.NumberFormatException: For input string: "4294967295"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.valueOf(Unknown Source)
at
org.eclipse.ocl.internal.parser.OCLLPGParser.createIntegerLi teralExpCS(OCLLPGParser.java:477)
at
org.eclipse.ocl.internal.parser.OCLLPGParser.ruleAction(OCLL PGParser.java:2018)
at
lpg.lpgjavaruntime.DeterministicParser.processReductions(Det erministicParser.java:55)
at
lpg.lpgjavaruntime.DeterministicParser.parse(DeterministicPa rser.java:115)
at
org.eclipse.ocl.internal.parser.OCLLPGParser.parser(OCLLPGPa rser.java:178)
at
org.eclipse.ocl.internal.parser.OCLLPGParser.parser(OCLLPGPa rser.java:150)
at
org.eclipse.ocl.internal.parser.OCLParser.parseConcreteSynta x(OCLParser.java:743)
at
org.eclipse.ocl.internal.parser.OCLParser.parsePackageDeclar ationCS(OCLParser.java:801)
at org.eclipse.ocl.OCL.parse(OCL.java:243)


When I specify a vale which EInt can store I get the following exception at
runtime:

java.lang.ClassCastException: java.lang.Integer cannot be cast to
java.lang.Long
at java.lang.Long.compareTo(Unknown Source)
at
org.eclipse.ocl.internal.evaluation.EvaluationVisitorImpl.vi sitOperationCallExp(EvaluationVisitorImpl.java:1067)
at
org.eclipse.ocl.ecore.impl.OperationCallExpImpl.accept(Opera tionCallExpImpl.java:336)
at
org.eclipse.ocl.AbstractEvaluationVisitor.visitExpression(Ab stractEvaluationVisitor.java:223)
at
org.eclipse.ocl.internal.evaluation.QueryImpl.evaluate(Query Impl.java:120)
at
org.eclipse.ocl.internal.evaluation.QueryImpl.check(QueryImp l.java:151)
at org.eclipse.ocl.ecore.QueryImpl.check(QueryImpl.java:54)
at
org.eclipse.emf.validation.ocl.AbstractOCLModelConstraint$Qu eryManager.check(AbstractOCLModelConstraint.java:261)
at
org.eclipse.emf.validation.ocl.AbstractOCLModelConstraint.va lidate(AbstractOCLModelConstraint.java:205)



"Christian W. Damus" <cdamus@ca.ibm.com> wrote in message
news:fih5ed$3cj$1@build.eclipse.org...
> Hi, Matthew,
>
> See some replies in-line, below.
>
> HTH,
>
> Christian
>
> Matthew Rawlings wrote:
>
>> I am looking for information on EType support in OCL.
>>
>> My eCore model frequently uses EBigInteger [java.math.BigInteger]. OCL
>> constraints of the kind {self.number > 0} don't work when number is of
>> type EBigInteger. I get the message "ERROR inm (operationalCallExpCS):
>> (Cannot find operation (>(Integer)) for the type (EBigInteger))". When I
>> change the EBigInteger to EInt [int] the OCL works fine.
>
> Right. The Ecore binding of MDT OCL currently does not recognize
> EBigInteger as corresponding to the Integer data type from the OCL
> Standard
> Library. So, it's just an opaque value type as far as OCL can tell.
>
>
>> 1. How do I make this OCL work for an attribute of type EBigInteger?
>
> Until MDT OCL is changed, you can work around this by specializing the
> EcoreEnvironment, extending the lookupOperation(...) method to return a an
> EOperation matching the signature that you need. Implement a
> corresponding
> subclass of the EcoreEvaluationEnvironment, then, to evaluate this
> operation by extending the callOperation(...) method.
>
> This would be very similar to the "Defining Helper Operations in Java"
> example shown in the "Customizing the Environment" topic in the OCL
> Developer Guide in the Eclipse help viewer. It is also available on-line:
>
> http://help.eclipse.org/help33/topic/org.eclipse.ocl.doc/ref erences/overview/advanced/customization.html
>
> Of course, not everyone should have to work around this, so you might
> raise
> an enhancement request and even contribute a patch (with JUnit tests) that
> updates the code I cite, below.
>
>
>> 2. What is different between EBigInteger and EInt that triggers this
>> difference in behaviour?
>
> The
> org.eclipse.ocl.ecore.internal.UMLReflectionImpl::getOCLType For(EDataType)
> method maps any EDataType whose instance-class is Integer or int to OCL
> Integer (along with Long/long and Short/short). EInt has the expected
> instance-class, EBigInteger does not.
>
>
>> 3. Where can I find a list of all supported values for EType and their
>> mapping to OCL types. All I can find so far is this post from Christian
>> Damus:
>>
> http://dev.eclipse.org/newslists/news.eclipse.modeling.mdt.o cl/msg00833.html.
>> This helps but is only a partial mapping.
>
> This is the getOCLTypeFor(EDataType) method I mentioned, above.
>
>> 4. Is there any documentation or references for this?
>
> If it's not in the SDK documentation, then no.
Previous Topic:VariableExp in OCL 1.2.0 breaks compatibility to 1.1.2?
Next Topic:Long exceptions
Goto Forum:
  


Current Time: Thu Apr 25 13:50:31 GMT 2024

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

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

Back to the top