org.norther.tammi.spray.template.flow
Class DefaultFlowStep

java.lang.Object
  extended by org.norther.tammi.spray.template.flow.DefaultFlowStep
All Implemented Interfaces:
Serializable, Cloneable, FlowStep

public class DefaultFlowStep
extends Object
implements FlowStep, Cloneable, Serializable

A default implementation of FlowStep. This implementation keeps itself synchronized with the FlowFilterMBeean until locally modified.

Author:
Ilkka Priha
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.norther.tammi.spray.template.flow.FlowStep
CURRENT_FLOW_INDICATOR, FLOW_PATH_SEPARATOR, STEP_INDEX_SEPARATOR, STEP_PATH_SEPARATOR
 
Constructor Summary
DefaultFlowStep(String name)
          Constructs a named flow step.
DefaultFlowStep(String name, FlowStep flow)
          Constructs a named flow step with a flow.
 
Method Summary
 void addStateListener(StepStateListener listener)
          Adds a state listener of this flow step.
 void addStepName(int index, String name)
          Adds a named flow step.
 void addVariable(int index, Variable var)
          Adds a new variable at the specified index.
 void addVariable(Variable var)
          Adds a new variable.
 Object clone()
           
 boolean containsInvalidVariables()
          Returns true, if there are one or more invalid variables.
 void disposeFlows()
          Disposes flows of this flow step and their resources.
 void disposeSteps()
          Disposes steps of this flow step and their resources.
 String getAbsolutePath()
          Gets the absolute path to this flow step.
 List getActionNames()
          Gets the action names.
 FlowStep getFlow()
          Gets the flow of this flow step.
 int getIndex()
          Gets the index of this flow step.
 String getLabel()
          Gets the label.
 String getName()
          Gets the name of this flow step.
 String getPath()
          Gets the relative path to this flow step.
 String getProperty(int index)
          Gets the indexed property.
 StepMatrix getRouteMatrix()
          Gets the step route matrix.
 FlowStep getStep(int index)
          Gets the indexed flow step
 String getStepName(int index)
          Gets the name of the indexed flow step.
 List getStepNames()
          Gets the names of flow steps.
 String getStepPath(int index)
          Gets the relative path to the indexed flow step.
 String getTemplate()
          Gets the template.
 List getTemplatePaths()
          Gets the template paths.
 String getTransition(int index)
          Gets the indexed transition.
 Variable getVariable(int index)
          Gets the indexed variable.
 List getVariables()
          Gets the variables.
 List getVariableTypes()
          Gets the variable types.
 int indexOfStep(String name)
          Returns the index of the named flow step.
 boolean isHeritable()
          Checks whether heritable.
 boolean isInvalidVariable(int index)
          Checks the invalidity of the indexed variable.
 boolean isState(int index)
          Checks the indexed state.
 boolean isValidVariable(int index)
          Checks the validity of the indexed variable.
 boolean isValidVariables()
          Checks whether all variables are valid, i.e.
protected  void relocate()
          Relocates the step.
 void removeStateListener(StepStateListener listener)
          Removes a state listener of this flow step.
 void removeStep(int index)
          Removes the indexed flow step.
 void removeTemplate()
          Removes the template.
 void removeVariable(int index)
          Removes the indexed variable.
 void removeVariables()
          Removes all variables.
 Variable renewVariable(int index)
          Renews the indexed variable by replacing it with a fresh one.
 List renewVariables()
          Renews all variables by replacing them with fresh ones.
 void resetInvalidVariables()
          Resets invalid variables by marking them as not updated.
 void resetVariable(int index)
          Resets the indexed variable by marking it as not updated.
 void resetVariables()
          Resets all variables by marking them as not updated.
 void setActionNames(List tasks)
          Sets the action names.
