Class GroovyOutlet
java.lang.Object
org.apache.torque.generator.outlet.OutletImpl
org.apache.torque.generator.template.TemplateOutletImpl
org.apache.torque.generator.template.groovy.GroovyOutlet
- All Implemented Interfaces:
Outlet,TemplateOutlet
- Direct Known Subclasses:
GroovyScriptOutlet,GroovyTemplateOutlet
A Outlet which uses groovy for generation.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGroovyOutlet(QualifiedName name, ConfigurationProvider configurationProvider, String path, String encoding) Constructs a new GroovyOutlet. -
Method Summary
Modifier and TypeMethodDescriptioncreateBinding(ControllerState controllerState) execute(ControllerState controllerState) Executes the generation process; the result is returned.protected abstract StringexecuteGroovy(Map<String, Object> binding, ControllerState controllerState) Executes the Groovy script or template and retuns the reult.booleanReturns whether all options which namespaces are visible to the name space of this outlet are put into the binding.booleanReturns whether the attributes of the current source element are put into the binding.booleanReturns whether all variables which are visible to this outlet are put into the binding.voidsetOptionsInBinding(boolean optionsInBinding) Tells the outlet to put all options which name space is visible to the namespace of this outlet into the binding.voidsetSourceAttributesInBinding(boolean sourceAttributesInBinding) Tells the outlet to put the attributes of the current source element into the binding or not.voidsetVariablesInContext(boolean variablesInBinding) Tells the outlet to put all variables which are visible to this outlet into the binding.Methods inherited from class org.apache.torque.generator.template.TemplateOutletImpl
getContent, getDetokenizedPath, getPath, load, toStringMethods inherited from class org.apache.torque.generator.outlet.OutletImpl
addMergepointMapping, afterExecute, beforeExecute, getInputClass, getInputElementName, getMergepointMapping, getMergepointMappings, getName, getVariable, mergepoint, setInputClass, setInputElementName, setMergepointMapping, setVariable, setVariableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.torque.generator.outlet.Outlet
addMergepointMapping, afterExecute, beforeExecute, getInputClass, getInputElementName, getMergepointMapping, getMergepointMappings, getName, setInputClass, setInputElementName, setMergepointMapping
-
Field Details
-
TORQUE_GEN_BINDING_NAME
The name under which the Torque generator interface will be put into the binding.- See Also:
-
NULL_KEY_BINDING_NAME
The key under which the null attribute of a source element is put into the binding.- See Also:
-
-
Constructor Details
-
GroovyOutlet
public GroovyOutlet(QualifiedName name, ConfigurationProvider configurationProvider, String path, String encoding) throws ConfigurationException Constructs a new GroovyOutlet.- Parameters:
name- the name of this outlet, not null.configurationProvider- the provider for reading the templates, not null.path- the path to the templates, not null.encoding- the encoding of the file, or null if the system's default encoding should be used.- Throws:
NullPointerException- if name, path or directories are null.ConfigurationException- if an error occurs while reading the template.
-
-
Method Details
-
execute
Executes the generation process; the result is returned.- Specified by:
executein interfaceOutlet- Specified by:
executein classOutletImpl- Parameters:
controllerState- the current controller state.- Returns:
- the result of the generation, not null.
- Throws:
GeneratorException- if generation fails.- See Also:
-
executeGroovy
protected abstract String executeGroovy(Map<String, Object> binding, ControllerState controllerState) throws GeneratorExceptionExecutes the Groovy script or template and retuns the reult.- Parameters:
binding- the binding, not null.controllerState- the controller state, not null.- Returns:
- the generation result.
- Throws:
GeneratorException- if generation fails.
-
createBinding
-
setOptionsInBinding
public void setOptionsInBinding(boolean optionsInBinding) Tells the outlet to put all options which name space is visible to the namespace of this outlet into the binding. Only the variable names are used as keys in the context, the namespaces are stripped.- Parameters:
optionsInBinding- whether to put the options into the context.
-
isOptionsInBinding
public boolean isOptionsInBinding()Returns whether all options which namespaces are visible to the name space of this outlet are put into the binding.- Returns:
- whether the outlet puts the options into the context.
-
setVariablesInContext
public void setVariablesInContext(boolean variablesInBinding) Tells the outlet to put all variables which are visible to this outlet into the binding. Only the variable names are used as keys in the binding, the namespaces are stripped.- Parameters:
variablesInBinding- whether to put the variables into the context.
-
isVariablesInBinding
public boolean isVariablesInBinding()Returns whether all variables which are visible to this outlet are put into the binding.- Returns:
- whether the outlet puts the variables into the binding.
-
setSourceAttributesInBinding
public void setSourceAttributesInBinding(boolean sourceAttributesInBinding) Tells the outlet to put the attributes of the current source element into the binding or not.- Parameters:
sourceAttributesInBinding- whether to put the source attributes into the binding.
-
isSourceAttributesInBinding
public boolean isSourceAttributesInBinding()Returns whether the attributes of the current source element are put into the binding.- Returns:
- whether the outlet puts the attributes of the current source element into the binding.
-