Klasse TorqueGenVelocity
java.lang.Object
org.apache.torque.generator.template.velocity.TorqueGenVelocity
This class acts as an interface to the Torque generator from the
templates. It lets the user access Torque generator properties from the
templates, and allows to execute certain action from within the templates.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungTorqueGenVelocity
(VelocityOutlet outlet, ControllerState controllerState) Constructs a generator interface within the given controllerState. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungboolean
booleanOption
(String key) Returns the option with the given key as boolean value.Returns the first child of the current source element with the given name.Returns all children of the current source element.getChildren
(String name) Returns the children of the current source element with a certain name.Returns the current controller state.static int
Returns a counter value which is increased each time this function is accessed.getModel()
Returns the current model object.Returns the parent of the current source element.Returns the current source element, if it is a SourceElement.Returns the currently processed source file.getVariable
(String key) Returns the variable with the given key.int
Returns the option with the given key as int value.mergepoint
(String mergepointName) Processes the mergepoint with the given name.now()
Returns the current date.Returns the option with the given key.static void
Resets the counter accessible thoughgetCounter()
back to 1.void
setVariable
(String key, Object value) Sets a variable.void
setVariable
(String key, Object value, String scope) Sets a variable.
-
Konstruktordetails
-
TorqueGenVelocity
Constructs a generator interface within the given controllerState.- Parameter:
outlet
- the outlet in which this generator interface will be used, not null.controllerState
- the controller context.- Löst aus:
NullPointerException
- if outlet or controllerState are null.
-
-
Methodendetails
-
mergepoint
Processes the mergepoint with the given name.- Parameter:
mergepointName
- the name of the mergepoint.- Gibt zurück:
- the output generated by the mergepoint.
- Löst aus:
GeneratorException
- if the mergepoint could not be processed completely.
-
getControllerState
Returns the current controller state.- Gibt zurück:
- The current controller state, never null.
-
getModel
Returns the current model object. This method is shorthand forgetControllerState().getModel()
- Gibt zurück:
- the current source element, never null.
-
getSourceElement
Returns the current source element, if it is a SourceElement. This method is shorthand for(SourceElement)getControllerState().getModel()
- Gibt zurück:
- the current source element, never null.
- Löst aus:
SourceException
- if the model is no SourceElement
-
getChildren
Returns all children of the current source element. This method is shorthand forgetSourceElement().getChildren()
- Gibt zurück:
- the children of the current source element, never null.
- Löst aus:
SourceException
- if the model is no SourceElement
-
getChildren
Returns the children of the current source element with a certain name. This method is shorthand forgetSourceElement().getChildren(name)
- Parameter:
name
- the name of the children elements to select.- Gibt zurück:
- the children of the current source element with the name name, never null.
- Löst aus:
SourceException
- if the model is no SourceElement
-
getChild
Returns the first child of the current source element with the given name. This method is shorthand forgetSourceElement().getChild(name)
- Parameter:
name
- the name of the child element to select.- Gibt zurück:
- the first child with the given name, or null if no such child exists.
- Löst aus:
SourceException
- if the model is no SourceElement
-
getParent
Returns the parent of the current source element.getSourceElement().getParent()
- Gibt zurück:
- the parent of the current source element, or null if the current source element has no parent.
- Löst aus:
SourceException
- if the model is no SourceElement
-
option
Returns the option with the given key. The key can either be a name prefixed with a namespace, or a name without namespace, in which case the namespace of the currently active outlet is used. In the case that the option is not set in this namespace, the parent namespaces are searched recursively. If the option is not set in any of the parent namespaces, null is returned.- Parameter:
key
- the key for the option to retrieve.- Gibt zurück:
- the option for the given key.
-
booleanOption
Returns the option with the given key as boolean value. The key can either be a name prefixed with a namespace, or a name without namespace, in which case the namespace of the currently active outlet is used. In the case that the option is not set in this namespace, the parent namespaces are searched recursively. If the option is not set in any of the parent namespaces, false is returned.- Parameter:
key
- the key for the option to retrieve.- Gibt zurück:
- the option for the given key, converted to a boolean
-
intOption
Returns the option with the given key as int value. The key can either be a name prefixed with a namespace, or a name without namespace, in which case the namespace of the currently active outlet is used. In the case that the option is not set in this namespace, the parent namespaces are searched recursively. If the option is not set in any of the parent namespaces or empty, 0 is returned.- Parameter:
key
- the key for the option to retrieve.- Gibt zurück:
- the option for the given key, converted to a boolean
-
getVariable
Returns the variable with the given key. The key can either be a name prefixed with a namespace, or a name without namespace, in which case the namespace of the currently active outlet is used. In the case that the variable is not set in this namespace, the parent namespaces are searched recursively. If the variable is not set in any of the parent namespaces, null is returned.- Parameter:
key
- the key for the variable to retrieve.- Gibt zurück:
- the variable for the given key, or null if the variable is not set or explicitly set to null.
-
setVariable
Sets a variable. The key can be given with or without namespace; in the latter case, the variable is set in the namespace of the currently active outlet. The Scope of the variable is this outlet and its children.- Parameter:
key
- the name of the variable, not nullvalue
- the value of the variable, may be null.- Löst aus:
NullPointerException
- if key or scope is null.IllegalArgumentException
- if the key is no valid QualifiedName.
-
setVariable
Sets a variable. The key can be given with or without namespace; in the latter case, the variable is set in the namespace of the currently active outlet.- Parameter:
key
- the name of the variable, not null.value
- the value of the variable, may be null.scope
- the scope of the variable, not null.- Löst aus:
NullPointerException
- if key or scope is null.IllegalArgumentException
- if the key is no valid QualifiedName.
-
getSourceFile
Returns the currently processed source file.- Gibt zurück:
- the source file which is currently processed.
-
now
Returns the current date.- Gibt zurück:
- the current date, not null.
-
getCounter
public static int getCounter()Returns a counter value which is increased each time this function is accessed. Start value is 1. IfresetCounter
is not called, the returned value is unique over the generation process.- Gibt zurück:
- the counter value.
-
resetCounter
public static void resetCounter()Resets the counter accessible thoughgetCounter()
back to 1.
-