de.matthias_burbach.flux
Class AbstractActionMappingGenerator

java.lang.Object
  extended byde.matthias_burbach.flux.AbstractActionMappingGenerator
All Implemented Interfaces:
ActionMappingGenerator
Direct Known Subclasses:
ActionActionMappingGenerator, FinalStateActionMappingGenerator, ModuleActionMappingGenerator, NonModelledActionMappingGenerator, PageActionMappingGenerator, PageEventActionMappingGenerator, PagePreProcessActionMappingGenerator

public abstract class AbstractActionMappingGenerator
extends java.lang.Object
implements ActionMappingGenerator

Abstract base class for ActionMappingGenerator implementations that provides commonly used functionality.

Author:
Matthias Burbach

Field Summary
protected  java.util.Properties settings
          The global settings that are used to control the generation process
 
Constructor Summary
AbstractActionMappingGenerator()
           
 
Method Summary
 void begin(StateMachine stateMachine, org.jdom.Document oldDocument, org.jdom.Element oldActionMappingsElement, org.jdom.Document newDocument, org.jdom.Element newActionMappingsElement)
          Is an empty default implementation.
 void end(StateMachine stateMachine, org.jdom.Document oldDocument, org.jdom.Element oldActionMappingsElement, org.jdom.Document newDocument, org.jdom.Element newActionMappingsElement)
          Is an empty default implementation.
 void generate(StateMachine stateMachine, State state, org.jdom.Document oldDocument, org.jdom.Element oldActionMappingsElement, org.jdom.Document newDocument, org.jdom.Element newActionMappingsElement)
          Is an empty default implementation.
protected  void generateForward(java.lang.String forwardName, java.lang.String forwardPath, org.jdom.Document document, org.jdom.Element oldActionMappingElement, org.jdom.Element newActionMappingElement)
          Calls generateForward( String forwardName, String forwardPath, Document document, Element oldActionMappingElement, Element newActionMappingElement, List additionalAttributes) adding null as last parameter.
protected  void generateForward(java.lang.String forwardName, java.lang.String forwardPath, org.jdom.Document document, org.jdom.Element oldActionMappingElement, org.jdom.Element newActionMappingElement, java.util.List additionalAttributes)
          Generates a single <forward> element and adds it to newActionMappingElement.
protected  void generateForwards(State state, org.jdom.Document newDocument, org.jdom.Element newActionMappingElement, org.jdom.Element oldActionMappingElement)
          Generates all forward elements for the newActionMappingElement from the outbound transitions of the state.
protected  void generateProperty(java.lang.String propertyName, java.lang.String propertyValue, org.jdom.Document document, org.jdom.Element actionMappingElement)
          Generates a <set-property> element and adds it to the actionMappingElement.
protected  org.jdom.Element getActionMappingElementForPath(org.jdom.Element actionMappingsElement, java.lang.String path)
          Selects the <action> element with the given path from the actionMappingsElement.
protected  java.lang.String getBasePath(State state)
           
protected  java.lang.String getBasePathExtension(State state)
          The base path extension may suffix the base path to make a full path of an <action> or <forward> element.
protected  java.lang.String getDefaultName()
           
protected  java.lang.String getDefaultPackage()
           
protected  java.lang.String getDefaultType(State state)
           
protected  org.jdom.Element getForwardElementForName(org.jdom.Element actionMappingElement, java.lang.String name)
          Selects the <forward> element with the given name from the actionMappingElement.
protected  java.lang.String getForwardPath(java.lang.String forwardName, State targetState, java.lang.String parameters)
          Constructs a forward path which mainly depends on the target state's stereotype.
protected  java.lang.String getForwardPathPrefix()
           
protected  java.lang.String getForwardPathSuffix()
           
protected  java.lang.String getNamePartOfBasePath(State state)
           
 void setSettings(java.util.Properties settings)
          Is called at the beginning of the generation before any other method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

settings

protected java.util.Properties settings
The global settings that are used to control the generation process

Constructor Detail