protected  void setFlow(FlowStep flow)
          Sets the flow.
 void setHeritable(boolean flag)
          Sets whether heritable.
 void setLabel(String label)
          Sets the label.
 String setProperty(int index, String value)
          Sets the indexed property.
 void setRouteMatrix(StepMatrix matrix)
          Sets the step route matrix.
 boolean setState(int index, boolean flag)
          Sets the indexed state.
 void setStepName(int index, String name)
          Sets the named flow step.
 void setStepNames(List names)
          Sets the names of flow steps.
 void setTemplate(String path)
          Sets the template.
 void setTemplatePaths(List paths)
          Sets the template paths.
 String setTransition(int index, String value)
          Sets the indexed transition.
 void setValidVariable(int index, boolean flag)
          Sets the validity of the indexed variable.
 void setValidVariables(boolean flag)
          Sets the validity of all variables.
 void setVariable(int index, Variable var)
          Sets the indexed variable.
 void setVariables(List list)
          Sets the variables.
 void setVariableTypes(List types)
          Sets the variable types.
 void sortVariables(Comparator comparator)
          Sorts variables.
 int stepCount()
          Returns the number of steps.
 String toClassName()
          Converts the name of this flow to the corresponding class name.
 int variableCount()
          Returns the number of variables.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFlowStep

public DefaultFlowStep(String name)
Constructs a named flow step.

Parameters:
name - the flow step name.
Throws:
NullPointerException - for a null name.
IllegalArgumentException - for an invalid name.

DefaultFlowStep

public DefaultFlowStep(String name,
                       FlowStep flow)
Constructs a named flow step with a flow.

Parameters:
name - the flow step name.
flow - the flow.
Throws:
NullPointerException - for a null name.
IllegalArgumentException - for an invalid name.
Method Detail

clone

public Object clone()
Overrides:
clone in class Object

getName

public String getName()
Description copied from interface: FlowStep
Gets the name of this flow step.

Specified by:
getName in interface FlowStep
Returns:
the flow name.

getFlow

public FlowStep getFlow()
Description copied from interface: FlowStep
Gets the flow of this flow step.

Specified by:
getFlow in interface FlowStep
Returns:
the flow.

getIndex

public int getIndex()
Description copied from interface: FlowStep
Gets the index of this flow step.

Specified by:
getIndex in interface FlowStep
Returns:
the step index.

getPath

public String getPath()
Description copied from interface: FlowStep
Gets the relative path to this flow step.

Specified by:
getPath in interface FlowStep
Returns:
the relative step path.

getAbsolutePath

public String getAbsolutePath()
Description copied from interface: FlowStep
Gets the absolute path to this flow step.

Specified by:
getAbsolutePath in interface FlowStep
Returns:
the absolute step path.

isHeritable

public boolean isHeritable()
Description copied from interface: FlowStep
Checks whether heritable.

Specified by:
isHeritable in interface FlowStep
Returns:
true if heritable, false otherwise.

setHeritable

public void setHeritable(boolean flag)
Description copied from interface: FlowStep
Sets whether heritable.

Specified by:
setHeritable in interface FlowStep
Parameters:
flag - true if heritable, false otherwise.

getRouteMatrix

public StepMatrix getRouteMatrix()
Description copied from interface: FlowStep
Gets the step route matrix.

Specified by:
getRouteMatrix in interface FlowStep
Returns:
the step matrix.

setRouteMatrix

public void setRouteMatrix(StepMatrix matrix)
Description copied from interface: FlowStep
Sets the step route matrix.

Specified by:
setRouteMatrix in interface FlowStep
Parameters:
matrix - the step matrix.

getStep

public FlowStep getStep(int index)
Description copied from interface: FlowStep
Gets the indexed flow step

Specified by:
getStep in interface FlowStep
Parameters:
index - the index.
Returns:
the flow step.

removeStep

public void removeStep(int index)
Description copied from interface: FlowStep
Removes the indexed flow step.

Specified by:
removeStep in interface FlowStep
Parameters:
index - the index.

indexOfStep

public int indexOfStep(String name)
Description copied from interface: FlowStep
Returns the index of the named flow step.

Specified by:
indexOfStep in interface FlowStep
Parameters:
name - the flow step name.
Returns:
the index of the step or -1.

