Package apg

Class Parser.Result

  • Enclosing class:
    Parser

    public class Parser.Result
    extends java.lang.Object
    Defines the Parser's results.
    See Also:
    Parser.parse()
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void displayResult​(java.io.PrintStream out)
      Displays the Parser's results on the output device.
      char[] getInputString()
      Called to get a copy of the string that was just parsed.
      int getMatchedPhraseLength()
      Called to get the length of the matched phrase.
      int getMaxMatchedPhraseLength()
      Called to get the maximum matched phrase length.
      boolean getState()
      Called to get the final state of the parser.
      boolean success()
      Called to determine the success of the Parser.
      java.lang.String toString()
      Returns a string describing the Parser's results.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getInputString

        public char[] getInputString()
        Called to get a copy of the string that was just parsed.
        Returns:
        a clone of the parsed string.
      • success

        public boolean success()
        Called to determine the success of the Parser.
        Returns:
        if true the parser state is true and the entire input string was consumed. If false the parse was unsuccessful. This could mean that the state was false or that the entire input string was not consumed or both.
      • getState

        public boolean getState()
        Called to get the final state of the parser. Note that if the matched phrase is not the entire input string the parse will not succeed even though the state is true
        Returns:
        if true a phrase was successfully matched, if false no phrase was successfully matched. Note that if true the phrase matched may not be the entire input string.
      • getMatchedPhraseLength

        public int getMatchedPhraseLength()
        Called to get the length of the matched phrase.
        Returns:
        length of the matched phrase. This will be zero if getState() returns false. If if getState() returns true the length returned may or may not be the full length of the input string.
      • getMaxMatchedPhraseLength

        public int getMaxMatchedPhraseLength()
        Called to get the maximum matched phrase length.
        Returns:
        the maximum phrase length matched during the parse. May be 0 even if getState() returns false. Can be useful in locating the point at which the Parser failed.
      • displayResult

        public void displayResult​(java.io.PrintStream out)
        Displays the Parser's results on the output device.
        Parameters:
        out - the PrintStream to display the results on.
      • toString

        public java.lang.String toString()
        Returns a string describing the Parser's results.
        Overrides:
        toString in class java.lang.Object