com.ibm.dse.automaton.html
Class DSEHtmlProcessor

java.lang.Object
  |
  +--com.ibm.dse.base.DSENotifier
        |
        +--com.ibm.dse.automaton.DSEProcessor
              |
              +--com.ibm.dse.automaton.html.DSEHtmlProcessor

public class DSEHtmlProcessor
extends DSEProcessor

This is a subclass of DSEProcessor that implements behaviour specific to the HomeBanking HTML Client. Behaviour has been added in this class to support 'virtual' processors, ie processors which can be persisted with enough information to restore them to the state they were in at the time they are persisted. Behaviour has also been added to change the default behaviour of DSEProcessor, whereby it executes the state machine to its end. The changed behaviour is to check state types before they are processed, and to suspend the processor for some kinds of states, specifically, for the page, and subflow types. In addition, support for a validator class has been added. The validator class provides support for validating business data required for the workflow that the processor is implementing.

See Also:
Serialized Form

Field Summary
static java.lang.String ABORTING
           
static java.lang.String COMPID
           
static java.lang.String CONSEQ_FALSE
           
static java.lang.String CONSEQ_TRUE
           
static java.lang.String CONSEQ_UNDEFINED
           
static java.lang.String CONSEQUENTIAL
           
 
Fields inherited from class com.ibm.dse.automaton.DSEProcessor
ABORTED, aProcessorStatusChangedListener, CHANGESTATE, cleanQueueOnSwitch, COMPLETED, context, currentState, eventQueue, externalizer, INITIALIZED, NOT_INITIALIZED, processorId, processorName, RUNNING, stateTag, status, STATUSCHANGEEVENT, SUSPENDED, TERMINATEEVENT
 
Fields inherited from class com.ibm.dse.base.DSENotifier
handlersList, name
 
Constructor Summary
DSEHtmlProcessor()
          DSEHtmlProcessor constructor.
DSEHtmlProcessor(boolean mustRegister)
          DSEHtmlProcessor constructor.
DSEHtmlProcessor(java.lang.String aName)
          DSEHtmlProcessor constructor.
DSEHtmlProcessor(java.lang.String aName, java.lang.String aTID)
          DSEHtmlProcessor constructor.
 
Method Summary
 void abort()
          Called on to abort the state machine
 void changeState(java.lang.String newState)
          This is equivalent to calling changeState(String, false, null).
 void changeState(java.lang.String newState, boolean ignoreEntryActions)
          This is equivalent to calling changeState(String, false, TransitionDescriptor), with a transition descriptor object that has its ignoreEntryActions flag set to the boolean argument.
 void changeState(java.lang.String newStateName, boolean activate, java.lang.String transitionName)
          This method is equivalent to calling changeState(String, boolean, TransitionDescriptor).
 void changeState(java.lang.String newStateName, boolean activate, TransitionDescriptor transition)
          This method attempts to change the current state being managed by the state machine to the one specified by the state name argument.
protected  boolean checkLegalSwitch(State state, TransitionDescriptor transition)
          This utility method returns a boolean indicating whether it is legal for the state machine to switch to state supplied as argument.
 boolean checkLegalSwitch(java.lang.String stateName)
          This utility method returns a boolean indicating whether it is legal for the state machine to switch to state supplied as argument.
 boolean checkLegalSwitch(java.lang.String stateName, java.lang.String eventName)
          This utility method returns a boolean indicating whether it is legal for the state machine to switch to state supplied as argument.
 void execute()
          Serves as an entry point for execution of the state machine.
 void execute(java.lang.String eventName)
          This method is used to kick off execution of the HTML processor.
 java.lang.String getConseqErrorResponse()
          Returns the consequential error response defined for this processor.
 java.lang.String getParentId()
          Returns the parent id attribute of this processor.
protected  State getStateInstance(State state, Tag aTag)
          This is a utility method used to obtain an appropriate State instance for the supplied tag.
 ProcessorXValidate getXValidator()
          Returns the validator attribute for this class.
 int indexOfInteger(java.lang.String address)
          Utility method which looks for a number inside the given string.
 java.lang.Object initializeFrom(Tag aTag)
          This method initializes this processor objects state from externalized data definitions.
protected  boolean isSystemValue(java.lang.String valueName)
          This utility method returns true if the string value passed represents the name of a HTML client system variable, which is defined as one prefixed with dse_.
 void setConseqErrorResponse(java.lang.String newConseqErrorResponse)
          Sets the consequential error response for this processor object.
 void setParentId(java.lang.String newParentId)
          Set the parent id attribute of this processor object.
