Package util

Class State

java.lang.Object
util.State

public abstract class State extends Object
Defines the abstract state of a Deterministic Finite State Automaton (DFSA). It is recommended that the set of states defining a DFSA are defined as static classes within a container class for proper encapsulation.
Author:
Krish Pillai
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    State(String name)
    State constructor takes a label.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
    int
     
    boolean
    Indicates is this is a final state.
    boolean
    Indicates if this is an initial state
    abstract void
    The method that will be invoked when a state change occurs.
    void
    Identifies this state as the final state.
    void
    Identifies this state as the initial state.
    String representation of the State.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • State

      public State(String name)
      State constructor takes a label. The label is used for checking congruence of state objects.
      Parameters:
      name - String defining the name of the state e.g. {S0, S1, S2, ...}
  • Method Details

    • setInitialState

      public void setInitialState()
      Identifies this state as the initial state. There can be only one initial state.
    • setFinalState

      public void setFinalState()
      Identifies this state as the final state. There can be a set of final states.
    • isInitialState

      public boolean isInitialState()
      Indicates if this is an initial state
      Returns:
      true or false
    • isFinalState

      public boolean isFinalState()
      Indicates is this is a final state.
      Returns:
      true or false
    • manage

      public abstract void manage()
      The method that will be invoked when a state change occurs. This method should be overridden by the concrete state class.
    • toString

      public String toString()
      String representation of the State. Only the name field is considered.
      Overrides:
      toString in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object