Class OutletImpl
java.lang.Object
org.apache.torque.generator.outlet.OutletImpl
- All Implemented Interfaces:
Outlet
- Direct Known Subclasses:
CopyOutlet,JavadocOutlet,JavaFilenameOutlet,ModifySourcenameOutlet,OutletWithoutMergepoints,TemplateOutletImpl
Implementation of the features in the
Outlet interface
which do not depend on type of Outlet.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMergepointMapping(MergepointMapping mergepointMapping) Adds an mergepoint mapping to the outlet.voidafterExecute(ControllerState controllerState) Adjusts the state of the Controller after generation.voidbeforeExecute(ControllerState controllerState) Adjusts the state of the Controller before generation.abstract OutletResultexecute(ControllerState controllerState) Generates the output for this template into the Generated object.Returns the fully qualified name of the input root class.Returns the name of the input root element.getMergepointMapping(String name) Returns the mergepoint mapping for the given mergepoint name.Returns the map of all mergepoint mappings, keyed by their name.getName()Returns the name of the outlet.getVariable(String key, ControllerState controllerState) Returns the variable with the given key.mergepoint(String mergepointName, ControllerState controllerState) Processes the mergepoint with the given name.voidsetInputClass(String inputClass) Sets the fully qualified name of the input model root class.voidsetInputElementName(String inputElementName) Sets the name of the input root element.setMergepointMapping(MergepointMapping mergepointMapping) Sets an mergepoint mapping in the outlet.voidsetVariable(String key, Object value, ControllerState controllerState) Sets a variable.voidsetVariable(String key, Object value, Variable.Scope scope, ControllerState controllerState) Sets a variable.toString()
-
Constructor Details
-
OutletImpl
Constructs a OutletImpl with the given name.- Parameters:
name- the name of this outlet, not null.- Throws:
NullPointerException- if name is null.
-
-
Method Details
-
getName
Description copied from interface:OutletReturns the name of the outlet. The namespace part of the name defines the default context of the outlet. -
getInputElementName
Description copied from interface:OutletReturns the name of the input root element. If not null, the outlet checks if the name of the input root element corresponds to the set element name and throws an exception if the names do not match.- Specified by:
getInputElementNamein interfaceOutlet- Returns:
- inputName the name of the root element of the source, or if any input name is accepted.
-
setInputElementName
Description copied from interface:OutletSets the name of the input root element. If set, the outlet checks if the name of the input root element corresponds to the set element name and throws an exception if the names do not match.- Specified by:
setInputElementNamein interfaceOutlet- Parameters:
inputElementName- the name of the root element of the source, or null to accept any input name.
-
getInputClass
Description copied from interface:OutletReturns the fully qualified name of the input root class. If not null, the outlet checks if the class name of the input root corresponds to the set class name and throws an exception if the names do not match.- Specified by:
getInputClassin interfaceOutlet- Returns:
- inputName the name of the root element of the source, or if any input name is accepted.
-
setInputClass
Description copied from interface:OutletSets the fully qualified name of the input model root class. If set, the outlet checks if the class name of the input model root corresponds to the set class name and throws an exception if the names do not match.- Specified by:
setInputClassin interfaceOutlet- Parameters:
inputClass- the name of the root element of the source, or null to accept any input name.
-
addMergepointMapping
Adds an mergepoint mapping to the outlet. No mergepoint mappings must exist with the given name.- Specified by:
addMergepointMappingin interfaceOutlet- Parameters:
mergepointMapping- the mergepointMapping to add, not null.- Throws:
NullPointerException- if mergepointMapping is null.ConfigurationException- if an mergepointMapping for the given name already exists.
-
setMergepointMapping
Sets an mergepoint mapping in the outlet. If a mergepoint mapping with the given name already exists, it is replaced.- Specified by:
setMergepointMappingin interfaceOutlet- Parameters:
mergepointMapping- the mergepointMapping to add, not null.- Returns:
- the replaced mergepoint mapping, not null.
- Throws:
NullPointerException- if mergepointMapping is null.
-
getMergepointMapping
Returns the mergepoint mapping for the given mergepoint name.- Specified by:
getMergepointMappingin interfaceOutlet- Parameters:
name- the name of the mergepoint mapping.- Returns:
- the mergepoint mapping for the given name, or null if no mergepoint mapping exists for this name.
-
getMergepointMappings
Description copied from interface:OutletReturns the map of all mergepoint mappings, keyed by their name.- Specified by:
getMergepointMappingsin interfaceOutlet- Returns:
- the map of mergepoint mappings, not null.
-
beforeExecute
Description copied from interface:OutletAdjusts the state of the Controller before generation.- Specified by:
beforeExecutein interfaceOutlet- Parameters:
controllerState- the current controller state, not null.- Throws:
GeneratorException- if adjusting the controller state fails.
-
afterExecute
Description copied from interface:OutletAdjusts the state of the Controller after generation.- Specified by:
afterExecutein interfaceOutlet- Parameters:
controllerState- the current controller state, not null.
-
execute
Description copied from interface:OutletGenerates the output for this template into the Generated object.- Specified by:
executein interfaceOutlet- Parameters:
controllerState- the current controller state, not null.- Returns:
- the output of the Outlet.
- Throws:
GeneratorException- if generation fails.
-
toString
-
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 this outlet. The scope of the variable is this outlet and its children.- Parameters:
key- the name of the variable, not nullvalue- the value of the variable, may be null.controllerState- the context of the controller, not null.- Throws:
NullPointerException- if key, scope or controllerState is null.IllegalArgumentException- if the key is no valid QualifiedName.
-
setVariable
public void setVariable(String key, Object value, Variable.Scope scope, ControllerState controllerState) Sets a variable. The key can be given with or without namespace; in the latter case, the variable is set in the namespace of this outlet.- Parameters:
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.controllerState- the context of the controller, not null.- Throws:
NullPointerException- if key or scope is null.IllegalArgumentException- if the key is no valid QualifiedName.
-
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 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.- Parameters:
key- the key for the variable to retrieve.controllerState- the context of the controller, not null.- Returns:
- the variable for the given key, or null if the variable is not set or explicitly set to null.
-
mergepoint
public String mergepoint(String mergepointName, ControllerState controllerState) throws GeneratorException Processes the mergepoint with the given name.- Parameters:
mergepointName- the name of the mergepoint.controllerState- the context of the controller, not null.- Returns:
- the output generated by the mergepoint.
- Throws:
GeneratorException- if the mergepoint could not be processed completely.
-