Package org.apache.lucene.util.automaton
Class Automaton.Builder
java.lang.Object
org.apache.lucene.util.automaton.Automaton.Builder
- Enclosing class:
Automaton
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEpsilon(int source, int dest) Add a [virtual] epsilon transition between source and dest.voidaddTransition(int source, int dest, int label) Add a new transition with min = max = label.voidaddTransition(int source, int dest, int min, int max) Add a new transition with the specified source, dest, min, max.voidCopies over all states/transitions from other.voidcopyStates(Automaton other) Copies over all states from other.intCreate a new state.finish()Compiles all added states and transitions into a newAutomatonand returns it.intHow many states this automaton has.booleanisAccept(int state) Returns true if this state is an accept state.voidsetAccept(int state, boolean accept) Set or clear this state as an accept state.
-
Constructor Details
-
Builder
public Builder()Default constructor, pre-allocating for 16 states and transitions. -
Builder
public Builder(int numStates, int numTransitions) Constructor which creates a builder with enough space for the given number of states and transitions.- Parameters:
numStates- Number of states.numTransitions- Number of transitions.
-
-
Method Details
-
addTransition
public void addTransition(int source, int dest, int label) Add a new transition with min = max = label. -
addTransition
public void addTransition(int source, int dest, int min, int max) Add a new transition with the specified source, dest, min, max. -
addEpsilon
public void addEpsilon(int source, int dest) Add a [virtual] epsilon transition between source and dest. Dest state must already have all transitions added because this method simply copies those same transitions over to source. -
finish
Compiles all added states and transitions into a newAutomatonand returns it. -
createState
public int createState()Create a new state. -
setAccept
public void setAccept(int state, boolean accept) Set or clear this state as an accept state. -
isAccept
public boolean isAccept(int state) Returns true if this state is an accept state. -
getNumStates
public int getNumStates()How many states this automaton has. -
copy
Copies over all states/transitions from other. -
copyStates
Copies over all states from other.
-