Class OutletImpl
- java.lang.Object
-
- org.apache.torque.generator.outlet.OutletImpl
-
- All Implemented Interfaces:
Outlet
- Direct Known Subclasses:
CopyOutlet,JavadocOutlet,JavaFilenameOutlet,ModifySourcenameOutlet,OutletWithoutMergepoints,TemplateOutletImpl
public abstract class OutletImpl extends Object implements Outlet
Implementation of the features in theOutletinterface which do not depend on type of Outlet.
-
-
Constructor Summary
Constructors Constructor Description OutletImpl(QualifiedName name)Constructs a OutletImpl with the given name.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddMergepointMapping(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.StringgetInputClass()Returns the fully qualified name of the input root class.StringgetInputElementName()Returns the name of the input root element.MergepointMappinggetMergepointMapping(String name)Returns the mergepoint mapping for the given mergepoint name.Map<String,MergepointMapping>getMergepointMappings()Returns the map of all mergepoint mappings, keyed by their name.QualifiedNamegetName()Returns the name of the outlet.ObjectgetVariable(String key, ControllerState controllerState)Returns the variable with the given key.Stringmergepoint(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.MergepointMappingsetMergepointMapping(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.StringtoString()
-
-
-
Constructor Detail
-
OutletImpl
public OutletImpl(QualifiedName name)
Constructs a OutletImpl with the given name.- Parameters:
name- the name of this outlet, not null.- Throws:
NullPointerException- if name is null.
-
-
Method Detail
-
getName
public QualifiedName 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
public String 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
public void setInputElementName(String inputElementName)
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
public String 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
public void setInputClass(String inputClass)
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
public void addMergepointMapping(MergepointMapping mergepointMapping) throws ConfigurationException
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
public MergepointMapping setMergepointMapping(MergepointMapping mergepointMapping)
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
public MergepointMapping getMergepointMapping(String name)
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
public Map<String,MergepointMapping> 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
public void beforeExecute(ControllerState controllerState) throws GeneratorException
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
public void afterExecute(ControllerState controllerState)
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
public abstract OutletResult execute(ControllerState controllerState) throws GeneratorException
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.
-
setVariable
public void setVariable(String key, Object value, 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. 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
public Object getVariable(String key, ControllerState controllerState)
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.
-
-