public class StateMachine extends Object implements 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.
Modifier and Type | Class and Description |
---|---|
class |
StateMachine.BasicState
Implementation of a State in a state machine
|
static interface |
StateMachine.ExitNotification
Interface implemented by State listeners that
want notification when a transition leaves the State.
|
class |
StateMachine.SimpleStateListener
a basic listener for a State.
|
static interface |
StateMachine.State
Interface for a State within this StateMachine
|
class |
StateMachine.Transition
class to represent a State Transition
|
class |
StateMachine.TransitionTable
Table of Transition destination States
and their corresponding Tags.
|
Modifier and Type | Field and Description |
---|---|
protected TagValueListener |
delegate |
protected static String |
END_RECORD_TAG |
protected static String |
END_TAG |
protected static String |
MAGICAL_STATE |
protected static String |
START_RECORD_TAG |
Constructor and Description |
---|
StateMachine() |
Modifier and Type | Method and Description |
---|---|
StateMachine.BasicState |
createState(String label) |
StateMachine.TransitionTable |
createTransitionTable() |
void |
endRecord()
The current record has ended.
|
void |
endTag()
End the current tag.
|
TagValueListener |
getDelegate()
get listener to which all calls will be delegated
|
StateMachine.BasicState |
getMagicalState() |
StateMachine.State |
getState(String label) |
void |
setDelegate(TagValueListener delegate)
TagValueWrapper interface
|
void |
startRecord()
A new record is about to start.
|
void |
startTag(Object tag)
TagValueListener interface
|
void |
value(TagValueContext ctxt,
Object value)
A value has been seen.
|
protected static final String START_RECORD_TAG
protected static final String END_RECORD_TAG
protected static final String END_TAG
protected static final String MAGICAL_STATE
protected TagValueListener delegate
public StateMachine()
public StateMachine.BasicState getMagicalState()
public StateMachine.BasicState createState(String label)
public StateMachine.State getState(String label)
public StateMachine.TransitionTable createTransitionTable()
public void setDelegate(TagValueListener delegate)
setDelegate
in interface TagValueWrapper
public TagValueListener getDelegate()
TagValueWrapper
getDelegate
in interface TagValueWrapper
public void startTag(Object tag) throws ParserException
startTag
in interface TagValueListener
tag
- the Object representing the new tagParserException
- if the tag could not be startedpublic void endTag() throws ParserException
TagValueListener
endTag
in interface TagValueListener
ParserException
- if the tag could not be endedpublic void startRecord() throws ParserException
TagValueListener
startRecord
in interface TagValueListener
ParserException
- if the record can not be startedpublic void endRecord() throws ParserException
TagValueListener
endRecord
in interface TagValueListener
ParserException
- if the record can not be endedpublic void value(TagValueContext ctxt, Object value) throws ParserException
TagValueListener
value
in interface TagValueListener
ctxt
- a TagValueContext that could be used to push a sub-documentvalue
- the value Object observedParserException
- if the value could not be processedCopyright © 2020 BioJava. All rights reserved.