4.4.2.1. Package

This element marks the output location of a Java package and is defined by the <package> element. A package contains interface and class elements that correspond to java interfaces and classes in this package.

Usage

Listing 4.25 <package/> example
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
<pattern>
        ...
        <package name=""
                 path=""
                 foreach="package|object|attribute|reference"
                 condition=""
                 package=""
                 var0=""
                 var1=""
                 var2=""
                 var3=""
                 var4=""
                 var5=""
                 skip="true|false">
         0 or more <interface /> elements
         0 or more <class /> elements
        </package>
        ...
</pattern>

Attributes

Table 4.20 attributes of <package/>

Name

Details

name

The name of the java package made

path

The path relating to the java output folder as defined in the MetaFactory project.

foreach

Indicates whether the package must be created for each element in model (value of foreach determines what model element). Possible values: package, object, attribute, reference

package

The <package> element also has a package attribute. The latter points to the package element of the model.

object

The name of the model element used to apply the foreach attribute.

condition

An expression that evaluates to true or false. Generation of the current file wil precede if true and otherwise not. .. code-block:

condition="${object.name}=Person"

In this case, the package is generated only if the current model object has the name: Person. This works only if all model objects are iterated (foreach=”object”).

var0

Value that you wish to store in the pre-defined variable with the name var0. Reference to this value can be made later by means of: ${var0}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var1

Value that you wish to store in the pre-defined variable with the name var1. Reference to this value can be made later by means of: ${var1}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var2

Value that you wish to store in the pre-defined variable with the name var2. Reference to this value can be made later by means of: ${var2}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var3

Value that you wish to store in the pre-defined variable with the name var3. Reference to this value can be made later by means of: ${var3}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var4

Value that you wish to store in the pre-defined variable with the name var4. Reference to this value can be made later by means of: ${var4}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

var5

Value that you wish to store in the pre-defined variable with the name var5. Reference to this value can be made later by means of: ${var5}. This can be used in both the pattern and in a snippet (freemarker or velocity template).

skip

True or false. This works as a flag to prevent generation of this package whenever the “Use @skip of packages” checkbox of the MetaFactory tool (located inside the menu Transform) is checked. Choosing not to generate specific packages every time can reduce processing time. You might also want to use this when you work on one specific package. Setting its flag to true while false for the other packages allows generation of the package that you are working on only.