Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCLInvalid Error (Substring)
OCLInvalid Error [message #658697] Wed, 09 March 2011 13:56 Go to next message
Hussam  is currently offline Hussam Friend
Messages: 19
Registered: January 2011
Junior Member
Hello every body here,


I have just a question , you can note it from the two Ocl expressions:


First One:

Association.allInstances()-> select(asso:Association|(asso.name.substring(1,9)='DR!{Hamad ') )


Results:
<<evlvAddDomainAssociation, evlvRenamedAssociation>> <Association> DR!{Hamada, Ramada}HO!{Hima, barhoom}


the second one:

Association.allInstances()-> select(asso:Association|(asso.name.substring(1,(10))='DR!{Ha mada') )


Results:
OclInvalid


The question is what is the problem with there in the second OCL constraint?


best regards to all of you.
Re: OCLInvalid Error [message #658700 is a reply to message #658697] Wed, 09 March 2011 14:21 Go to previous messageGo to next message
Axel Uhl is currently offline Axel UhlFriend
Messages: 40
Registered: July 2009
Member
I'm sceptical the expressions are shown exactly the way you presented them to the parser. Your first expression contains a blank at the end of the string literal and hence can't have matched the association you show as the result because 'Hamada' <> 'Hamad '.

Based on this it may be hard to find any issue with the second expression. At first glance the only obvious difference is the parentheses around the integer literal 10. If the parentheses were to cause an OclInvalid, the parser would have a serious problem. Can you please try without the parentheses around the 10?

Best,
-- Axel
Re: OCLInvalid Error [message #658754 is a reply to message #658700] Wed, 09 March 2011 16:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4194
Registered: July 2009
Senior Member
Hi

It definitely looks like the parentheses, but putting similar
parentheses into some existing JUnit tests shows no problem.

(It's an evaluation rather than a parser problem.)

Can you clarify the typo, and what version of what tool you use to
observe your results?

Regards

Ed Willink

On 09/03/2011 14:21, Axel Uhl wrote:
> I'm sceptical the expressions are shown exactly the way you presented
> them to the parser. Your first expression contains a blank at the end
> of the string literal and hence can't have matched the association you
> show as the result because 'Hamada' <> 'Hamad '.
>
> Based on this it may be hard to find any issue with the second
> expression. At first glance the only obvious difference is the
> parentheses around the integer literal 10. If the parentheses were to
> cause an OclInvalid, the parser would have a serious problem. Can you
> please try without the parentheses around the 10?
>
> Best,
> -- Axel
Re: OCLInvalid Error [message #658762 is a reply to message #658754] Wed, 09 March 2011 17:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4194
Registered: July 2009
Senior Member
Hi

Nothing to do with parentheses; just length;

The ten character substring of a nine character string should be 'invalid'.

Regards

Ed Willink

On 09/03/2011 16:42, Ed Willink wrote:
> Hi
>
> It definitely looks like the parentheses, but putting similar
> parentheses into some existing JUnit tests shows no problem.
>
> (It's an evaluation rather than a parser problem.)
>
> Can you clarify the typo, and what version of what tool you use to
> observe your results?
>
> Regards
>
> Ed Willink
>
> On 09/03/2011 14:21, Axel Uhl wrote:
>> I'm sceptical the expressions are shown exactly the way you presented
>> them to the parser. Your first expression contains a blank at the end
>> of the string literal and hence can't have matched the association
>> you show as the result because 'Hamada' <> 'Hamad '.
>>
>> Based on this it may be hard to find any issue with the second
>> expression. At first glance the only obvious difference is the
>> parentheses around the integer literal 10. If the parentheses were to
>> cause an OclInvalid, the parser would have a serious problem. Can you
>> please try without the parentheses around the 10?
>>
>> Best,
>> -- Axel
>
Re: OCLInvalid Error [message #658764 is a reply to message #658762] Wed, 09 March 2011 17:35 Go to previous messageGo to next message
Hussam  is currently offline Hussam Friend
Messages: 19
Registered: January 2011
Junior Member
Hello All,
Thanks for the reply ,


but I still have the same problem, whenever I use number >9 it gives me the same invalid .

Association.allInstances()-> select(asso:Association|(asso.name.substring(1,9)='DR!{Hamad ') )


Results:
<<evlvAddDomainAssociation, evlvRenamedAssociation>> <Association> DR!{Hamada, Ramada}HO!{Hima, barhoom}


the second one:

Association.allInstances()-> select(asso:Association|(asso.name.substring(1,10)='DR!{Hama da, Ramada}HO!{Hima') )


Results:
OclInvalid


So what is the problem now,? do not care about the blank , it occurs just here in this text ,

Thanx for your help,

Regards
Re: OCLInvalid Error [message #658768 is a reply to message #658764] Wed, 09 March 2011 17:50 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4194
Registered: July 2009
Senior Member
Hi

Note that the substring selection is within a select, so if ANY
Association has less than 9/10 charcters you will get invalid.

Regards

Ed Willink

On 09/03/2011 17:35, Hussam wrote:
> Hello All,
> Thanks for the reply ,
>
>
> but I still have the same problem, whenever I use number >9 it gives
> me the same invalid .
>
> Association.allInstances()->
> select(asso:Association|(asso.name.substring(1,9)='DR!{Hamad ') )
>
>
> Results:
> <<evlvAddDomainAssociation, evlvRenamedAssociation>> <Association>
> DR!{Hamada, Ramada}HO!{Hima, barhoom}
>
>
> the second one:
>
> Association.allInstances()->
> select(asso:Association|(asso.name.substring(1,10)='DR!{Hama da,
> Ramada}HO!{Hima') )
>
>
> Results:
> OclInvalid
>
>
> So what is the problem now,? do not care about the blank , it occurs
> just here in this text ,
> Thanx for your help,
>
> Regards
Re: OCLInvalid Error [message #658771 is a reply to message #658768] Wed, 09 March 2011 18:16 Go to previous messageGo to next message
Hussam  is currently offline Hussam Friend
Messages: 19
Registered: January 2011
Junior Member
Thanx ED Willink,

I think you got what I want to do,

I need to query some association according to substring, how to do that out of the select statement?

Regards
Re: OCLInvalid Error [message #658782 is a reply to message #658771] Wed, 09 March 2011 18:32 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4194
Registered: July 2009
Senior Member
Hi Hussam

In the same way as Java.

Guard an access to an invalid index with a bounds check.

Regards

Ed Willink


On 09/03/2011 18:16, Hussam wrote:
> Thanx ED Willink,
>
> I think you got what I want to do,
>
> I need to query some association according to substring, how to do
> that out of the select statement?
>
> Regards
Previous Topic:Extend Ocl parser.
Next Topic:[Announce] MDT/OCL 3.1.0 M6 is now available
Goto Forum:
  


Current Time: Sat Dec 27 08:51:39 GMT 2014

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

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