Java Reference
In-Depth Information
14.1.14 Expression Language
To provide support for metamodel element access, aggregation, and iteration,
Xpand uses an underlying expression language. This language is also available
within Xtend, and this section covers it. You've already seen uses of this expres-
sion language, such as in the typeSelect() function used in our earlier exam-
ple template.
The syntax of the expression language is a mixture of OCL and Java. On one
hand, this is good because it's familiar to many. On the other hand, it's not OCL.
The underlying implementation does not leverage the MDT OCL project, as does
QVT OML, which is also based on OCL. To provide side effects, QVTO itself
could be used in place of Xtend/OCL in Xpand, which is exactly the approach
that the forthcoming Xpand variant from GMF takes.
General Syntax
Let's begin with some of the basics of accessing properties, invoking operations,
and so on. Following are examples that should form a self-explanatory basis of
the expression language.
To access a property of a model element, use a simple dot notation:
modelElement.name
To access an operation defined in the model, use a dot notation with paren-
theses:
modelElement.anOperation()
To perform basic arithmetic, use the usual suspects:
(1 + 1 * 2) / 4
Boolean logic is specified using Java-like constructs and semantics:
! ((text.startsWith('t') && text.length > 0 ) | | ! false)
Literals and Special Operators for Built-In Types
Several literals exist for built-in types, each of which is described next.
Search WWH ::




Custom Search