Package apg
Class Parser.Result
- java.lang.Object
-
- apg.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.
-
-
-
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 istrue
and the entire input string was consumed. Iffalse
the parse was unsuccessful. This could mean that the state wasfalse
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 istrue
- Returns:
- if
true
a phrase was successfully matched, iffalse
no phrase was successfully matched. Note that iftrue
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()
returnsfalse
. If ifgetState()
returnstrue
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 ifgetState()
returnsfalse
. 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 classjava.lang.Object
-
-