Ocl question- check string is an integer similar to Integer.parseInt(myString)? [message #217449] |
Fri, 06 February 2009 07:12  |
Eclipse User |
|
|
|
Hi,
I would like to ask if there is any way to check if a String is an Integer
using an Ocl constraint.
For example in java you can do something like:
1. Integer.parseInt(myString) and catch the exception or
2. boolean isInteger = Pattern.matches("^\d*$", myString)
Is there any way to perform something similar to the above in OCL?
I tried to use something like self.value.oclIsTypeOf(Integer) but the
oclIsTypeOf property deals with the direct type of an object.
e.g. context Person
inv: self.oclIsTypeOf( Person ) -- is true
inv: self.oclIsTypeOf( Company) -- is false
I tried to use something like self.value.oclIsKindOf(Integer) but the
oclIsKindOf property determines whether value is either the direct type or
one of the supertypes of an object.
Any suggestions how this can be done?
Thanks,
Achilleas
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03416 seconds