Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values.
[EMFatic] Help with ExtendedAnnotations, Regular Expressions and constrained values. [message #623095] Tue, 03 August 2010 23:06
Toñi  Reina is currently offline Toñi ReinaFriend
Messages: 209
Registered: July 2009
Senior Member
Hi all,

I'm trying to incorporate to my emfatic/ecore metamodel some
constrained datatypes. Unfortunately, I haven't found any clear
documentation about that matter. So, I have mixed things from one site
and another, and I finally found that some constrains can be added with
the @ExtendedMetadata annotation. So I have specified a Name datatype,
and I have written a regular expression in order to constraint the
strings that are candidates to be names. For me, a name has to start
with a letter or an underscore and can be followed by cero or more
characters (letters, digits or underscores). I have written the
following annotation associated to the datatype.

@ExtendedMetadata(name="isIdentifier",
baseType="http://www.eclipse.org/emf/2003/XMLType#string",
pattern="^[a-zA-Z_]([a-zA-Z_0-9])*$")
datatype Name: java.lang.String;

Oher kind of constraint I want to write is related to constraining the
values possible values of other datatype. In this case, I have used the
properties minInclusive and maxInclusive, because my PortNumber has to
be a number between 0 and 65534, both inclusive. Below, I have included
the corresponding annotation.

@ExtendedMetadata(name="PortNumber",
baseType="http://www.eclipse.org/emf/2003/XMLType#integer",
minInclusive="0",
maxInclusive="65534")
datatype PortNumber:java.lang.Integer;

The question is that although the editor I'm generating and the
Reflective EMF Editor seem to have into account the constraints, each
time I write a value for a typed PortNumber attribute or a typed Name
attribute, the value is erased, as if the value does not fulfill the
constraint. I have tested with different values for a typed PortNumber
attribute, such as 0, 1, 65534, 7000.

I also have tested a typed Name attribute, and I have introduced values
such as A, My_Name, ...

I don't know if there's something that I'm missing. I also would
appreciate some extra documentation about this ExtendedMetadata
annotations, what kind of regular expressions can be written in the
pattern section, what other kind of constrains can be specified with
this extendedMetadata annotations, and if there is some way of testing
the regular expressions before writing them in the annotations.

Thanks in advance,
Previous Topic:[mwe] Use of the property multipleResourcesInCaseOfList of the mwe writer
Next Topic:[MWE] Any libraries?
Goto Forum:
  


Current Time: Sat Apr 20 14:39:08 GMT 2024

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

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

Back to the top