Package org.apache.torque.generator.control

# Class ControllerState

java.lang.Object
org.apache.torque.generator.control.ControllerState

public class ControllerState extends Object
The state of the controller. Contains all stuff the controller needs to track. Initialization steps in `Controller.run(List)`:

1. First `unitConfiguration` `UnitConfiguration` is set in `Controller.processGenerationUnit(ControllerState, UnitConfiguration)`
2. Second `output` `Output` and `sourceProvider` `SourceProvider` is set and reset in private method processOutput of `Controller`.
3. Third `sourceFile`, `modelRoot` and `model` is set in private method processSourceInOutput of `Controller`.
4. Fourth `outputFile`, `outletNamespace`, `rootOutletReference` is set in private method processModel of `Controller` .

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ControllerState()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `getBooleanOption(String name)`
  Convenience method to return the value of an option as boolean.
  `boolean`
  `getBooleanOption(OptionName optionName)`
  Convenience method to return the value of an option as boolean.
  `Checksums`
  `getLastGeneratedSourceChecksums()`
  Returns the checksums of the source files for the last generation run.
  `Object`
  `getModel()`
  Returns the current model object within the source.
  `Object`
  `getModelRoot()`
  Returns the root object of the current source.
  `Object`
  `getOption(String name)`
  Calculates the value of an option in the current outlet's context.
  `Object`
  `getOption(OptionName optionName)`
  Calculates the value of an option in the current outlet's context.
  `Outlet`
  `getOutlet()`
  Returns the topmost outlet in the stack of outlets.
  `Namespace`
  `getOutletNamespace()`
  Returns the namespace of the outlet which is currently active.
  `Output`
  `getOutput()`
  Returns the output declaration which is currently processed.
  `File`
  `getOutputFile()`
  Returns the currently generated file.
  `String`
  `getPathToModel()`
  Returns the path from the model root to the current model.
  `QualifiedName`
  `getQualifiedName(String name)`
  Converts a name to a QualifiedName, using the outlet namespace as default namespace is none is given.
  `OutletReference`
  `getRootOutletReference()`
  Returns the reference to the current outlet.
  `File`
  `getSourceFile()`
  Returns the currently used source file.
  `SourceProvider`
  `getSourceProvider()`
  Returns the source provider which is currently in use.
  `String`
  `getStringOption(String name)`
  Convenience method to return the value of an option as String.
  `String`
  `getStringOption(OptionName optionName)`
  Convenience method to return the value of an option as String.
  `Checksums`
  `getThisGenerationSourceChecksums()`
  Returns the checksums of the source files for this generation run.
  `UnitConfiguration`
  `getUnitConfiguration()`
  Returns the configuration of the currently processed generation unit.
  `VariableStore`
  `getVariableStore()`
  Returns the VariableStore where generation variables can be set.
  `Options`
  `getVisibleOptions()`
  Returns all options which are visible from the current outlet's namespace.
  `Outlet`
  `popOutlet()`
  Pops the topmost outlets from the stack of outlets.
  `void`
  `pushOutlet(Outlet outlet)`
  Pushes a outlet onto the stack of outlets.
  `void`
  `setModel(Object model, String newPathToModel)`
  Sets the current source model object.
  `void`
  `setModelRoot(Object modelRoot)`
  Sets the root object of the current source.
  `void`
  `setPathToModel(String pathToModel)`
  Sets the path from the model root to the current model.
  `void`
  `setSourceFile(File sourceFile)`
  Sets the currently used source file.
  `void`
  `setSourceProvider(SourceProvider sourceProvider)`
  Sets the source provider which is currently in use.
  `void`
  `setUnitConfiguration(UnitConfiguration unitConfiguration)`
  Sets the configuration of the currently processed generation unit.
  `String`
  `toString()`

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

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

- ## Constructor Details

  - ### ControllerState

    public ControllerState()