protected  void setProcessorConsequentialState(State state, java.lang.String consequentiality)
          This utility method changes the status of the processor depending on the consequentiality of the state and the supplied consequentiality argument.
 void setXValidator(ProcessorXValidate newXValidator)
          Sets the validator attribute of this processor object.
static boolean stateReturnsControl(State state)
          This method serves as a utility method for HTML processors and determines whether the state supplied to it as argument is of a type for which the processor will suspend execution of the state machine.
 void updateContext(Context context)
          This method updates the processor context by copying values by name from the supplied context into the processor context.
 boolean updateContext(KeyedCollection coll)
          Validates the data received from client and copies it into the processor context.
 void validate(KeyedCollection coll, Context context)
          This method does basic validation of the business data passed in the keyed collection.
 void validateFromTransition(KeyedCollection coll, Context context)
          This method does basic validation of the business data passed in the keyed collection.
 void xValidate(Context context, java.lang.String transitionName)
          This method uses the processors defined validator class to perform validation of data, and stores any exceptions thrown in the course of validation in the context heirarchy to be utilized by the HomeBanking framework.
 
Methods inherited from class com.ibm.dse.automaton.DSEProcessor
addProcessorStatusChangedListener, cleanEventQueue, close, externalizer, fireProcessorStatusChangedEvent, fireProcessorTerminatedEvent, getContext, getCurrentState, getCurrentStateType, getEventQueue, getExternalizer, getInitialStateTag, getProcessorId, getProcessorName, getStateTag, getStateTagList, getStatus, getTag, initialize, initializeKeyedCollectionValueFrom, isCacheable, isCleanQueueOnSwitch, readExternal, readExternal, readObject, reinitialize, removeExternal, resume, setCleanQueueOnSwitch, setContext, setCurrentState, setCurrentStateType, setEventQueue, setExternalizer, setProcessorId, setProcessorName, setStatus, setTag, suspend, terminate, toString, toStrings, toTags, writeExternal, writeExternal
 
Methods inherited from class com.ibm.dse.base.DSENotifier
addHandler, getHandlersList, getName, removeHandler, setName, signalEvent, signalEvent, signalEvent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

COMPID

public static final java.lang.String COMPID

CONSEQ_UNDEFINED

public static final java.lang.String CONSEQ_UNDEFINED

CONSEQ_TRUE

public static final java.lang.String CONSEQ_TRUE

CONSEQ_FALSE

public static final java.lang.String CONSEQ_FALSE

CONSEQUENTIAL

public static final java.lang.String CONSEQUENTIAL

ABORTING

public static final java.lang.String ABORTING
Constructor Detail

DSEHtmlProcessor

public DSEHtmlProcessor()
DSEHtmlProcessor constructor.

DSEHtmlProcessor

public DSEHtmlProcessor(java.lang.String aName)
DSEHtmlProcessor constructor.
Parameters:
aName - java.lang.String

DSEHtmlProcessor

public DSEHtmlProcessor(java.lang.String aName,
                        java.lang.String aTID)
DSEHtmlProcessor constructor.
Parameters:
aName - java.lang.String
aTID - java.lang.String

DSEHtmlProcessor

public DSEHtmlProcessor(boolean mustRegister)
DSEHtmlProcessor constructor.
Parameters:
mustRegister - boolean
Method Detail

abort

public void abort()
           throws DSEProcessorException
Called on to abort the state machine
Overrides:
abort in class DSEProcessor
Throws:
DSEProcessorException -  

changeState

public void changeState(java.lang.String newState)
                 throws DSEProcessorException
This is equivalent to calling changeState(String, false, null).
Overrides:
changeState in class DSEProcessor
Parameters:
newState - java.lang.String
Throws:
DSEProcessorException -  

changeState

public void changeState(java.lang.String newState,
                        boolean ignoreEntryActions)
                 throws DSEProcessorException
This is equivalent to calling changeState(String, false, TransitionDescriptor), with a transition descriptor object that has its ignoreEntryActions flag set to the boolean argument.
Overrides:
changeState in class DSEProcessor
Parameters:
newState - java.lang.String
ignoreEntryActions - boolean
Throws:
DSEProcessorException -  

changeState

public void changeState(java.lang.String newStateName,
                        boolean activate,
                        TransitionDescriptor transition)
                 throws DSEProcessorException