AbstractActionMappingGenerator

public AbstractActionMappingGenerator()
Method Detail

setSettings

public void setSettings(java.util.Properties settings)
Description copied from interface: ActionMappingGenerator
Is called at the beginning of the generation before any other method.

Specified by:
setSettings in interface ActionMappingGenerator
Parameters:
settings - holds simple properties that can be used by the generator to control the generation

begin

public void begin(StateMachine stateMachine,
                  org.jdom.Document oldDocument,
                  org.jdom.Element oldActionMappingsElement,
                  org.jdom.Document newDocument,
                  org.jdom.Element newActionMappingsElement)
           throws java.lang.Exception
Is an empty default implementation.

Specified by:
begin in interface ActionMappingGenerator
Parameters:
stateMachine - the UML state machine to generate from
oldDocument - the previously generated version of the complete XML output
oldActionMappingsElement - the previously generated version of the <action-mappings> element
newDocument - the XML output being under construction
newActionMappingsElement - the <action-mappings> element being under construction and to add children to
Throws:
java.lang.Exception - if anything goes unexpectedly wrong, will cancel the generation process

generate

public void generate(StateMachine stateMachine,
                     State state,
                     org.jdom.Document oldDocument,
                     org.jdom.Element oldActionMappingsElement,
                     org.jdom.Document newDocument,
                     org.jdom.Element newActionMappingsElement)
              throws java.lang.Exception
Is an empty default implementation.

Specified by:
generate in interface ActionMappingGenerator
Parameters:
stateMachine - the UML state machine to generate from
state - the current UML state to generate from
oldDocument - the previously generated version of the complete XML output
oldActionMappingsElement - the previously generated version of the <action-mappings> element
newDocument - the XML output being under construction
newActionMappingsElement - the <action-mappings> element being under construction and to add children to
Throws:
java.lang.Exception - if anything goes unexpectedly wrong, will cancel the generation process

end

public void end(StateMachine stateMachine,
                org.jdom.Document oldDocument,
                org.jdom.Element oldActionMappingsElement,
                org.jdom.Document newDocument,
                org.jdom.Element newActionMappingsElement)
         throws java.lang.Exception
Is an empty default implementation.

Specified by:
end in interface ActionMappingGenerator
Parameters:
stateMachine - the UML state machine to generate from
oldDocument - the previously generated version of the complete XML output
oldActionMappingsElement - the previously generated version of the <action-mappings> element
newDocument - the XML output being under construction
newActionMappingsElement - the <action-mappings> element being under construction and to add children to
Throws:
java.lang.Exception - if anything goes unexpectedly wrong, will cancel the generation process

getDefaultType

protected java.lang.String getDefaultType(State state)
Parameters:
state - the state the default Java type is to be derived from
Returns:
the default fully qualified Java class name derived from the the default package and the state's name and stereotype

getDefaultName

protected java.lang.String getDefaultName()
Returns:
the default form name if specified as settings property 'DefaultForm' or null if not specified

getDefaultPackage

protected java.lang.String getDefaultPackage()
Returns:
the default Java package name as defined by the the settings property 'DefaultPackage'

generateForwards

protected void generateForwards(State state,
                                org.jdom.Document newDocument,
                                org.jdom.Element newActionMappingElement,
                                org.jdom.Element oldActionMappingElement)
                         throws java.lang.Exception
Generates all forward elements for the newActionMappingElement from the outbound transitions of the state. The transitions' labels (event names or guard conditions) become the forwards' names.

Parameters:
state - the state whose transitions are transformed into forwards
newDocument - the struts-config document being generated
newActionMappingElement - the <action-mappings> element the forwards will be added to
oldActionMappingElement - the previously generated version of the <action-mappings> element
Throws:
java.lang.Exception - if anything goes unexpectedly wrong

generateForward

protected void generateForward(java.lang.String forwardName,
                               java.lang.String forwardPath,
                               org.jdom.Document document,
                               org.jdom.Element oldActionMappingElement,
                               org.jdom.Element newActionMappingElement)
                        throws java.lang.Exception