getStepName

public String getStepName(int index)
Description copied from interface: FlowStep
Gets the name of the indexed flow step.

Specified by:
getStepName in interface FlowStep
Parameters:
index - the index.
Returns:
the name of the flow step.

setStepName

public void setStepName(int index,
                        String name)
Description copied from interface: FlowStep
Sets the named flow step.

Specified by:
setStepName in interface FlowStep
Parameters:
index - the index.
name - the flow step name.

addStepName

public void addStepName(int index,
                        String name)
Description copied from interface: FlowStep
Adds a named flow step.

Specified by:
addStepName in interface FlowStep
Parameters:
index - the index.
name - the flow step name.

getStepNames

public List getStepNames()
Description copied from interface: FlowStep
Gets the names of flow steps.

Specified by:
getStepNames in interface FlowStep
Returns:
a read-only list of flow step names or null.

setStepNames

public void setStepNames(List names)
Description copied from interface: FlowStep
Sets the names of flow steps.

Specified by:
setStepNames in interface FlowStep
Parameters:
names - a list of flow step names.

getStepPath

public String getStepPath(int index)
Description copied from interface: FlowStep
Gets the relative path to the indexed flow step.

Specified by:
getStepPath in interface FlowStep
Parameters:
index - the index.
Returns:
the relative step path.

stepCount

public int stepCount()
Description copied from interface: FlowStep
Returns the number of steps.

Specified by:
stepCount in interface FlowStep
Returns:
the number of steps.

disposeSteps

public void disposeSteps()
Description copied from interface: FlowStep
Disposes steps of this flow step and their resources.

Specified by:
disposeSteps in interface FlowStep

disposeFlows

public void disposeFlows()
Description copied from interface: FlowStep
Disposes flows of this flow step and their resources.

Specified by:
disposeFlows in interface FlowStep

toClassName

public String toClassName()
Description copied from interface: FlowStep
Converts the name of this flow to the corresponding class name.

Specified by:
toClassName in interface FlowStep
Returns:
the flow name in the class name format.

getLabel

public String getLabel()
Description copied from interface: FlowStep
Gets the label.

Note that the name is returned if the label is not set.

Specified by:
getLabel in interface FlowStep
Returns:
the label.

setLabel

public void setLabel(String label)
Description copied from interface: FlowStep
Sets the label.

Specified by:
setLabel in interface FlowStep
Parameters:
label - the label.

getTemplatePaths

public List getTemplatePaths()
Description copied from interface: FlowStep
Gets the template paths.

Specified by:
getTemplatePaths in interface FlowStep
Returns:
a list of template paths or null.

setTemplatePaths

public void setTemplatePaths(List paths)
Description copied from interface: FlowStep
Sets the template paths.

Specified by:
setTemplatePaths in interface FlowStep
Parameters:
paths - a list of template paths.

getVariableTypes

public List getVariableTypes()
Description copied from interface: FlowStep
Gets the variable types.

Specified by:
getVariableTypes in interface FlowStep
Returns:
a list of variable types.

setVariableTypes

public void setVariableTypes(List types)
Description copied from interface: FlowStep
Sets the variable types.

Specified by:
setVariableTypes in interface FlowStep
Parameters:
types - a list of variable types or null.

getActionNames

public List getActionNames()
Description copied from interface: FlowStep
Gets the action names.

Specified by:
getActionNames in interface FlowStep
Returns:
a list of action names.

setActionNames

public void setActionNames(List tasks)
Description copied from interface: FlowStep
Sets the action names.

Specified by:
setActionNames in interface FlowStep
Parameters:
tasks - a list of action names or null.

isState

public boolean isState(int index)
Description copied from interface: FlowStep
Checks the indexed state.

Note that the index depends on the context of this flow step.

Specified by:
isState in interface FlowStep
Parameters:
index - the state index.
Returns:
true if set, false otherwise.

setState

public boolean setState(int index,
                        boolean flag)
Description copied from interface: FlowStep
Sets the indexed state.

