Class RunAutomaton

    • Constructor Detail

      • RunAutomaton

        public RunAutomaton​(Automaton a)
        Constructs a new RunAutomaton from a deterministic Automaton. Same as RunAutomaton(a, true).
        Parameters:
        a - an automaton
      • RunAutomaton

        public RunAutomaton​(Automaton a,
                            boolean tableize)
        Constructs a new RunAutomaton from a deterministic Automaton. If the given automaton is not deterministic, it is determinized first.
        Parameters:
        a - an automaton
        tableize - if true, a transition table is created which makes the run method faster in return of a higher memory usage
    • Method Detail

      • toString

        public String toString()
        Returns a string representation of this automaton.
        Overrides:
        toString in class Object
      • getSize

        public int getSize()
        Returns number of states in automaton.
      • isAccept

        public boolean isAccept​(int state)
        Returns acceptance status for given state.
      • getInitialState

        public int getInitialState()
        Returns initial state.
      • getCharIntervals

        public char[] getCharIntervals()
        Returns array of character class interval start points. The array should not be modified by the caller.
      • store

        public void store​(OutputStream stream)
                   throws IOException
        Writes this RunAutomaton to the given stream.
        Parameters:
        stream - output stream for serialized automaton
        Throws:
        IOException - if input/output related exception occurs
      • step

        public int step​(int state,
                        char c)
        Returns the state obtained by reading the given char from the given state. Returns -1 if not obtaining any such state. (If the original Automaton had no dead states, -1 is returned here if and only if a dead state is entered in an equivalent automaton with a total transition function.)
      • run

        public boolean run​(String s)
        Returns true if the given string is accepted by this automaton.
      • run

        public int run​(String s,
                       int offset)
        Returns the length of the longest accepted run of the given string starting at the given offset.
        Parameters:
        s - the string
        offset - offset into s where the run starts
        Returns:
        length of the longest accepted run, -1 if no run is accepted
      • newMatcher

        public AutomatonMatcher newMatcher​(CharSequence s)
        Creates a new automaton matcher for the given input.
        Parameters:
        s - the CharSequence to search
        Returns:
        A new automaton matcher for the given input
      • newMatcher

        public AutomatonMatcher newMatcher​(CharSequence s,
                                           int startOffset,
                                           int endOffset)
        Creates a new automaton matcher for the given input.
        Parameters:
        s - the CharSequence to search
        startOffset - the starting offset of the given character sequence
        endOffset - the ending offset of the given character sequence
        Returns:
        A new automaton matcher for the given input