Class StateMachine
- All Implemented Interfaces:
TagValueListener,TagValueWrapper
Each State can be specified to deliver events to a particular TagValueListener.
Transitions can be specified to occur between States when specific events are encountered. These events can be Tags delivered by startTag as well as the endTag/endRecord events. Events that result in exit from the current State can be specified to be notifiable to the State listener.
In addition, tables of transitions can be defined and specified as the fallback when the a corresponding Transition cannot be found for the tag. This is useful for specifying the destination States that are globally applicable for particular tags. As the fallbacks can be chained, you can end up with a hierarchy of Transition Tables, some being State-specific, others applicable to groups of States and finally one being global.
- Author:
- David Huen
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassImplementation of a State in a state machinestatic interfaceInterface implemented by State listeners that want notification when a transition leaves the State.classa basic listener for a State.static interfaceInterface for a State within this StateMachineclassclass to represent a State TransitionclassTable of Transition destination States and their corresponding Tags. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TagValueListenerprotected static final Stringprotected static final Stringprotected static final Stringprotected static final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateState(String label) voidThe current record has ended.voidendTag()End the current tag.get listener to which all calls will be delegatedvoidsetDelegate(TagValueListener delegate) TagValueWrapper interfacevoidA new record is about to start.voidTagValueListener interfacevoidvalue(TagValueContext ctxt, Object value) A value has been seen.
-
Field Details
-
START_RECORD_TAG
- See Also:
-
END_RECORD_TAG
- See Also:
-
END_TAG
- See Also:
-
MAGICAL_STATE
- See Also:
-
delegate
-
-
Constructor Details
-
StateMachine
public StateMachine()
-
-
Method Details
-
getMagicalState
-
createState
-
getState
-
createTransitionTable
-
setDelegate
TagValueWrapper interface- Specified by:
setDelegatein interfaceTagValueWrapper
-
getDelegate
Description copied from interface:TagValueWrapperget listener to which all calls will be delegated- Specified by:
getDelegatein interfaceTagValueWrapper
-
startTag
TagValueListener interface- Specified by:
startTagin interfaceTagValueListener- Parameters:
tag- the Object representing the new tag- Throws:
ParserException- if the tag could not be started
-
endTag
Description copied from interface:TagValueListenerEnd the current tag.- Specified by:
endTagin interfaceTagValueListener- Throws:
ParserException- if the tag could not be ended
-
startRecord
Description copied from interface:TagValueListenerA new record is about to start.- Specified by:
startRecordin interfaceTagValueListener- Throws:
ParserException- if the record can not be started
-
endRecord
Description copied from interface:TagValueListenerThe current record has ended.- Specified by:
endRecordin interfaceTagValueListener- Throws:
ParserException- if the record can not be ended
-
value
Description copied from interface:TagValueListenerA value has been seen.- Specified by:
valuein interfaceTagValueListener- Parameters:
ctxt- a TagValueContext that could be used to push a sub-documentvalue- the value Object observed- Throws:
ParserException- if the value could not be processed
-