Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL AuditRule Constraining a String Property
OCL AuditRule Constraining a String Property [message #53030] Fri, 21 March 2008 11:41 Go to next message
Eclipse UserFriend
Originally posted by: martin.baus.web.de

Hi,

I'm new to OCL and can't get it right.

I'm trying to define an AuditRule Constraint for a Property with Type String
in my GMF Project.

But all the variants I tried with context, inv, post are not working.

What I need is a Constraint that defines that the String can only hold the
Characters

'0','1','2','3','4','5','6','7','8','9','[',']','{','}'

Can anyone show me how to define a constraint like this? Or maybe can give
me a link with informations on how to write OCL Constraints in Eclipse?

Thanks for your help.


Martin Baus
Re: OCL AuditRule Constraining a String Property [message #53136 is a reply to message #53030] Mon, 24 March 2008 15:32 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Martin,

It sounds like you are defining OCL constraints in a GMF context. I have
included that newsgroup in this reply.

To my knowledge, GMF's Audit constraints don't use the concrete syntax for
constraint context, so you don't want the "context MyClass inv:" preamble
on your constraint. The GMF Wiki page has some pretty good documentation
about Audits for more information.

Concerning the OCL that you need to implement this particular constraint,
something like this might do:

let allowed : Set(String) =
Set{'0','1','2','3','4','5','6','7','8','9','[',']','{','}'} in
Sequence{1..self.name.size()}->forAll(i : Integer |
allowed->includes(self.name.substring(i, i)))

assuming that it is "self.name" that you want to constrain.

HTH,

Christian


Martin Baus wrote:

> Hi,
>
> I'm new to OCL and can't get it right.
>
> I'm trying to define an AuditRule Constraint for a Property with Type
> String in my GMF Project.
>
> But all the variants I tried with context, inv, post are not working.
>
> What I need is a Constraint that defines that the String can only hold the
> Characters
>
> '0','1','2','3','4','5','6','7','8','9','[',']','{','}'
>
> Can anyone show me how to define a constraint like this? Or maybe can give
> me a link with informations on how to write OCL Constraints in Eclipse?
>
> Thanks for your help.
>
>
> Martin Baus
Previous Topic:Reserved keywords?
Next Topic:validate applied to umleditor
Goto Forum:
  


Current Time: Fri Apr 19 21:34:58 GMT 2024

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

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

Back to the top