Some of the examples given in the specification assume that there is a "+" operator defined between Strings. This is not true in OCL, and there is none defined in the MOFM2T specification itself.
page 9, section 7.2 :
[trace(c.id()+ '_definition') ]
should be
[trace(c.id().concat('_definition')) ]
page 9, section 7.3 :
[file (‘file:\\’+c.name+’.java’, false, c.id + ‘impl’)]
should be
[file (‘file:\\’.concat(c.name).concat(’.java’), false, c.id.concat(‘impl’))]
Furthermore, the description of this examples tells readers that a file named "cust.sql"; this is wrong. the text below the example of 7.3 should be :
---------8<---------
Suppose the above specification was run on a class named ‘cust,’ it would produce Java code in cust.java file and a log
entry ‘processing cust’ in log.log file. Suppose after generation, the storage specification was added in the protected area
of file cust.java. Even if the classname is changed later, say to ‘customer,’ a tool will be able to retain the storage
specification in the new file customer.java as the file block takes unique id as a parameter that hasn’t changed (for ‘cust’
object). The uri ‘stdout’ denotes the stdout output stream.
--------->8---------
Page 30, Annex A.3
Counting the "+"<=>"concat" error only once, this example sports no less than 9 syntax errors. Replace all text with :
---------8<---------
[module class_header_gen ( UML ) /]
[template public class_header(c : Class)
{ Integer count = -1; }
]
[file (c.name.concat('.cpp'), false)]
[trace(c.id().concat('_header'))]
// Bit vector #defines
[for(a : Attribute | c.attribute)
{ Integer count = count + 1; }
]
#define [a.name/]_BIT [count/]
[/for]
class [c.name/] [for(c:Class | c.super) before(':') separator(',')] [c.name/] [/for]
{
bool bitVector [‘[‘.concat(c.attribute->size()).concat(’]’)/];
// Attribute declarations
[for (a : Attribute | c.attribute)]
[a.type.name/] [if(isComplexType(a.type))]*[/if] [a.name/];
[/for]
// Constructor
[c.name/]()
{
// initialize bit vector
for (int i = 0; i < [c.attribute->size()/]; i++)
{
bitVector[‘[i]’] = 0;
}
[protected ('user_code')]
// your code here
[/protected]
}
// Attribute set/get/isSpecified methods
[for (a : Attribute | c.attribute)]
void Set[a.name/] ([a.type.name/] [if(isComplexType(a.type))] * [/if] p[a.name/])
{
bitVector[’[‘.concat(a.name).concat(’_BIT]’)] = 1;
[a.name/] = p[a.name/];
}
[a.type.name/] Get[a.name/] ()
{return [a.name/];}
bool isSpecified[a.name/]()
{return bitVector[’[‘.concat(a.name).concat(’_BIT]’)];}
[/for]
// Method declarations
[for (o : Operation | c.operation) ]
[o.type.name/] [o.name/] ([for(p:Parameter | o.parameter) separator(',')] [p.type/] [p.name/] [/for]);
[/for]
}
[/trace]
[/file]
[/template]
--------->8---------
Another solution to fix these errors would be to rely on the 2.1 version of the OCL specification which will introduce a '+' operator for Strings; or to add this operator in the MOFM2T specification.