Package org.apache.torque.generator.outlet

## 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 the `Outlet` interface 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
    --- | --- | ---
    `void` | `addMergepointMapping​(MergepointMapping mergepointMapping)` | Adds an mergepoint mapping to the outlet.
    `void` | `afterExecute​(ControllerState controllerState)` | Adjusts the state of the Controller after generation.
    `void` | `beforeExecute​(ControllerState controllerState)` | Adjusts the state of the Controller before generation.
    `abstract OutletResult` | `execute​(ControllerState controllerState)` | Generates the output for this template into the Generated object.
    `String` | `getInputClass()` | Returns the fully qualified name of the input root class.
    `String` | `getInputElementName()` | Returns the name of the input root element.
    `MergepointMapping` | `getMergepointMapping​(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.
    `QualifiedName` | `getName()` | Returns the name of the outlet.
    `Object` | `getVariable​(String key, ControllerState controllerState)` | Returns the variable with the given key.
    `String` | `mergepoint​(String mergepointName, ControllerState controllerState)` | Processes the mergepoint with the given name.
    `void` | `setInputClass​(String inputClass)` | Sets the fully qualified name of the input model root class.
    `void` | `setInputElementName​(String inputElementName)` | Sets the name of the input root element.
    `MergepointMapping` | `setMergepointMapping​(MergepointMapping mergepointMapping)` | Sets an mergepoint mapping in the outlet.
    `void` | `setVariable​(String key, Object value, ControllerState controllerState)` | Sets a variable.
    `void` | `setVariable​(String key, Object value, Variable.Scope scope, ControllerState controllerState)` | Sets a variable.
    `String` | `toString()` |

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 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: `Outlet`
      Returns the name of the outlet. The namespace part of the name defines the default context of the outlet.
      Specified by:
        `getName` in interface `Outlet`
      Returns:
        the name of the outlet, not null.

    - #### getInputElementName

          public String getInputElementName()

      Description copied from interface: `Outlet`
      Returns 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:
        `getInputElementName` in interface `Outlet`
      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: `Outlet`
      Sets 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:
        `setInputElementName` in interface `Outlet`
      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: `Outlet`
      Returns 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:
        `getInputClass` in interface `Outlet`
      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: `Outlet`
      Sets 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:
        `setInputClass` in interface `Outlet`
      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:
        `addMergepointMapping` in interface `Outlet`
      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:
        `setMergepointMapping` in interface `Outlet`
      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:
        `getMergepointMapping` in interface `Outlet`
      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: `Outlet`
      Returns the map of all mergepoint mappings, keyed by their name.
      Specified by:
        `getMergepointMappings` in interface `Outlet`
      Returns:
        the map of mergepoint mappings, not null.

    - #### beforeExecute

          public void beforeExecute​(ControllerState controllerState)
                             throws GeneratorException

      Description copied from interface: `Outlet`
      Adjusts the state of the Controller before generation.
      Specified by:
        `beforeExecute` in interface `Outlet`
      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: `Outlet`
      Adjusts the state of the Controller after generation.
      Specified by:
        `afterExecute` in interface `Outlet`
      Parameters:
        `controllerState` - the current controller state, not null.

    - #### execute

          public abstract OutletResult execute​(ControllerState controllerState)
                                        throws GeneratorException

      Description copied from interface: `Outlet`
      Generates the output for this template into the Generated object.
      Specified by:
        `execute` in interface `Outlet`
      Parameters:
        `controllerState` - the current controller state, not null.
      Returns:
        the output of the Outlet.
      Throws:
        `GeneratorException` - if generation fails.

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### 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 null
        `value` - 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.