[OCL] String Operations [message #69301] |
Tue, 30 January 2007 00:42 |
Eclipse User |
|
|
|
Originally posted by: irbull.cs.uvic.ca
Does OCL support String regular expression operations. I need to select
items whose name matches a particular regex. (Actually I just need
startWith) but I could imagine the need for more powerful operations.
Cheers,
Ian
|
|
|
Re: [OCL] String Operations [message #69398 is a reply to message #69301] |
Tue, 30 January 2007 12:47 |
Eclipse User |
|
|
|
Originally posted by: merks.ca.ibm.com
Ian,
OCL has its own newsgroup now: eclipse.modeling.mdt.ocl.
Ian Bull wrote:
> Does OCL support String regular expression operations. I need to
> select items whose name matches a particular regex. (Actually I just
> need startWith) but I could imagine the need for more powerful
> operations.
>
> Cheers,
> Ian
|
|
|
Re: [OCL] String Operations [message #69458 is a reply to message #69398] |
Tue, 30 January 2007 14:45 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Ian, Ed,
OCL defines the following operations on Strings:
size() : Integer
concat(s : String) : String
substring(lower : Integer, upper : Integer) : String
toInteger() : Integer
toReal() : Real
You can implement startsWith and endsWith using the substring operation:
context String
def: startsWith(s : String) : Boolean =
s.size() <= self.size() and self.substring(1, s.size()) = s
def: endsWith(s : String) : Boolean =
let start : Integer = self.size() - s.size() + 1 in
start > 0 and self.substring(start, self.size()) = s
In the latest build of OCL, you can actually implement def expressions of
this nature on the String library class! Or, you can follow Chris Lenz's
example on the OCL Wiki of extending the OCL Environment to add custom
operations to suit your needs:
http://wiki.eclipse.org/index.php/CustomizingOclEnvironments
I will need to update this example for M5 when it comes.
Cheers,
Christian
Ed Merks wrote:
> Ian,
>
> OCL has its own newsgroup now: eclipse.modeling.mdt.ocl.
>
>
> Ian Bull wrote:
>> Does OCL support String regular expression operations. I need to
>> select items whose name matches a particular regex. (Actually I just
>> need startWith) but I could imagine the need for more powerful
>> operations.
>>
>> Cheers,
>> Ian
|
|
|
Re: [OCL] String Operations [message #601742 is a reply to message #69301] |
Tue, 30 January 2007 12:47 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Ian,
OCL has its own newsgroup now: eclipse.modeling.mdt.ocl.
Ian Bull wrote:
> Does OCL support String regular expression operations. I need to
> select items whose name matches a particular regex. (Actually I just
> need startWith) but I could imagine the need for more powerful
> operations.
>
> Cheers,
> Ian
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: [OCL] String Operations [message #601770 is a reply to message #69398] |
Tue, 30 January 2007 14:45 |
Eclipse User |
|
|
|
Originally posted by: cdamus.ca.ibm.com
Hi, Ian, Ed,
OCL defines the following operations on Strings:
size() : Integer
concat(s : String) : String
substring(lower : Integer, upper : Integer) : String
toInteger() : Integer
toReal() : Real
You can implement startsWith and endsWith using the substring operation:
context String
def: startsWith(s : String) : Boolean =
s.size() <= self.size() and self.substring(1, s.size()) = s
def: endsWith(s : String) : Boolean =
let start : Integer = self.size() - s.size() + 1 in
start > 0 and self.substring(start, self.size()) = s
In the latest build of OCL, you can actually implement def expressions of
this nature on the String library class! Or, you can follow Chris Lenz's
example on the OCL Wiki of extending the OCL Environment to add custom
operations to suit your needs:
http://wiki.eclipse.org/index.php/CustomizingOclEnvironments
I will need to update this example for M5 when it comes.
Cheers,
Christian
Ed Merks wrote:
> Ian,
>
> OCL has its own newsgroup now: eclipse.modeling.mdt.ocl.
>
>
> Ian Bull wrote:
>> Does OCL support String regular expression operations. I need to
>> select items whose name matches a particular regex. (Actually I just
>> need startWith) but I could imagine the need for more powerful
>> operations.
>>
>> Cheers,
>> Ian
|
|
|
Powered by
FUDForum. Page generated in 0.03714 seconds