This method attempts to change the current state being managed by the state machine to the one specified by the state name argument. The following apply: The ignoreEntryActions attribute of the new state is set to correspond to the ignoreEntryActions attribute of the supplied transition. For HTML states, the inputMapFormat attribute of the supplied transition is copied (if present), into the state. The consequentiality of the state specified by the state name argument, and of the transition passed in as argument are used to determine the consequential status of the processor. State and transition consequentiality are attributes that define whether the processor will be placed in a consequential state upon traversal of the state or transition. Consequentiality for a state or transition can take one of three values, undefined, true or false. Please see com.ibm.dse.automaton.html.DSEHtmlState for formal definitions. If the state specified by the state name argument defines consequentiality (true or false), then its value for consequentiality is used to determine the consequential status of the processor. If it does not however, but the transition does, then the transitions consequentiality is used to determine the processors consequential status. If the processor is consequential and the state or transition has a status of false, then the processor is removed from the consequential state. If the processor is not consequential, and the state or transition has a status of true, then the processor is placed into a consequential state. As mentioned above, the transitions values are only used if the state has a value of undefined for its consequentiality. If the activate argument is true, then the new state is activated upon completion of this method.
Parameters:
newStateName - java.lang.String
activate - boolean
transition - com.ibm.dse.automaton.TransitionDescriptor
Throws:
DSEProcessorException -  

changeState

public void changeState(java.lang.String newStateName,
                        boolean activate,
                        java.lang.String transitionName)
                 throws DSEProcessorException
This method is equivalent to calling changeState(String, boolean, TransitionDescriptor). The transition descriptor argument is obtained from the current state of the processor, using the transition name supplied as argument to this method.
Parameters:
newStateName - java.lang.String
ignoreEntryActions - boolean
transitionName - java.lang.String
Throws:
DSEProcessorException -  

checkLegalSwitch

protected boolean checkLegalSwitch(State state,
                                   TransitionDescriptor transition)
This utility method returns a boolean indicating whether it is legal for the state machine to switch to state supplied as argument. Legality is determined thus: If the processor is in a consequential state, and an attempt is made to switch to a state that does not define consequentiality, then legality is set to false. All other cases set legality to true ;
Parameters:
state - com.ibm.dse.automaton.State
transition - com.ibm.dse.automaton.TransitionDescriptor
Returns:
boolean

checkLegalSwitch

public boolean checkLegalSwitch(java.lang.String stateName)
This utility method returns a boolean indicating whether it is legal for the state machine to switch to state supplied as argument. Legality is determined thus: If the processor is in a consequential state, and an attempt is made to switch to a state that does not define consequentiality, then legality is set to false. All other cases set legality to true ;
Parameters:
stateName - java.lang.String
Returns:
boolean

checkLegalSwitch

public boolean checkLegalSwitch(java.lang.String stateName,
                                java.lang.String eventName)
This utility method returns a boolean indicating whether it is legal for the state machine to switch to state supplied as argument. Legality is determined thus: If the processor is in a consequential state, and an attempt is made to switch to a state that does not define consequentiality, then legality is set to false. All other cases set legality to true ;
Parameters:
stateName - java.lang.String
eventName - java.lang.String
Returns:
boolean

execute

public void execute()
             throws DSEInvalidArgumentException,
                    DSEProcessorException
Serves as an entry point for execution of the state machine. Additional behavior has been added to this method to support suspension of the state machine when states of a certain type are encountered during processing.
Overrides:
execute in class DSEProcessor
Throws:
DSEInvalidArgumentException -  
DSEProcessorException -  

execute

public void execute(java.lang.String eventName)
             throws DSEInvalidArgumentException,
                    DSEProcessorException
This method is used to kick off execution of the HTML processor. An event is dispatched to the state machine corresponding to the supplied event name. This event is essentially the entry event for the state machine to begin processing with.
Throws:
DSEInvalidArgumentException -  
DSEProcessorException -  

getConseqErrorResponse

public java.lang.String getConseqErrorResponse()
Returns the consequential error response defined for this processor.
Returns:
java.lang.String

getParentId

public java.lang.String getParentId()
Returns the parent id attribute of this processor.
Returns:
java.lang.String

getStateInstance

protected State getStateInstance(State state,
                                 Tag aTag)
                          throws java.lang.Exception
This is a utility method used to obtain an appropriate State instance for the supplied tag. The class of the supplied State argument is used if a class instance cannot be obtained in any other way.
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
com.ibm.dse.automaton.State
Throws:
java.lang.Exception -  

getXValidator

public ProcessorXValidate getXValidator()
Returns the validator attribute for this class.
Returns:
com.ibm.dse.automaton.html.ProcessorXValidate

