net.sf.vex.dom
Class DFAState

java.lang.Object
  |
  +--net.sf.vex.dom.DFAState

public class DFAState
extends java.lang.Object

Represents a state in a deterministic finite automaton (DFA). A DFA can be thought of as a directed graph, where each arc in the graph represents a transition on an input symbol to a new state (i.e. a node in the graph.) The DFA has a start state and one or more accepting states. The DFA represents a grammar. If a sequence of input symbols drives the DFA from the start state to one of the accepting states, the sequence is a valid sentence in the grammar represented by the DFA.

Within VEX, we use a DFA to validate the sequence of children of a given element. A DFA is constructed for each element declaration in the DTD.


Constructor Summary
DFAState()
          Class constructor.
 
Method Summary
 void addTransition(java.lang.Object symbol, DFAState target)
          Adds an outgoing transition to the state.
 DFAState getNextState(java.lang.Object symbol)
          Returns the next state given the given input symbol, or null if there are no outgoing transitions corresponding to the given symbol.
 DFAState getState(java.util.List sequence)
          Return the state obtained by traversing the given list of symbols.
 java.util.Set getValidSymbols()
          Returns the set of symbols that are valid for this state.
 boolean isAccepting()
          Returns true if this is an accepting state of the DFA.
 void setAccepting(boolean accepting)
          Sets the value of the accepting property.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DFAState

public DFAState()
Class constructor.

Method Detail

getState

public DFAState getState(java.util.List sequence)
Return the state obtained by traversing the given list of symbols. Returns null if the given sequence does not lead to a state in the DFA.

Parameters:
sequence - Sequence of symbols to use.

addTransition

public void addTransition(java.lang.Object symbol,
                          DFAState target)
Adds an outgoing transition to the state.

Parameters:
symbol - Symbol that initiates the transition.
target - State to which the transition leads.

getValidSymbols

public java.util.Set getValidSymbols()
Returns the set of symbols that are valid for this state.


isAccepting

public boolean isAccepting()
Returns true if this is an accepting state of the DFA.


getNextState

public DFAState getNextState(java.lang.Object symbol)
Returns the next state given the given input symbol, or null if there are no outgoing transitions corresponding to the given symbol.

Parameters:
symbol - input symbol

setAccepting

public void setAccepting(boolean accepting)
Sets the value of the accepting property.

Parameters:
accepting - true if this an accepting state of the DFA.