"FOR" is the most important generator command. It is used to navigate
through the hierarchical structure of input data.
Syntax
<for>variable iterator[@objname][<asc>sort expression][<desc>sort expression][<dist>]<where>{boolean_expression}<div>divider<wrap>wrap<container>[environment][<@>container]<begin>body<endfor>
<for>variable iterator[@objname][<asc>sort expression][<desc>sort expression][<dist>]^{boolean_expression}^divider^wrap^[environment]@[container]<begin>body<endfor>
for each element in iterator
collection of objname object
matching
filter expression generates code based on body expression
- variable - name
(or names connected by ".") of
variable(s) used
to denote current element
- iterator - name
(or names connected by ".") of
collection. Optionally iterator can be followed by objname identifier. Objname is used to change the
object iterator should be applied to. Note: objname doesn't change the
container; to change it use environment
element. Depends on {objname} object type can be the following (type
with minus sign on the end means "do not proceed inherited
attributes/associations")
- packages;
applicable to packages, iterates through child packages
- classes;
applicable to packages, iterates through child classes
- attributes, attributes-;
applicable to classes, iterates through class attributes
- methods;
applicable to classes, iterates through class methods
- parameters;
applicable to methods, iterates through method parameters
- roles (associations),
roles- (associations-);
applicable to classes, iterates through roles associated with given
class
- selfroles
(associations1), selfroles- (associations1-); applicable to classes, iterates
through opposite roles associated with given class
- type; applicable
to roles, returns the opposite class
- refattribute;
applicable to roles, returns pseudo attribute associated with role
- parent;
applicable to packages, returns the parent package
- objname -
optional, name of object - owner of collection,
by
default it is current object
- boolean
expression
- divider -
expression inserted between generated codes of
different elements
- wrap - expression
iserted in the middle of the generated
code
if length of the line exeeds 100 characters
- environment@container -
identifies container and/or environment modificator, format is
- body - expression
generated for each element of
collection
matching the boolean expression
Example
of usage
To show list of classes in a
UML
package use the following code
<for>x
classes<begin>Class %.name%
<endfor>