Package apg
Class Parser.Result
- java.lang.Object
-
- apg.Parser.Result
-
- Enclosing class:
- Parser
public class Parser.Result extends java.lang.ObjectDefines the Parser's results.- See Also:
Parser.parse()
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisplayResult(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.intgetMatchedPhraseLength()Called to get the length of the matched phrase.intgetMaxMatchedPhraseLength()Called to get the maximum matched phrase length.booleangetState()Called to get the final state of the parser.booleansuccess()Called to determine the success of the Parser.java.lang.StringtoString()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
truethe parser state istrueand the entire input string was consumed. Iffalsethe parse was unsuccessful. This could mean that the state wasfalseor 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
truea phrase was successfully matched, iffalseno phrase was successfully matched. Note that iftruethe 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()returnstruethe 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
0even 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:
toStringin classjava.lang.Object
-
-