Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [OCL] String Operations
[OCL] String Operations [message #69301] Mon, 29 January 2007 19:42 Go to next message
Eclipse UserFriend
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 07:47 Go to previous messageGo to next message
Eclipse UserFriend
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 09:45 Go to previous message
Eclipse UserFriend
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 07:47 Go to previous message
Eclipse UserFriend
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 #601770 is a reply to message #69398] Tue, 30 January 2007 09:45 Go to previous message
Eclipse UserFriend
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
Previous Topic:Generating EMF model with virtual attributes
Next Topic:Teneo: More than one class with same name
Goto Forum:
  


Current Time: Sat Jun 07 11:48:56 EDT 2025

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

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

Back to the top