Java Reference
In-Depth Information
syntax of a mapping operation, where <direction> is one of in , out , or inout .
A mapping is either contextual, as seen here, where X represents the type and
prefixes the mapping name, or noncontextual, where the input parameter is
explicitly declared, as in mapping XtoR(in x : X) : R .
mapping <direction> X::name
(<direction> p1:P1, <direction> p2:P2) : r1:R1, r2:R2
when { ... }
where { ... }
{
init { ... }
population { ... }
end { ... }
}
A mapping has a name, which, by convention, follows either an X::<input_
element>2<output_element>() or X::to<output_element>() pattern,
where X represents the input element type. The mapping name is prefixed by the
fully qualified input element, separated by double colons. This is standard OCL
namespace syntax. The input object is referenced using self within the mapping .
Note that a mapping can be declared as abstract.
Parameters are comma separated and indicate direction in|out|inout fol-
lowed by name and type information. Input parameters cannot be modified,
while inout parameters can be updated. The out parameter receives a new value
but cannot be newly created if a previous mapping invocation for the input
instance has been processed. The following example specifies a single input
parameter named targetType and conforms to the type UML::DataType . In
this case, UML is defined by a modeltype declaration at the top of the trans-
formation.
The result is declared following a single colon after the parameter list. In the
following example, the return conforms to the type RDB::TableColumn , where
RDB is also defined by a modeltype declaration. Note that it's possible to have
multiple results for a mapping. The result keyword is used to reference the
return object, or tuple, in the case of multiple result objects.
mapping UML::Property::primitiveAttribute2column( in targetType :
UML::DataType) : RDB::TableColumn
when { self .isPrimitive() }
{
isPrimaryKey := self .isPrimaryKey();
name := self .name;
. . .
}
Search WWH ::




Custom Search