org.norther.tammi.spray.template.tool
Class FlowTool

java.lang.Object
  extended by org.norther.tammi.core.pool.RecyclableSupport
      extended by org.norther.tammi.core.pool.PoolableSupport
          extended by org.norther.tammi.spray.engine.tool.GlobalTool
              extended by org.norther.tammi.spray.engine.tool.ContextTool
                  extended by org.norther.tammi.spray.template.tool.FlowTool
All Implemented Interfaces:
Serializable, Cloneable, EventListener, Interruptable, Poolable, Recyclable, ContextBindingListener, StepFlowContext

public class FlowTool
extends ContextTool
implements StepFlowContext

A request context tool for controlling flows.

Version:
$Id: FlowTool.java,v 1.63 2010-08-16 15:45:02 cvsimp Exp $
Author:
Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.norther.tammi.spray.template.flow.StepFlowContext
StepFlowContext.ActionPhase
 
Field Summary
 
Fields inherited from interface org.norther.tammi.spray.template.flow.StepFlowContext
CURRENT_FLOW_INDICATOR
 
Constructor Summary
FlowTool()
          Constructs a new flow tool.
 
Method Summary
 FlowStep activateSelection()
          Activates the selection.
 Set<Object> attributeKeySet()
          Returns a set of context attribute keys.
 void cancelSelection()
          Cancels the the current selection.
 boolean chainErrors()
          Chains step flow and filter chain errors to the filter chain.
 boolean checkPermission(FlowStep flow, int index, String actions)
          Checks access permission for the indexed step in the specified flow.
 boolean checkPermission(int index, String actions)
          Checks access permission for the indexed step in the current flow.
 boolean checkPermission(String actions)
          Checks access permission for the current step.
 void clearAttributes()
          Clears all context attributes.
 void clearErrors()
          Clears throwables from the error stack.
 void clearSelection()
          Clears the current selection.
 boolean clearState(FlowStep step, Object state)
          Clears the state of the specified step.
 boolean clearState(Object state)
          Clears the state of the current step.
 boolean containsAttribute(Object key)
          Checks a context attribute.
 boolean containsErrors()
          Checks whether the erro stack contains errors.
 boolean containsValidity(String validity)
          Returns true if the specified form validity is present in the current step.
 void defaultSelection()
          Clears and resets the selection to the default one.
 void dispose()
          Disposes the object by setting its disposed flag.
 boolean equalsValidity(String validity)
          Returns true if the specified form validity equals validities of the current step.
 boolean exists(String name)
          Checks whether the specified step or flow exists.
 void finishSelection(ServletRequest request, ServletResponse response, FilterChain chain)
          Finishes a new selection.
 StepFlowContext.ActionPhase getActionPhase()
          Gets the action phase.
 Object getAttribute(Object key)
          Gets a context attribute.
 Object getAttribute(Object key, Object defaultValue)
          Gets a context attribute with a default value.
 Object getAttribute(String name, String key, Object defaultValue)
          Gets a mapped attribute.
protected  StepFlowContext getCurrentContext()
          Gets the current step flow context.
 String getDefaultFlowName()
          Gets the default flow name.
 String getDefaultLabel()
          Gets the default label.
 List<Throwable> getErrors()
          Gets a list of all throwables in the error stack.
 FlowStep getFlow()
          Gets the current flow.
 FlowFilter getFlowFilter()
          Gets the flow filter of this context if available.
 String getFlowLabel()
          Gets the label of the current flow.
 String getFlowLabel(String name)
          Gets the label of the named flow.
 String getFlowName(String path)
          Gets the flow part of the flow step path.
 List<FlowStep> getFlows()
          Gets the current flow path as a list.