- ## Method Details

  - ### getSourceProvider

    public SourceProvider getSourceProvider()
    Returns the source provider which is currently in use.
    Returns:
      the current source provider.

  - ### setSourceProvider

    public void setSourceProvider(SourceProvider sourceProvider)
    Sets the source provider which is currently in use.
    Parameters:
      `sourceProvider` - the current source provider.

  - ### getOutput

    public Output getOutput()
    Returns the output declaration which is currently processed.
    Returns:
      the output declaration which is currently processed, may be null only if no output is processed at the moment.

  - ### getOutlet

    public Outlet getOutlet()
    Returns the topmost outlet in the stack of outlets.
    Returns:
      the topmost outlet in the stack of outlets, or null if the stack is empty.

  - ### pushOutlet

    public void pushOutlet(Outlet outlet)
    Pushes a outlet onto the stack of outlets.
    Parameters:
      `outlet` - the outlet to be added to the stack of outlets, not null.

  - ### popOutlet

    public Outlet popOutlet()
    Pops the topmost outlets from the stack of outlets.
    Returns:
      the removed outlet, not null.
    Throws:
      `IndexOutOfBoundsException` - if the stack is empty.

  - ### getModel

    public Object getModel()
    Returns the current model object within the source. Does not return null during generation.
    Returns:
      the current model object.

  - ### setModel

    public void setModel(Object model, String newPathToModel)
    Sets the current source model object.
    Parameters:
      `model` - the new current source model object, or null to remove the current source model object.
      `newPathToModel` - the path from root to the new model, or null to leave the path unchanged.

  - ### getPathToModel

    public String getPathToModel()
    Returns the path from the model root to the current model.
    Returns:
      the path from the model root to the current model, not null.

  - ### setPathToModel

    public void setPathToModel(String pathToModel)
    Sets the path from the model root to the current model.
    Parameters:
      `pathToModel` - the path from the model root to the current model, not null.

  - ### getModelRoot

    public Object getModelRoot()
    Returns the root object of the current source.
    Returns:
      The the root object of the current source; may be null only if no source is currently processed.

  - ### setModelRoot

    public void setModelRoot(Object modelRoot)
    Sets the root object of the current source.
    Parameters:
      `modelRoot` - the the root object of the current source, or null to remove the current root object.

  - ### getRootOutletReference

    public OutletReference getRootOutletReference()
    Returns the reference to the current outlet.
    Returns:
      the reference to the current outlet, or null if no outlet is currently active.

  - ### getOutletNamespace

    public Namespace getOutletNamespace()
    Returns the namespace of the outlet which is currently active.
    Returns:
      the name space of the active outlet. May be null only if no generation is in progress.

  - ### getOption

    public Object getOption(String name)
    Calculates the value of an option in the current outlet's context. The default namespace which is used when no namespace is given in `name` is the namespace of the currently used outlet.
    Parameters:
      `name` - the name of the option, can contain a namespace.
    Returns:
      The value of the option, or null if no option with that name is visible from the given namespace.

  - ### getOption

    public Object getOption(OptionName optionName)
    Calculates the value of an option in the current outlet's context. The default namespace which is used when no namespace is given in `name` is the namespace of the currently used outlet.
    Parameters:
      `optionName` - the object containing the name of the option, which can contain a namespace, not null.
    Returns:
      The value of the option, or null if no option with that name is visible from the given namespace.
    Throws:
      `NullPointerException` - if optionName is null.

  - ### getBooleanOption

    public boolean getBooleanOption(String name)
    Convenience method to return the value of an option as boolean. The option is evaluated in the current outlet's context, see getOption(String).

    Uses Boolean.paseBoolean() for String -> Boolean conversion.

    Parameters:
      `name` - the name of the option, can contain a namespace.
    Returns:
      The value of the option as boolean, or false if no option with that name is visible from the given namespace,

  - ### getBooleanOption

    public boolean getBooleanOption(OptionName optionName)
    Convenience method to return the value of an option as boolean. The option is evaluated in the current outlet's context, see getOption(String).

    Uses Boolean.paseBoolean() for String -> Boolean conversion.

    Parameters:
      `optionName` - the object containing the name of the option, which can contain a namespace.
    Returns:
      The value of the option as boolean, or false if no option with that name is visible from the given namespace.
    Throws:
      `NullPointerException` - if optionName is null.

  - ### getStringOption

    public String getStringOption(String name)
    Convenience method to return the value of an option as String. The option is evaluated in the current outlet's context, see getOption(String).
    Parameters:
      `name` - the name of the option, can contain a namespace.
    Returns:
      The value of the option as boolean, or false if no option with that name is visible from the given namespace,

  - ### getStringOption

    public String getStringOption(OptionName optionName)
    Convenience method to return the value of an option as String. The option is evaluated in the current outlet's context, see getOption(String).
    Parameters:
      `optionName` - the object containing the name of the option, which can contain a namespace.
    Returns:
      The value of the option as String, or null if no option with that name is visible from the given namespace,
    Throws:
      `NullPointerException` - if optionName is null.

  - ### getVisibleOptions

    public Options getVisibleOptions()
    Returns all options which are visible from the current outlet's namespace.
    Returns:
      all visible options, not null.

  - ### getVariableStore

    public VariableStore getVariableStore()
    Returns the VariableStore where generation variables can be set.
    Returns:
      the variableStore, never null.

  - ### getQualifiedName

    public QualifiedName getQualifiedName(String name)
    Converts a name to a QualifiedName, using the outlet namespace as default namespace is none is given.
    Parameters:
      `name` - the name to convert to a qualifiedName, not null.
    Returns:
      the corresponding qualifiedName.
    Throws:
      `NullPointerException` - if name is null
      `IllegalArgumentException` - if name is no valid qualifiedName.

  - ### getOutputFile

    public File getOutputFile()
    Returns the currently generated file.
    Returns:
      the current output file. May only be null if no output file is currently generated (e.g. if the file name is currently generated).

  - ### getSourceFile

    public File getSourceFile()
    Returns the currently used source file.
    Returns:
      the current source file. May be null if no source file is currently used (e.g. if the source is created by other means than reading a file).

  - ### setSourceFile

    public void setSourceFile(File sourceFile)
    Sets the currently used source file.
    Parameters:
      `sourceFile` - the current source file, or null to remove the source file.

  - ### getUnitConfiguration

    public UnitConfiguration getUnitConfiguration()
    Returns the configuration of the currently processed generation unit.
    Returns:
      the configuration of the currently processed generation unit.

  - ### setUnitConfiguration

    public void setUnitConfiguration(UnitConfiguration unitConfiguration)
    Sets the configuration of the currently processed generation unit.
    Parameters:
      `unitConfiguration` - the configuration of the currently processed generation unit.

  - ### getLastGeneratedSourceChecksums

    public Checksums getLastGeneratedSourceChecksums()
    Returns the checksums of the source files for the last generation run.
    Returns:
      the checksums, not null.

  - ### getThisGenerationSourceChecksums

    public Checksums getThisGenerationSourceChecksums()
    Returns the checksums of the source files for this generation run.
    Returns:
      the checksums, not null.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`