Ocl expressions [message #876004] |
Wed, 23 May 2012 14:11  |
Eclipse User |
|
|
|
Hi guys!
I'm working with OCL expressions and I need a expression that
validate a string in the context that it starter with a letter and not
with caracteres as !,?,*,&,^%,$.
Some idea how can I do that?
I tried to do with a regular expression, but I had no success.
Thank's for the help and sorry for the english!
|
|
|
Re: Ocl expressions [message #876027 is a reply to message #876004] |
Wed, 23 May 2012 15:15   |
Eclipse User |
|
|
|
Hi
With the Ecore-binding in Indigo; you have only substring.
With the Pivot-binding in Indigo; you also have characters(), at() to
play with.
In Juno, you have characters(), startsWith(), at(), match() to play with.
Regards
Ed Willink
On 23/05/2012 19:11, Pablo Silva wrote:
> Hi guys!
>
>
> I'm working with OCL expressions and I need a expression that
> validate a string in the context that it starter with a letter and not
> with caracteres as !,?,*,&,^%,$.
>
>
> Some idea how can I do that?
>
> I tried to do with a regular expression, but I had no success.
>
> Thank's for the help and sorry for the english!
|
|
|
|
|
Re: Ocl expressions [message #876054 is a reply to message #876004] |
Wed, 23 May 2012 16:23   |
Eclipse User |
|
|
|
Because I'm a new user in the OCL.
I'm learning about that.
Actually I am trying to place restrictions on a GMF graphical editor that I created. But I want these restrictions are implemented in EMF Ecore Model, because then it will be easier to manage them.
I've done to restrictions such as the name of a Node can not be empty, or that two nodes can not have the same name.
Take a look in my Ecore Model open in OCLinEcore editor:
package my : my = 'my'
{
class Graph
{
invariant NoDuplicateEdgeNames: edges->forAll(e1, e2 | e1 <> e2 implies e1.name <> e2.name);
invariant NoDuplicateNodeNames: nodes->forAll(n1, n2 | n1 <> n2 implies n1.name <> n2.name);
invariant NoMultiGraphs: edges->forAll(e1, e2 | e1 <> e2 implies (e1.start <> e2.start) or (e1.end <> e2.end));
invariant NoSameOneNodes: edges->forAll( e1, e2 | e1 = e2 implies e1.start<>e1.end);
property nodes : Node[*] { composes };
property edges : Edge[*] { composes };
attribute name : String[?];
annotation 'gmf.diagram'(onefile = 'true', 'diagram.extension' = 'Graph');
}
class Node
{
invariant noEmptyName: self.name->notEmpty();
invariant noInvalidCaracter:;
attribute name : String[?];
attribute startNode : Boolean[?];
annotation 'gmf.node'(label = 'name', figure = 'ellipse');
}
class Edge
{
property start : Node[1];
property end : Node[1];
attribute name : String[?];
annotation 'gmf.link'(label = 'name', source = 'start', target = 'end', 'target.decoration' = 'arrow');
}
}
All constraints are working, but I don't know how to do for to validate a name as I said before!
I can't find a document with all methods of OCL. If you could show me a link where
I can get this, I'll be grateful!
Pablo Silva
|
|
|
Re: Ocl expressions [message #876078 is a reply to message #876054] |
Wed, 23 May 2012 17:26   |
Eclipse User |
|
|
|
Hi
Have you tried Help Contents OCL Documentation?
Have you tried the OCL specification?
Regards
Ed Willink
On 23/05/2012 21:23, Pablo Silva wrote:
> Because I'm a new user in the OCL.
> I'm learning about that.
>
> Actually I am trying to place restrictions on a GMF graphical editor
> that I created. But I want these restrictions are implemented in EMF
> Ecore Model, because then it will be easier to manage them.
>
> I've done to restrictions such as the name of a Node can not be empty,
> or that two nodes can not have the same name.
> Take a look in my Ecore Model open in OCLinEcore editor:
>
>
>
> package my : my = 'my'
> {
> class Graph
> {
> invariant NoDuplicateEdgeNames: edges->forAll(e1, e2 | e1 <>
> e2 implies e1.name <> e2.name);
> invariant NoDuplicateNodeNames: nodes->forAll(n1, n2 | n1 <>
> n2 implies n1.name <> n2.name);
> invariant NoMultiGraphs: edges->forAll(e1, e2 | e1 <> e2
> implies (e1.start <> e2.start) or (e1.end <> e2.end));
> invariant NoSameOneNodes: edges->forAll( e1, e2 | e1 = e2
> implies e1.start<>e1.end);
> property nodes : Node[*] { composes };
> property edges : Edge[*] { composes };
> attribute name : String[?];
> annotation 'gmf.diagram'(onefile = 'true', 'diagram.extension'
> = 'Graph');
> }
> class Node
> {
> invariant noEmptyName: self.name->notEmpty();
> invariant noInvalidCaracter:;
> attribute name : String[?];
> attribute startNode : Boolean[?];
> annotation 'gmf.node'(label = 'name', figure = 'ellipse');
> }
> class Edge
> {
> property start : Node[1];
> property end : Node[1];
> attribute name : String[?];
> annotation 'gmf.link'(label = 'name', source = 'start', target
> = 'end', 'target.decoration' = 'arrow');
> }
> }
>
> All constraints are working, but I don't know how to do for to
> validate a name as I said before!
>
> I can't find a document with all methods of OCL. If you could show me
> a link where
> I can get this, I'll be grateful!
>
> Pablo Silva
>
|
|
|
|
|
|
|
Re: Ocl expressions [message #879764 is a reply to message #879725] |
Thu, 31 May 2012 15:46  |
Eclipse User |
|
|
|
Hi
You can certainly use def: to define an operation; that's what it is for.
But as in my answer on the other newsgroup you must use String not
'Character'.
Regards
Ed Willink
On 31/05/2012 19:18, Pablo Silva wrote:
> I try to do this expression:
>
> def:validate(n:Integer):Boolean =
> (self.name.substring(n,n)<='@' or self.name.substring(n,n)>='[') and
> (self.name.substring(n,n)<='`' or self.name.substring(n,n)>='{')=
> true inv: let tam:Integer = self.name.size() in
> validate(tam)
>
> But is wrong. I would like to know if I can do that, i.e., use a def
> like a function?
>
> Thank's for the help.
|
|
|
Powered by
FUDForum. Page generated in 0.03914 seconds