protected  FormFilter getFormFilter()
          Gets the form filter from the filter stack.
 int[] getFormIndex(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the form index of the specified request.
 String getFormName(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the form name of the specified request.
 List<KeyValue<String,Variable>> getFormVariables(FlowStep step, ServletRequest request, ServletResponse response, FilterChain chain)
          Gets a list of flow step form variables of the specified request.
 int getNextIndex()
          Gets the index of the next step or 0 if not available.
 int getPreviousIndex()
          Gets the index of the previous step or 0 if not available.
 Object getProperty(FlowStep step, Object property, boolean... local)
          Gets the property of the specified step.
 Object getProperty(Object property, boolean... local)
          Gets the property of the current step.
 String getQualifiedName()
          Gets the qualified name of the current step.
 String getQualifiedName(String name)
          Gets the qualified name of the named step of the current flow.
 String getQualifiedName(String[] names)
          Gets the qualified name of the named steps of the current flow.
 long getReservationTime()
          Gets the last reservation time.
protected  ResourceFilter getResourceFilter()
          Gets the resource filter from the filter stack.
 FlowStep getRoot()
          Gets the root flow.
protected  SecuredFilter getSecuredFilter()
          Gets the secured filter from the filter stack.
 String getSelectedAttribute()
          Gets the name of the selected attribute with an optional form prefix.
 String getSelectedFlowName()
          Gets the selected flow name.
 String getSelectedParameter(int index)
          Gets the selected parameter.
 int getSelectedParameterCount()
          Gets the number of selected parameters.
 int getSelectedStepIndex()
          Gets the index of the selected step.
 String getSelectedStepPath()
          Gets the selected step path.
 String getSelectedTemplatePath()
          Gets the selected template path.
 Variable getSelectedVariable()
          Gets the selected variable.
 FlowStep getStep()
          Gets the current step.
 FlowStep getStep(int offset)
          Gets the step relative to the current one or null if not available.
 int getStepIndex(int offset)
          Gets the index of the step relative to the current one or 0 if not available.
 int getStepIndex(String path)
          Gets the index part of the flow step path.
 String getStepLabel()
          Gets the label of the current step.
 String getStepPath(String name, int index)
          Gets the path to the indexed step of the named flow.
 String getTemplate()
          Gets the template of the current step.
 String getTemplate(int ind)
          Gets the indexed template of the current step.
 TemplateContext getTemplateContext(ServletRequest request, ServletResponse response, FilterChain chain)
          Gets the template context of the specified request.
 List<String> getTemplates()
          Gets the templates of the current step.
 Object getTransition(FlowStep step, Object state, boolean... local)
          Gets the transition of the specified step.
 Object getTransition(Object state, boolean... local)
          Gets the transition of the current step.
 String[] getValidities()
          Gets the validities of the variables of the current step.
 String getValidity(int index)
          Gets the validity of the indexed variable of the current step.
 Variable getVariable()
          Gets the variable of the current step.
 Variable getVariable(int ind)
          Gets the indexed variable of the current step.
 List<Variable> getVariables()
          Gets the variables of the current step.
 boolean isCurrentIndex(int index)
          Checks whether the indexed step is the current one.
 boolean isFlowEnabled(FlowStep flow)
          Checks whether the specified flow is enabled.
 boolean isFormValidated()
          Checks whether the form variables of the current step are validated.
 boolean isInterrupted()
          Checks whether interrupted.
 boolean isLocalized()
          Checks whether the current step is localized.
 boolean isNewSelection()
          Checks whether a new selection is set.
 boolean isObsolete()
          Checks whether this tool is obsolete.
 boolean isOnlyWrite()
          Checks the only-write state of the current step.
 boolean isReadOnly()
          Checks the read-only state of the current step.
 boolean isReserved()
          Checks whether this context is reserved by some other thread than the current one.
 boolean isRestrictedRoutes()
          Checks whether step routes are restricted by a route matrix.
 boolean isRoot()
          Checks whether the current step is the root.
 boolean isSecure()
          Checks whether the current step requires a secured connection.
 boolean isSecure(FlowStep step)
          Checks whether the specified step requires a secured connection.
 boolean isState(FlowStep step, Object state, boolean... local)
          Checks the state of the specified step.
 boolean isState(Object state, boolean... local)
          Checks the state of the current step.
 boolean isStepEnabled(FlowStep step, FlowStep flow, int index)
          Checks whether the route from the specified step to the indexed one in the specified flow is enabled.
 boolean isStepEnabled(FlowStep flow, int index)
          Checks whether the route from the current step to the indexed one in the specified flow is enabled.
 boolean isValid()
          Checks whether this context is valid.
 boolean isValidated()
          Checks whether the current step has validated variables.
 boolean isWriteEven()
          Checks the write-even state of the current step.
 boolean joinErrors()
          Joins filter chain and step flow errors to the step flow.
 Throwable popError()
          Pops a throwable from the error stack.
 FlowStep prepareSelection(ServletRequest request, ServletResponse response, FilterChain chain)
          Prepares a new selection.
 void pushError(Throwable error)
          Pushes a throwable to the error stack without throwing one.
 void release()
          Releases this context after state changes.
 void removeAttribute(Object key)
          Removes a context attribute.
 boolean removeAttribute(Object key, Object value)
          Removes a context attribute with the specidied value.
 Object removeProperty(FlowStep step, Object property)
          Removes the property of the specified step.
 Object removeProperty(Object property)
          Removes the property of the current step.
 Object removeTransition(FlowStep step, Object state)
          Removes the transition of the specified step.
 Object removeTransition(Object state)
          Removes the transition of the current step.
 void renewFormVariables(FlowStep step, ServletRequest request, ServletResponse response, FilterChain chain)
          Renews flow step form variables of the specified request by creating a new instance of each variable.
 void reserve(long t)
          Reserves this context for state changes at the specified time unless stale or interrupted.
 void resetFormVariables(FlowStep step, ServletRequest request, ServletResponse response, FilterChain chain)
          Resets flow step form variables of the specified request by setting the form validities back to initial.
 void resetSelection()
          Clears and resets the selection to the previous one.
 void resetValidities(String validity)
          Resets the validity of all variables of the current step unless rejected.
 String resolve(String key)
          Resolves a string resource from the flow specific bundle.
 void reuseFormVariables(FlowStep step, ServletRequest request, ServletResponse response, FilterChain chain)
          Reuses flow step form variables of the specified request by resetting them and nullifying variable identities.
 void setAttribute(Object key, Object value)
          Sets a context attribute.
 Object setAttributeIfAbsent(Object key, Object value)
          Sets a context attribute if not already set.
 void setProperty(FlowStep step, Object property, Object value)
          Sets the property of the specified step.
 void setProperty(Object property, Object value)
          Sets the property of the current step.
 void setSelectedAttribute(String name)
          Sets the name of the selected attribute with an optional form prefix.
 void setSelectedFlowName(String name)
          Sets the selected flow name.
 void setSelectedParameter(int index, String value)
          Sets the selected parameter.
 void setSelectedStepIndex(int step)
          Sets the index of the selected step.
 void setSelectedStepPath(String name)
          Sets the selected step path.
 void setSelectedTemplatePath(String template)
          Sets the selected template path.
 void setSelectedVariable(Variable variable)
          Sets the selected variable.
 void setState(FlowStep step, Object state, boolean flag)
          Sets the state of the specified step.
 void setState(Object state, boolean flag)
          Sets the state of the current step.
 void setStepEnabled(FlowStep step, FlowStep flow, int index, boolean flag)
          Sets whether the route from the specified step to the indexed one is in the specified flow enabled.
 void setStepEnabled(FlowStep flow, int index, boolean flag)
          Sets whether the route from the current step to the indexed one in the specified flow is enabled.
 void setTemplate(String path)
          Sets the template of the current step.
 void setTransition(FlowStep step, Object state, Object value)
          Sets the transition of the specified step.
 void setTransition(Object state, Object value)
          Sets the transition of the current step.
 void setValidity(int index, String validity)
          Sets the validity of the indexed variable of the current step.
 void setVariable(Variable var)
          Sets the variable of the current step.
 int stepCount()
          Returns the number of steps in the current flow.
 int templateCount()
          Returns the number templates of the current step.
 int variableCount()
          Returns the number variables of the current step.
 
Methods inherited from class org.norther.tammi.spray.engine.tool.ContextTool
getFilter, getFilterChain, getFilterKey, getPrincipal, getRequest, getResponse, isFilterChanged
 
Methods inherited from class org.norther.tammi.spray.engine.tool.GlobalTool
clone, getContext, getContextToolFilter, getMBeanServer, isBound, nop, toString, valueBound, valueUnbound
 
Methods inherited from class org.norther.tammi.core.pool.PoolableSupport
disposed, recycled
 
Methods inherited from class org.norther.tammi.core.pool.RecyclableSupport
isDisposed, recycle
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.norther.tammi.core.pool.Recyclable
isDisposed, recycle
 

Constructor Detail

FlowTool

public FlowTool()
Constructs a new flow tool.

Method Detail

dispose

public void dispose()
Description copied from class: RecyclableSupport
Disposes the object by setting its disposed flag.

Specified by:
dispose in interface Recyclable
Overrides:
dispose in class ContextTool

reserve

public void reserve(long t)
Description copied from interface: StepFlowContext
Reserves this context for state changes at the specified time unless stale or interrupted.

Specified by:
reserve in interface StepFlowContext
Parameters:
t - the reservation time in msecs.

release

public void release()
Description copied from interface: StepFlowContext
Releases this context after state changes.

Specified by:
release in interface StepFlowContext

isReserved

public boolean isReserved()
Description copied from interface: StepFlowContext
Checks whether this context is reserved by some other thread than the current one.

Specified by:
isReserved in interface StepFlowContext
Returns:
true if reserved, false otherwise.

isInterrupted

public boolean isInterrupted()
Description copied from interface: Interruptable
Checks whether interrupted.

Specified by:
isInterrupted in interface Interruptable
Returns:
true if interrupted, false otherwise.

getReservationTime

public long getReservationTime()
Description copied from interface: StepFlowContext
Gets the last reservation time.

Specified by:
getReservationTime in interface StepFlowContext
Returns:
the time in msecs.

isValid

public boolean isValid()
Description copied from interface: StepFlowContext
Checks whether this context is valid.

Specified by:
isValid in interface StepFlowContext
Returns:
true if valid, false otherwise.

isRoot

public boolean isRoot()
Description copied from interface: StepFlowContext
Checks whether the current step is the root.

Specified by:
isRoot in interface StepFlowContext
Returns:
true if the root, false otherwise.

getRoot

public FlowStep getRoot()
Description copied from interface: StepFlowContext
Gets the root flow.

Specified by:
getRoot in interface StepFlowContext
Returns:
the root flow or null.

getFlow

public FlowStep getFlow()
Description copied from interface: StepFlowContext
Gets the current flow.

Specified by:
getFlow in interface StepFlowContext
Returns:
the current flow or null.

getStep

public FlowStep getStep()
Description copied from interface: StepFlowContext
Gets the current step.

Specified by:
getStep in interface StepFlowContext
Returns:
the current step or null.

isRestrictedRoutes

public boolean isRestrictedRoutes()
Description copied from interface: StepFlowContext
Checks whether step routes are restricted by a route matrix.

Specified by:
isRestrictedRoutes in interface StepFlowContext
Returns:
true if restricted, false otherwise.

isFlowEnabled

public boolean isFlowEnabled(FlowStep flow)
Description copied from interface: StepFlowContext
Checks whether the specified flow is enabled.

Specified by:
isFlowEnabled in interface StepFlowContext
Parameters:
flow - the target flow.
Returns:
true if enabled, false otherwise.

isStepEnabled

public boolean isStepEnabled(FlowStep step,
                             FlowStep flow,
                             int index)
Description copied from interface: StepFlowContext
Checks whether the route from the specified step to the indexed one in the specified flow is enabled.

Specified by:
isStepEnabled in interface StepFlowContext
Parameters:
step - the source step.
flow - the target flow.
index - the index of the target step.
Returns:
true if enabled, false otherwise.

setStepEnabled

public void setStepEnabled(FlowStep step,
                           FlowStep flow,
                           int index,
                           boolean flag)
Description copied from interface: StepFlowContext
Sets whether the route from the specified step to the indexed one is in the specified flow enabled.

Specified by:
setStepEnabled in interface StepFlowContext
Parameters:
step - the source step.
flow - the target flow.
index - the index of the target step.
flag - true if enabled, false otherwise.

getActionPhase

public StepFlowContext.ActionPhase getActionPhase()
Description copied from interface: StepFlowContext
Gets the action phase.

Specified by:
getActionPhase in interface StepFlowContext
Returns:
the action phase.

getAttribute

public Object getAttribute(Object key)
Description copied from interface: StepFlowContext
Gets a context attribute.

Specified by:
getAttribute in interface StepFlowContext
Parameters:
key - the attribute key.
Returns:
the attribute value or null.

getAttribute

public Object getAttribute(Object key,
                           Object defaultValue)
Description copied from interface: StepFlowContext
Gets a context attribute with a default value.

Specified by:
getAttribute in interface StepFlowContext
Parameters:
key - the attribute key.
defaultValue - the default value.
Returns:
the attribute value or null.

setAttribute

public void setAttribute(Object key,
                         Object value)
Description copied from interface: StepFlowContext
Sets a context attribute.

Specified by:
setAttribute in interface StepFlowContext
Parameters:
key - the attribute key.
value - the attribute value.

setAttributeIfAbsent

public Object setAttributeIfAbsent(Object key,
                                   Object value)
Description copied from interface: StepFlowContext
Sets a context attribute if not already set.

Specified by:
setAttributeIfAbsent in interface StepFlowContext
Parameters:
key - the attribute key.
value - the attribute value.
Returns:
the existing attribute value or null.

containsAttribute

public boolean containsAttribute(Object key)
Description copied from interface: StepFlowContext
Checks a context attribute.

Specified by:
containsAttribute in interface StepFlowContext
Parameters:
key - the attribute key.
Returns:
true if defined, false othwerwise.

removeAttribute

public void removeAttribute(Object key)
Description copied from interface: StepFlowContext
Removes a context attribute.

Specified by:
removeAttribute in interface StepFlowContext
Parameters:
key - the attribute key.

removeAttribute

public boolean removeAttribute(Object key,
                               Object value)
Description copied from interface: StepFlowContext
Removes a context attribute with the specidied value.

Specified by:
removeAttribute in interface StepFlowContext
Parameters:
key - the attribute key.
value - the attribute value.
Returns:
true if removed, false othwerwise.

clearAttributes

public void clearAttributes()
Description copied from interface: StepFlowContext
Clears all context attributes.

Specified by:
clearAttributes in interface StepFlowContext

attributeKeySet

public Set<Object> attributeKeySet()
Description copied from interface: StepFlowContext
Returns a set of context attribute keys.

Specified by:
attributeKeySet in interface StepFlowContext
Returns:
a read-only set of attribute keys.

getSelectedStepPath

public String getSelectedStepPath()
Description copied from interface: StepFlowContext
Gets the selected step path.

Specified by:
getSelectedStepPath in interface StepFlowContext
Returns:
the path of the selected step.

setSelectedStepPath

public void setSelectedStepPath(String name)
Description copied from interface: StepFlowContext
Sets the selected step path.

Specified by:
setSelectedStepPath in interface StepFlowContext
Parameters:
name - the path of the selected step.

getSelectedFlowName

public String getSelectedFlowName()
Description copied from interface: StepFlowContext
Gets the selected flow name.

Specified by:
getSelectedFlowName in interface StepFlowContext
Returns:
the name of the selected flow.

setSelectedFlowName

public void setSelectedFlowName(String name)
Description copied from interface: StepFlowContext
Sets the selected flow name.

Note that the selected step index is set to the beginning of the flow.

Specified by:
setSelectedFlowName in interface StepFlowContext
Parameters:
name - the name of the selected flow.

getSelectedStepIndex

public int getSelectedStepIndex()
Description copied from interface: StepFlowContext
Gets the index of the selected step.

Specified by:
getSelectedStepIndex in interface StepFlowContext
Returns:
the index of selected step.

setSelectedStepIndex

public void setSelectedStepIndex(int step)
Description copied from interface: StepFlowContext
Sets the index of the selected step.

Specified by:
setSelectedStepIndex in interface StepFlowContext
Parameters:
step - the index of the selected step.

getSelectedParameter

public String getSelectedParameter(int index)
Description copied from interface: StepFlowContext
Gets the selected parameter.

Specified by:
getSelectedParameter in interface StepFlowContext
Parameters:
index - the parameter index.
Returns:
the selected parameter.

setSelectedParameter

public void setSelectedParameter(int index,
                                 String value)
Description copied from interface: StepFlowContext
Sets the selected parameter.

Specified by:
setSelectedParameter in interface StepFlowContext
Parameters:
index - the parameter index.
value - the selected parameter.

getSelectedParameterCount

public int getSelectedParameterCount()
Description copied from interface: StepFlowContext
Gets the number of selected parameters.

Specified by:
getSelectedParameterCount in interface StepFlowContext
Returns:
the selected parameter count.

getSelectedTemplatePath

public String getSelectedTemplatePath()
Description copied from interface: StepFlowContext
Gets the selected template path.

Specified by:
getSelectedTemplatePath in interface StepFlowContext
Returns:
the selected template path.

setSelectedTemplatePath

public void setSelectedTemplatePath(String template)
Description copied from interface: StepFlowContext
Sets the selected template path.

Note that only one template can be passed through the selection, more complicated cases must be handled with other methods.

Specified by:
setSelectedTemplatePath in interface StepFlowContext
Parameters:
template - the selected template path.

getSelectedVariable

public Variable getSelectedVariable()
Description copied from interface: StepFlowContext
Gets the selected variable.

Specified by:
getSelectedVariable in interface StepFlowContext
Returns:
the selected variable.

setSelectedVariable

public void setSelectedVariable(Variable variable)
Description copied from interface: StepFlowContext
Sets the selected variable.

Note that only one variable can be passed through the selection, more complicated cases must be handled with other methods.

Specified by:
setSelectedVariable in interface StepFlowContext
Parameters:
variable - the selected variable.

getSelectedAttribute

public String getSelectedAttribute()
Description copied from interface: StepFlowContext
Gets the name of the selected attribute with an optional form prefix.

Specified by:
getSelectedAttribute in interface StepFlowContext
Returns:
the name of the selected attribute.

setSelectedAttribute

public void setSelectedAttribute(String name)
Description copied from interface: StepFlowContext
Sets the name of the selected attribute with an optional form prefix.

Specified by:
setSelectedAttribute in interface StepFlowContext
Parameters:
name - the name of the selected attribute.

isNewSelection

public boolean isNewSelection()
Description copied from interface: StepFlowContext
Checks whether a new selection is set.

Specified by:
isNewSelection in interface StepFlowContext
Returns:
true if set, false otherwise.

cancelSelection

public void cancelSelection()
Description copied from interface: StepFlowContext
Cancels the the current selection.

Specified by:
cancelSelection in interface StepFlowContext

clearSelection

public void clearSelection()
Description copied from interface: StepFlowContext
Clears the current selection.

Specified by:
clearSelection in interface StepFlowContext

resetSelection

public void resetSelection()
Description copied from interface: StepFlowContext
Clears and resets the selection to the previous one.

Specified by:
resetSelection in interface StepFlowContext

defaultSelection

public void defaultSelection()
Description copied from interface: StepFlowContext
Clears and resets the selection to the default one.

Specified by:
defaultSelection in interface StepFlowContext

getErrors

public List<Throwable> getErrors()
Description copied from interface: StepFlowContext
Gets a list of all throwables in the error stack.

Specified by:
getErrors in interface StepFlowContext
Returns:
an unmodifiable list of throwables.

pushError

public void pushError(Throwable error)
Description copied from interface: StepFlowContext
Pushes a throwable to the error stack without throwing one.

Specified by:
pushError in interface StepFlowContext
Parameters:
error - the throwable.

popError

public Throwable popError()
Description copied from interface: StepFlowContext
Pops a throwable from the error stack.

Specified by:
popError in interface StepFlowContext
Returns:
the thowable or null.

containsErrors

public boolean containsErrors()
Description copied from interface: StepFlowContext
Checks whether the erro stack contains errors.

Specified by:
containsErrors in interface StepFlowContext
Returns:
true if the error stack is not empty.

clearErrors

public void clearErrors()
Description copied from interface: StepFlowContext
Clears throwables from the error stack.

Specified by:
clearErrors in interface StepFlowContext

prepareSelection

public FlowStep prepareSelection(ServletRequest request,
                                 ServletResponse response,
                                 FilterChain chain)
Description copied from interface: StepFlowContext
Prepares a new selection.

Specified by:
prepareSelection in interface StepFlowContext
Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the selected step or null.

finishSelection

public void finishSelection(ServletRequest request,
                            ServletResponse response,
                            FilterChain chain)
Description copied from interface: StepFlowContext
Finishes a new selection.

Specified by:
finishSelection in interface StepFlowContext
Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.

getTemplateContext

public TemplateContext getTemplateContext(ServletRequest request,
                                          ServletResponse response,
                                          FilterChain chain)
                                   throws TemplateException
Description copied from interface: StepFlowContext
Gets the template context of the specified request.

Specified by:
getTemplateContext in interface StepFlowContext
Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the template context.
Throws:
TemplateException - on errors.

getFormName

public String getFormName(ServletRequest request,
                          ServletResponse response,
                          FilterChain chain)
Description copied from interface: StepFlowContext
Gets the form name of the specified request.

Specified by:
getFormName in interface StepFlowContext
Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the form name or null.

getFormIndex

public int[] getFormIndex(ServletRequest request,
                          ServletResponse response,
                          FilterChain chain)
Description copied from interface: StepFlowContext
Gets the form index of the specified request.

Specified by:
getFormIndex in interface StepFlowContext
Parameters:
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
the form index or null.

getFormVariables

public List<KeyValue<String,Variable>> getFormVariables(FlowStep step,
                                                        ServletRequest request,
                                                        ServletResponse response,
                                                        FilterChain chain)
Description copied from interface: StepFlowContext
Gets a list of flow step form variables of the specified request. Unsubmitted variables are returned as nulls. If none is submitted, an empty list is returned. Keys correspond to form prefixes of the variables in their indexed order.

Specified by:
getFormVariables in interface StepFlowContext
Parameters:
step - the flow step.
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Returns:
a list of form variables.

resetFormVariables

public void resetFormVariables(FlowStep step,
                               ServletRequest request,
                               ServletResponse response,
                               FilterChain chain)
Description copied from interface: StepFlowContext
Resets flow step form variables of the specified request by setting the form validities back to initial.

Specified by:
resetFormVariables in interface StepFlowContext
Parameters:
step - the flow step.
request - the servlet request.
response - the servlet response.
chain - the filter chain.

reuseFormVariables

public void reuseFormVariables(FlowStep step,
                               ServletRequest request,
                               ServletResponse response,
                               FilterChain chain)
                        throws ConstructionException
Description copied from interface: StepFlowContext
Reuses flow step form variables of the specified request by resetting them and nullifying variable identities.

Specified by:
reuseFormVariables in interface StepFlowContext
Parameters:
step - the flow step.
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Throws:
ConstructionException - on errors.

renewFormVariables

public void renewFormVariables(FlowStep step,
                               ServletRequest request,
                               ServletResponse response,
                               FilterChain chain)
                        throws ConstructionException
Description copied from interface: StepFlowContext
Renews flow step form variables of the specified request by creating a new instance of each variable.

Specified by:
renewFormVariables in interface StepFlowContext
Parameters:
step - the flow step.
request - the servlet request.
response - the servlet response.
chain - the filter chain.
Throws:
ConstructionException - if construction fails.

getFlowFilter

public FlowFilter getFlowFilter()
Description copied from interface: StepFlowContext
Gets the flow filter of this context if available.

Specified by:
getFlowFilter in interface StepFlowContext
Returns:
the flow filter or null.

isObsolete

public boolean isObsolete()
Checks whether this tool is obsolete.

Returns:
true if obsolete, false otherwise.

getDefaultFlowName

public String getDefaultFlowName()
Gets the default flow name.

Returns:
the default flow name or null.

getFlowName

public String getFlowName(String path)
Gets the flow part of the flow step path.

Parameters:
path - the flow step path.
Returns:
the flow name without a step index.

getStepIndex

public int getStepIndex(String path)
Gets the index part of the flow step path.

Parameters:
path - the flow step path.
Returns:
the defined index or the default one if not included.
Throws:
NumberFormatException - for an invalid indexed path.

getStepPath

public String getStepPath(String name,
                          int index)
Gets the path to the indexed step of the named flow.

Parameters:
name - the flow step name.
index - the step index.
Returns:
the path to the specified step.

getFlows

public List<FlowStep> getFlows()
Gets the current flow path as a list.

Returns:
a list of flows.

getQualifiedName

public String getQualifiedName()
Gets the qualified name of the current step.

Returns:
the qualified name or null.

getQualifiedName

public String getQualifiedName(String name)
Gets the qualified name of the named step of the current flow.

Parameters:
name - the step name.
Returns:
the qualified name or null.

getQualifiedName

public String getQualifiedName(String[] names)
Gets the qualified name of the named steps of the current flow.

Parameters:
names - the step names.
Returns:
the qualified name or null.

isState

public boolean isState(Object state,
                       boolean... local)
Checks the state of the current step.

Parameters:
state - the state.
local - true to break inheritance.
Returns:
true or false.

setState

public void setState(Object state,
                     boolean flag)
Sets the state of the current step.

Parameters:
state - the state.
flag - true or false.

clearState

public boolean clearState(Object state)
Clears the state of the current step.

Parameters:
state - the state.
Returns:
true or false.

getProperty

public Object getProperty(Object property,
                          boolean... local)
Gets the property of the current step.

Parameters:
property - the property.
local - true to break inheritance.
Returns:
the value.

setProperty

public void setProperty(Object property,
                        Object value)
Sets the property of the current step.

Parameters:
property - the property.
value - the value.

removeProperty

public Object removeProperty(Object property)
Removes the property of the current step.

Parameters:
property - the property.
Returns:
the value.

getTransition

public Object getTransition(Object state,
                            boolean... local)
Gets the transition of the current step.

Parameters:
state - the state.
local - true to break inheritance.
Returns:
the transition.

setTransition

public void setTransition(Object state,
                          Object value)
Sets the transition of the current step.

Parameters:
state - the state.
value - the transition.

removeTransition

public Object removeTransition(Object state)
Removes the transition of the current step.

Parameters:
state - the state.
Returns:
the value.

isState

public boolean isState(FlowStep step,
                       Object state,
                       boolean... local)
Checks the state of the specified step.

Parameters:
step - the step.
state - the state.
local - true to break inheritance.
Returns:
true or false.

setState

public void setState(FlowStep step,
                     Object state,
                     boolean flag)
Sets the state of the specified step.

Parameters:
step - the step.
state - the state.
flag - true or false.

clearState

public boolean clearState(FlowStep step,
                          Object state)
Clears the state of the specified step.

Parameters:
step - the step.
state - the state.
Returns:
true or false.

getProperty

public Object getProperty(FlowStep step,
                          Object property,
                          boolean... local)
Gets the property of the specified step.

Parameters:
step - the step.
property - the property.
local - true to break inheritance.
Returns:
the value.

setProperty

public void setProperty(FlowStep step,
                        Object property,
                        Object value)
Sets the property of the specified step.

Parameters:
step - the step.
property - the property.
value - the value.

removeProperty

public Object removeProperty(FlowStep step,
                             Object property)
Removes the property of the specified step.

Parameters:
step - the step.
property - the property.
Returns:
the value.

getTransition

public Object getTransition(FlowStep step,
                            Object state,
                            boolean... local)
Gets the transition of the specified step.

Parameters:
step - the step.
state - the state.
local - true to break inheritance.
Returns:
the value.

setTransition

public void setTransition(FlowStep step,
                          Object state,
                          Object value)
Sets the transition of the specified step.

Parameters:
step - the step.
state - the state.
value - the value.

removeTransition

public Object removeTransition(FlowStep step,
                               Object state)
Removes the transition of the specified step.

Parameters:
step - the step.
state - the state.
Returns:
the value.

isSecure

public boolean isSecure()
Checks whether the current step requires a secured connection.

Returns:
True if secured, False if not and null if unchanged.

isSecure

public boolean isSecure(FlowStep step)
Checks whether the specified step requires a secured connection.

Parameters:
step - the step.
Returns:
True if secured, False if not and null if unchanged.

exists

public boolean exists(String name)
Checks whether the specified step or flow exists.

Parameters:
name - the name of the flow or step.
Returns:
the if exists, false otherwise.

getDefaultLabel

public String getDefaultLabel()
Gets the default label.

Returns:
the label or empty if not specified.

getFlowLabel

public String getFlowLabel()
Gets the label of the current flow.

Returns:
the label or the name if not specified.

getStepLabel

public String getStepLabel()
Gets the label of the current step.

Returns:
the label or the name if not specified.

getFlowLabel

public String getFlowLabel(String name)
Gets the label of the named flow.

Parameters:
name - the name of the flow.
Returns:
the label or the name if not specified.

stepCount

public int stepCount()
Returns the number of steps in the current flow.

Returns:
the number of steps.

isCurrentIndex

public boolean isCurrentIndex(int index)
Checks whether the indexed step is the current one.

Parameters:
index - the index of the step.
Returns:
true if current, false otherwise.

getPreviousIndex

public int getPreviousIndex()
Gets the index of the previous step or 0 if not available.

Returns:
the previous step index or 0.

getNextIndex

public int getNextIndex()
Gets the index of the next step or 0 if not available.

Returns:
the next step index or 0.

getStepIndex

public int getStepIndex(int offset)
Gets the index of the step relative to the current one or 0 if not available.

Parameters:
offset - the index offset.
Returns:
the step index or 0.

getStep

public FlowStep getStep(int offset)
Gets the step relative to the current one or null if not available.

Parameters:
offset - the index offset.
Returns:
the step or null.

isStepEnabled

public boolean isStepEnabled(FlowStep flow,
                             int index)
Checks whether the route from the current step to the indexed one in the specified flow is enabled.

Parameters:
flow - the target flow.
index - the index of the target step.
Returns:
true if enabled, false otherwise.

setStepEnabled

public void setStepEnabled(FlowStep flow,
                           int index,
                           boolean flag)
Sets whether the route from the current step to the indexed one in the specified flow is enabled.

Parameters:
flow - the target flow.
index - the index of the target step.
flag - true if enabled, false otherwise.

isReadOnly

public boolean isReadOnly()
Checks the read-only state of the current step.

Returns:
true for a read-only state.

isOnlyWrite

public boolean isOnlyWrite()
Checks the only-write state of the current step.

Returns:
true for a only-write state.

isWriteEven

public boolean isWriteEven()
Checks the write-even state of the current step.

Returns:
true for a write-even state.

getTemplate

public String getTemplate()
Gets the template of the current step.

Returns:
the template of the current step or null.

setTemplate

public void setTemplate(String path)
Sets the template of the current step.

Parameters:
path - the template of the current step.

getTemplate

public String getTemplate(int ind)
Gets the indexed template of the current step.

Parameters:
ind - the index of the template.
Returns:
the indexed template of the current step or null.

getTemplates

public List<String> getTemplates()
Gets the templates of the current step.

Returns:
a read only list of templates.

templateCount

public int templateCount()
Returns the number templates of the current step.

Returns:
the number of templates.

getVariable

public Variable getVariable()
Gets the variable of the current step.

Returns:
the variable of the current step or null.

setVariable

public void setVariable(Variable var)
Sets the variable of the current step.

Parameters:
var - the variable of the current step.

getVariable

public Variable getVariable(int ind)
Gets the indexed variable of the current step.

Parameters:
ind - the index of the variable.
Returns:
the indexed variable of the current step or null.

getVariables

public List<Variable> getVariables()
Gets the variables of the current step.

Returns:
a read only list of variables.

variableCount

public int variableCount()
Returns the number variables of the current step.

Returns:
the number of variables.

checkPermission

public boolean checkPermission(String actions)
Checks access permission for the current step.

Parameters:
actions - the actions to access.
Returns:
true or false.

checkPermission

public boolean checkPermission(int index,
                               String actions)
Checks access permission for the indexed step in the current flow.

Parameters:
index - the step index.
actions - the actions to access.
Returns:
true or false.

checkPermission

public boolean checkPermission(FlowStep flow,
                               int index,
                               String actions)
Checks access permission for the indexed step in the specified flow.

Parameters:
flow - the flow.
index - the step index.
actions - the actions to access.
Returns:
true or false.

isValidated

public boolean isValidated()
Checks whether the current step has validated variables.

Returns:
true if validated, false otherwise.

getValidity

public String getValidity(int index)
Gets the validity of the indexed variable of the current step.

Parameters:
index - the index.
Returns:
the form validity.

setValidity

public void setValidity(int index,
                        String validity)
Sets the validity of the indexed variable of the current step.

Parameters:
index - the index.
validity - the form validity

getValidities

public String[] getValidities()
Gets the validities of the variables of the current step.

Returns:
the form validities.

resetValidities

public void resetValidities(String validity)
Resets the validity of all variables of the current step unless rejected.

Parameters:
validity - the form validity

containsValidity

public boolean containsValidity(String validity)
Returns true if the specified form validity is present in the current step.

Parameters:
validity - the form validity
Returns:
true if contains the specified validity.

equalsValidity

public boolean equalsValidity(String validity)
Returns true if the specified form validity equals validities of the current step.

Parameters:
validity - the form validity
Returns:
true if equals to the specified validity.

isFormValidated

public boolean isFormValidated()
Checks whether the form variables of the current step are validated.

Returns:
true if validated, false otherwise.

getAttribute

public Object getAttribute(String name,
                           String key,
                           Object defaultValue)
Gets a mapped attribute.

Parameters:
name - the attribute name.
key - the mapped key.
defaultValue - the default value.
Returns:
the mapped value or null.

isLocalized

public boolean isLocalized()
Checks whether the current step is localized.

Returns:
true if localized, false otherwise.

resolve

public String resolve(String key)
Resolves a string resource from the flow specific bundle.

Parameters:
key - the key of the resource.
Returns:
the found resource or the key if not found.

activateSelection

public FlowStep activateSelection()
Activates the selection.

Returns:
selected step or null if failed.

chainErrors

public boolean chainErrors()
Chains step flow and filter chain errors to the filter chain.

Returns:
true if any chained errors, false otherwise.

joinErrors

public boolean joinErrors()
Joins filter chain and step flow errors to the step flow.

Returns:
true if any joined errors, false otherwise.

getCurrentContext

protected StepFlowContext getCurrentContext()
Gets the current step flow context.

Returns:
the step flow context.

getFormFilter

protected FormFilter getFormFilter()
Gets the form filter from the filter stack.

Returns:
the form filter or null.

getResourceFilter

protected ResourceFilter getResourceFilter()
Gets the resource filter from the filter stack.

Returns:
the resource filter or null.

getSecuredFilter

protected SecuredFilter getSecuredFilter()
Gets the secured filter from the filter stack.

Returns:
the secured filter or null.


Copyright © 2004 The Norther Organization. All rights reserved.