A Velocity variable can be either a referenced Java object or a declared variable inside a template. A Velocity variable begins with $ followed by the name of the variable. Depending on what is added to the Velocity Context (MagicDraw automatically adds its element to the Velocity Context) the variable can either be a local variable or a reference to a Java object.

To declare a local variable inside a template, type: $ followed by a string beginning with a letter. A referenced Java object variable is provided by Report Wizard as shown in the following table  (see the Linking Report Wizard template to MagicDraw section for a complete list of variables).

The table shows a partial list of MagicDraw specific variables.

Variable Name

Return Value

$Class

Contains a list of class elements.

$UseCase

Contains a list of use case elements.

$Diagram

Contains a list of diagram elements.

 

If a Velocity variable is a reference to a Java object, you can call its methods and value by:

  • Directly calling the object method with the Velocity variable, for example, $object.method().This is useful if you want to use a Java object's method to process data and print it out.
  • Calling the object properties, for example, $object.name.

Velocity allows you to call the referenced Java object's method directly like you would in Java. This is very useful as you can create methods in Java that can help you create a more flexible Velocity template. For instance, if you need to perform a complex operation, such as sorting a list according to certain variables, you can create a sorting method in Java, and then call that method from a Java object.

Report Wizard provides a collection of complex statements in standard tool methods. You can find more information on the standard tool in the Helper Modules section, Report Wizard User Guide. You can also create your own custom tool, deploy, and use it inside a template. For more information on the custom tool, see Appendix A: Report Extensions, Report Wizard User Guide.