Note that the index depends on the context of this flow step.

Specified by:
setState in interface FlowStep
Parameters:
index - the state index.
flag - true if set, false otherwise.
Returns:
the previous value of the state.

getProperty

public String getProperty(int index)
Description copied from interface: FlowStep
Gets the indexed property.

Note that the index depends on the context of this flow step.

Specified by:
getProperty in interface FlowStep
Parameters:
index - the property index.
Returns:
the value of the property or null.

setProperty

public String setProperty(int index,
                          String value)
Description copied from interface: FlowStep
Sets the indexed property.

Note that the index depends on the context of this flow step.

Specified by:
setProperty in interface FlowStep
Parameters:
index - the property index.
value - the value of the property.
Returns:
the previous value of the property.

getTransition

public String getTransition(int index)
Description copied from interface: FlowStep
Gets the indexed transition.

Note that the index depends on the context of this flow step.

Specified by:
getTransition in interface FlowStep
Parameters:
index - the state index.
Returns:
the value of the transition or null.

setTransition

public String setTransition(int index,
                            String value)
Description copied from interface: FlowStep
Sets the indexed transition.

Note that the index depends on the context of this flow step.

Specified by:
setTransition in interface FlowStep
Parameters:
index - the state index.
value - the value of the transition.
Returns:
the previous value of the transition.

addStateListener

public void addStateListener(StepStateListener listener)
Description copied from interface: FlowStep
Adds a state listener of this flow step.

Specified by:
addStateListener in interface FlowStep
Parameters:
listener - the listener.

removeStateListener

public void removeStateListener(StepStateListener listener)
Description copied from interface: FlowStep
Removes a state listener of this flow step.

Specified by:
removeStateListener in interface FlowStep
Parameters:
listener - the listener.

getTemplate

public String getTemplate()
Description copied from interface: FlowStep
Gets the template. The template is either the set one or the first one of the defined template paths.

Specified by:
getTemplate in interface FlowStep
Returns:
the template or null.

setTemplate

public void setTemplate(String path)
Description copied from interface: FlowStep
Sets the template. The template has precedence over the first one of the defined template paths, but doesn't replace it.

Specified by:
setTemplate in interface FlowStep
Parameters:
path - the template path.

removeTemplate

public void removeTemplate()
Description copied from interface: FlowStep
Removes the template. Only the set template is removed, not the defined template paths.

Specified by:
removeTemplate in interface FlowStep

getVariable

public Variable getVariable(int index)
                     throws ConstructionException
Description copied from interface: FlowStep
Gets the indexed variable.

Specified by:
getVariable in interface FlowStep
Parameters:
index - the index of the variable.
Returns:
the variable.
Throws:
ConstructionException - if construction fails.

setVariable

public void setVariable(int index,
                        Variable var)
                 throws ConstructionException
Description copied from interface: FlowStep
Sets the indexed variable.

Specified by:
setVariable in interface FlowStep
Parameters:
index - the index of the variable.
var - the variable.
Throws:
ConstructionException - if construction fails.

getVariables

public List getVariables()
                  throws ConstructionException
Description copied from interface: FlowStep
Gets the variables.

Specified by:
getVariables in interface FlowStep
Returns:
a read-only list of variables.
Throws:
ConstructionException - if construction fails.

setVariables

public void setVariables(List list)
Description copied from interface: FlowStep
Sets the variables.

Specified by:
setVariables in interface FlowStep
Parameters:
list - a list of variables.

addVariable

public void addVariable(Variable var)
                 throws ConstructionException
Description copied from interface: FlowStep
Adds a new variable.

Specified by:
addVariable in interface FlowStep
Parameters:
var - the variable.
Throws:
ConstructionException - if construction fails.

addVariable

public void addVariable(int index,
                        Variable var)
                 throws ConstructionException
Description copied from interface: FlowStep
Adds a new variable at the specified index.

Specified by:
addVariable in interface FlowStep
Parameters:
index - the index of the variable.
var - the variable.
Throws:
ConstructionException - if construction fails.

