Chapter 5 Object Languages Reference Guide


Templates category

Templates are used to define what to generate for the current object.

For more information on the use of templates, see section Defining templates, in chapter Generation Reference Guide.

Example

The following template is defined for operations in Java. It sets the rules on visibility display. It is also available in the Templates category for attributes and classes.


For more information on the Templates category, see section Defining templates and generated files in a profile, in chapter Managing profiles.

Note   Use the F12 key to find templates
You can find all templates of the same name using the F12 key. To do so, open a template, position the cursor on a template name in-between % characters, and hit the F12 key. This opens a Browse window that displays all templates prefixed by their metaclass name.
Example: position the cursor on %definition% inside a template, hit F12. The Browse window displays all <metaclass_name>::definition. You can then double-click the template of your choice in the Browse window to directly position the cursor on the selected template

How do generated files and templates work together?

In the following example, the Generated Files category for classifiers contains a 'Java Source' entry. This entry contains the template named %source% in the text zone.


When you open the Templates category for classifiers, the template named 'source' is displayed. When the file is generated for a given classifier or for the instances of a classifier with a selected stereotype or criterion, the template evaluated is the 'source' template. The name of the file generated corresponds to the entry in the File name box.


Association roles

You can define implementation collections for associations. The evaluated association attributes are: RoleName, Visibility, Multiplicity, Implementation (RoleAContainer or RoleBContainer), ImplementationClass, Ordering, Navigability, Changeability, Initial Value, Persistent, Volatile, Minimum Multiplicity, Maximum Multiplicity, Classifier (ClassA or ClassB). You have to set the active role of the association using attributes RoleAActive or RoleBActive. When you reference RoleAActive for example, then role A of association becomes active and the implementation script can return attributes corresponding to role A.

 


Copyright (C) 2005. Sybase Inc. All rights reserved.