Calls generateForward( String forwardName, String forwardPath, Document document, Element oldActionMappingElement, Element newActionMappingElement, List additionalAttributes) adding null as last parameter.

Throws:
java.lang.Exception

generateForward

protected void generateForward(java.lang.String forwardName,
                               java.lang.String forwardPath,
                               org.jdom.Document document,
                               org.jdom.Element oldActionMappingElement,
                               org.jdom.Element newActionMappingElement,
                               java.util.List additionalAttributes)
                        throws java.lang.Exception
Generates a single <forward> element and adds it to newActionMappingElement.

Parameters:
forwardName - the name of the forward to be generated
forwardPath - the path of the forward to be generated if not taken from the previous version of the <action-mappings> element
document - the struts-config document being generated
oldActionMappingElement - the previous version of the <action-mappings> element
newActionMappingElement - the element the forward is to be added to
Throws:
java.lang.Exception - if anything goes unexpectedly wrong

getBasePath

protected java.lang.String getBasePath(State state)
Parameters:
state - the state the base path is to be derived from
Returns:
the base path derived from the state's stereotype and name, follows the pattern '/Stereotype.Name' (the '.Name' part is left out for the final state)

getNamePartOfBasePath

protected java.lang.String getNamePartOfBasePath(State state)
Parameters:
state - the state the name part of the base path is to be derived from
Returns:
either '' or the '.'-prepended name of the state

getBasePathExtension

protected java.lang.String getBasePathExtension(State state)
The base path extension may suffix the base path to make a full path of an <action> or <forward> element.

Parameters:
state - the state the extension is to be derived from
Returns:
the default base path extension ('.enter' for modules, '.display' for pages and '' else)

getForwardPath

protected java.lang.String getForwardPath(java.lang.String forwardName,
                                          State targetState,
                                          java.lang.String parameters)
                                   throws java.lang.Exception
Constructs a forward path which mainly depends on the target state's stereotype.

Parameters:
forwardName - the name of the forward the path is used for
targetState - the target state the path is to be derived from
parameters - optional parameter(s) that will be attached after "?", must not be preceded by "?" or "&", must be separated by "&" if multi-valued
Returns:
the forward path
Throws:
java.lang.Exception - if anything goes unexpectedly wrong

getForwardPathPrefix

protected java.lang.String getForwardPathPrefix()
Returns:
the forward path prefix (could be '' or '/do/', e.g.)

getForwardPathSuffix

protected java.lang.String getForwardPathSuffix()
Returns:
the forward path suffix (could be '' or '.do', e.g.)

getForwardElementForName

protected org.jdom.Element getForwardElementForName(org.jdom.Element actionMappingElement,
                                                    java.lang.String name)
                                             throws java.lang.Exception
Selects the <forward> element with the given name from the actionMappingElement.

Parameters:
actionMappingElement - the element to select the child forward from
name - the name of the <forward> element to be selected
Returns:
the selected <forward> element
Throws:
java.lang.Exception - if anything goes unexpectedly wrong

getActionMappingElementForPath

protected org.jdom.Element getActionMappingElementForPath(org.jdom.Element actionMappingsElement,
                                                          java.lang.String path)
                                                   throws java.lang.Exception
Selects the <action> element with the given path from the actionMappingsElement.

Parameters:
actionMappingsElement - the element to select the child action from
path - the path of the <action> element to be selected
Returns:
the selected <forward> element
Throws:
java.lang.Exception - if anything goes unexpectedly wrong

generateProperty

protected void generateProperty(java.lang.String propertyName,
                                java.lang.String propertyValue,
                                org.jdom.Document document,
                                org.jdom.Element actionMappingElement)
Generates a <set-property> element and adds it to the actionMappingElement.

Parameters:
propertyName - the value of the property attribute
propertyValue - the value of the value attribute
document - the struts-config document being generated
actionMappingElement - the <action> element the property is to be added to