Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Re: OCL AuditRule Constraining a String Property
Re: OCL AuditRule Constraining a String Property [message #178766] Mon, 24 March 2008 15:32
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:To change Node figure at runtime
Next Topic:How to set palette layout to view in "details" by default programmatically
Goto Forum:
  


Current Time: Tue Sep 24 19:16:19 GMT 2024

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

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

Back to the top