renewVariable

public Variable renewVariable(int index)
                       throws ConstructionException
Description copied from interface: FlowStep
Renews the indexed variable by replacing it with a fresh one.

Specified by:
renewVariable in interface FlowStep
Parameters:
index - the index of the variable.
Returns:
the variable.
Throws:
ConstructionException - if construction fails.

renewVariables

public List renewVariables()
                    throws ConstructionException
Description copied from interface: FlowStep
Renews all variables by replacing them with fresh ones.

Specified by:
renewVariables in interface FlowStep
Returns:
a read-only list of variable MBeans.
Throws:
ConstructionException - if construction fails.

removeVariable

public void removeVariable(int index)
                    throws ConstructionException
Description copied from interface: FlowStep
Removes the indexed variable.

Specified by:
removeVariable in interface FlowStep
Parameters:
index - the index of the variable.
Throws:
ConstructionException - if construction fails.

removeVariables

public void removeVariables()
                     throws ConstructionException
Description copied from interface: FlowStep
Removes all variables.

Specified by:
removeVariables in interface FlowStep
Throws:
ConstructionException - if construction fails.

sortVariables

public void sortVariables(Comparator comparator)
                   throws ConstructionException
Description copied from interface: FlowStep
Sorts variables.

Specified by:
sortVariables in interface FlowStep
Parameters:
comparator - the comparator to apply.
Throws:
ConstructionException - if construction fails.

variableCount

public int variableCount()
Description copied from interface: FlowStep
Returns the number of variables.

Specified by:
variableCount in interface FlowStep
Returns:
the number of variables.

isValidVariable

public boolean isValidVariable(int index)
Description copied from interface: FlowStep
Checks the validity of the indexed variable.

Specified by:
isValidVariable in interface FlowStep
Parameters:
index - the index of the variable.
Returns:
true if valid, false otherwise.

isInvalidVariable

public boolean isInvalidVariable(int index)
Description copied from interface: FlowStep
Checks the invalidity of the indexed variable.

Specified by:
isInvalidVariable in interface FlowStep
Parameters:
index - the index of the variable.
Returns:
true if invalid, false otherwise.

setValidVariable

public void setValidVariable(int index,
                             boolean flag)
Description copied from interface: FlowStep
Sets the validity of the indexed variable.

Specified by:
setValidVariable in interface FlowStep
Parameters:
index - the inded of the variable.
flag - true if valid, false otherwise.

isValidVariables

public boolean isValidVariables()
Description copied from interface: FlowStep
Checks whether all variables are valid, i.e. updated and not invalid.

Specified by:
isValidVariables in interface FlowStep
Returns:
true if valid, false otherwise.

setValidVariables

public void setValidVariables(boolean flag)
Description copied from interface: FlowStep
Sets the validity of all variables.

Specified by:
setValidVariables in interface FlowStep
Parameters:
flag - true if valid, false otherwise.

resetVariable

public void resetVariable(int index)
Description copied from interface: FlowStep
Resets the indexed variable by marking it as not updated.

Specified by:
resetVariable in interface FlowStep
Parameters:
index - the index of the variable.

resetVariables

public void resetVariables()
Description copied from interface: FlowStep
Resets all variables by marking them as not updated.

Specified by:
resetVariables in interface FlowStep

containsInvalidVariables

public boolean containsInvalidVariables()
Description copied from interface: FlowStep
Returns true, if there are one or more invalid variables.

Specified by:
containsInvalidVariables in interface FlowStep
Returns:
true if invalid, false otherwise.

resetInvalidVariables

public void resetInvalidVariables()
Description copied from interface: FlowStep
Resets invalid variables by marking them as not updated.

Specified by:
resetInvalidVariables in interface FlowStep

setFlow

protected void setFlow(FlowStep flow)
Sets the flow.

Parameters:
flow - the flow.

relocate

protected void relocate()
Relocates the step.



Copyright © 2004 The Norther Organization. All rights reserved.