Class State

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<State>

    public class State
    extends java.lang.Object
    implements java.io.Serializable, java.lang.Comparable<State>
    Automaton state.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) boolean accept  
      (package private) int id  
      (package private) static int next_id  
      (package private) int number  
      (package private) static long serialVersionUID  
      (package private) java.util.Set<Transition> transitions  
    • Constructor Summary

      Constructors 
      Constructor Description
      State()
      Constructs a new state.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) void addEpsilon​(State to)  
      void addTransition​(Transition t)
      Adds an outgoing transition.
      int compareTo​(State s)
      Compares this object with the specified object for order.
      boolean equals​(java.lang.Object obj)
      See Object.equals(java.lang.Object).
      (package private) Transition[] getSortedTransitionArray​(boolean to_first)
      Returns transitions sorted by (min, reverse max, to) or (to, min, reverse max)
      java.util.List<Transition> getSortedTransitions​(boolean to_first)
      Returns sorted list of outgoing transitions.
      java.util.Set<Transition> getTransitions()
      Returns the set of outgoing transitions.
      int hashCode()
      See Object.hashCode().
      boolean isAccept()
      Returns acceptance status.
      (package private) void resetTransitions()
      Resets transition set.
      void setAccept​(boolean accept)
      Sets acceptance for this state.
      State step​(char c)
      Performs lookup in transitions, assuming determinism.
      void step​(char c, java.util.Collection<State> dest)
      Performs lookup in transitions, allowing nondeterminism.
      java.lang.String toString()
      Returns string describing this state.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • accept

        boolean accept
      • transitions

        java.util.Set<Transition> transitions
      • number

        int number
      • id

        int id
      • next_id

        static int next_id
    • Constructor Detail

      • State

        public State()
        Constructs a new state. Initially, the new state is a reject state.
    • Method Detail

      • resetTransitions

        final void resetTransitions()
        Resets transition set.
      • getTransitions

        public java.util.Set<Transition> getTransitions()
        Returns the set of outgoing transitions. Subsequent changes are reflected in the automaton.
        Returns:
        transition set
      • addTransition

        public void addTransition​(Transition t)
        Adds an outgoing transition.
        Parameters:
        t - transition
      • setAccept

        public void setAccept​(boolean accept)
        Sets acceptance for this state.
        Parameters:
        accept - if true, this state is an accept state
      • isAccept

        public boolean isAccept()
        Returns acceptance status.
        Returns:
        true is this is an accept state
      • step

        public State step​(char c)
        Performs lookup in transitions, assuming determinism.
        Parameters:
        c - character to look up
        Returns:
        destination state, null if no matching outgoing transition
        See Also:
        step(char, Collection)
      • step

        public void step​(char c,
                         java.util.Collection<State> dest)
        Performs lookup in transitions, allowing nondeterminism.
        Parameters:
        c - character to look up
        dest - collection where destination states are stored
        See Also:
        step(char)
      • addEpsilon

        void addEpsilon​(State to)
      • getSortedTransitionArray

        Transition[] getSortedTransitionArray​(boolean to_first)
        Returns transitions sorted by (min, reverse max, to) or (to, min, reverse max)
      • getSortedTransitions

        public java.util.List<Transition> getSortedTransitions​(boolean to_first)
        Returns sorted list of outgoing transitions.
        Parameters:
        to_first - if true, order by (to, min, reverse max); otherwise (min, reverse max, to)
        Returns:
        transition list
      • toString

        public java.lang.String toString()
        Returns string describing this state. Normally invoked via Automaton.toString().
        Overrides:
        toString in class java.lang.Object
      • compareTo

        public int compareTo​(State s)
        Compares this object with the specified object for order. States are ordered by the time of construction.
        Specified by:
        compareTo in interface java.lang.Comparable<State>
      • equals

        public boolean equals​(java.lang.Object obj)
        See Object.equals(java.lang.Object).
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        See Object.hashCode().
        Overrides:
        hashCode in class java.lang.Object