indexOfInteger

public int indexOfInteger(java.lang.String address)
Utility method which looks for a number inside the given string. If it is found, its index in the String is returned, if not, -1 is returned. The number is supposed to be delimitated by dots ("asas.123.dfg.dfg"). If there are more than one number, the index of the first one is returned.
Parameters:
address - java.lang.String
Returns:
int

initializeFrom

public java.lang.Object initializeFrom(Tag aTag)
                                throws java.io.IOException,
                                       DSEException
This method initializes this processor objects state from externalized data definitions.
Overrides:
initializeFrom in class DSEProcessor
Parameters:
aTag - com.ibm.dse.base.Tag
Returns:
java.lang.Object
Throws:
java.io.IOException -  
DSEException -  

isSystemValue

protected boolean isSystemValue(java.lang.String valueName)
This utility method returns true if the string value passed represents the name of a HTML client system variable, which is defined as one prefixed with dse_.
Parameters:
valueName - java.lang.String
Returns:
boolean

setConseqErrorResponse

public void setConseqErrorResponse(java.lang.String newConseqErrorResponse)
Sets the consequential error response for this processor object.
Parameters:
newConseqErrorResponse - java.lang.String

setParentId

public void setParentId(java.lang.String newParentId)
Set the parent id attribute of this processor object.
Parameters:
newParentId - java.lang.String

setProcessorConsequentialState

protected void setProcessorConsequentialState(State state,
                                              java.lang.String consequentiality)
This utility method changes the status of the processor depending on the consequentiality of the state and the supplied consequentiality argument.
Parameters:
state - com.ibm.dse.automaton.State
consequentiality - java.lang.String

setXValidator

public void setXValidator(ProcessorXValidate newXValidator)
Sets the validator attribute of this processor object.
Parameters:
newXValidator - com.ibm.dse.automaton.html.ProcessorXValidate

stateReturnsControl

public static boolean stateReturnsControl(State state)
This method serves as a utility method for HTML processors and determines whether the state supplied to it as argument is of a type for which the processor will suspend execution of the state machine. It returns a boolean indicating whether this should occur or not.
Parameters:
state - com.ibm.dse.automaton.State
Returns:
boolean

updateContext

public void updateContext(Context context)
                   throws DSEObjectNotFoundException,
                          DSEException
This method updates the processor context by copying values by name from the supplied context into the processor context.
Parameters:
context - com.ibm.dse.base.Context
Throws:
DSEObjectNotFoundException -  
DSEException -  

updateContext

public boolean updateContext(KeyedCollection coll)
                      throws DSETypeException,
                             DSEObjectNotFoundException,
                             DSEInvalidArgumentException
Validates the data received from client and copies it into the processor context. The validation includes the field validation and the cross validation. If a transition context has been defined, only the sent elements that appear in this context will be copied.
Parameters:
coll - com.ibm.dse.base.KeyedCollection
Returns:
boolean
Throws:
DSETypeException -  
DSEObjectNotFoundException -  
DSEInvalidArgumentException -  

validate

public void validate(KeyedCollection coll,
                     Context context)
              throws DSEObjectNotFoundException,
                     DSETypeException,
                     DSEInvalidArgumentException
This method does basic validation of the business data passed in the keyed collection. Extensive validation is possible when using typed data, else validation is basically a copy-by-name into the supplied context. With typed data however, the data element validator is used to verify the data value before it is copied into the context.
Parameters:
coll - com.ibm.dse.base.KeyedCollection
context - com.ibm.dse.base.Context
Returns:
boolean
Throws:
DSEException -  

validateFromTransition

public void validateFromTransition(KeyedCollection coll,
                                   Context context)
                            throws DSEException
This method does basic validation of the business data passed in the keyed collection. Only the fields defined in the transition context are validated and copied into the context. Extensive validation is possible when using typed data, else validation is basically a copy-by-name into the supplied context. With typed data however, the data element validator is used to verify the data value before it is copied into the context.
Parameters:
coll - com.ibm.dse.base.KeyedCollection
context - com.ibm.dse.base.Context
Returns:
boolean
Throws:
DSEException -  

xValidate

public void xValidate(Context context,
                      java.lang.String transitionName)
               throws java.lang.Exception
This method uses the processors defined validator class to perform validation of data, and stores any exceptions thrown in the course of validation in the context heirarchy to be utilized by the HomeBanking framework.
Parameters:
context - com.ibm.dse.base.Context
transitionName - java.lang.String
Throws:
java.lang.Exception -