|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.google.gwt.thirdparty.streamhtmlparser.impl.GenericParser
public class GenericParser
An implementation of the Parser interface that is common to both
HtmlParser and JavascriptParser.
Provides methods for parsing input and ensuring that all in-state, entering-a-state and exiting-a-state callbacks are invoked as appropriate.
This class started as abstract but it was found better for testing to make it instantiatable so that the parsing logic can be tested with dummy state transitions.
| Field Summary | |
|---|---|
protected int |
columnNumber
|
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState |
currentState
|
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState |
initialState
|
protected java.util.Map<com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState,ExternalState> |
intToExtStateTable
|
protected int |
lineNumber
|
protected com.google.gwt.thirdparty.streamhtmlparser.impl.ParserStateTable |
parserStateTable
|
| Fields inherited from interface com.google.gwt.thirdparty.streamhtmlparser.Parser |
|---|
STATE_ERROR |
| Constructor Summary | |
|---|---|
protected |
GenericParser(GenericParser aGenericParser)
Constructs a generic parser that is an exact copy of the one given. |
protected |
GenericParser(com.google.gwt.thirdparty.streamhtmlparser.impl.ParserStateTable parserStateTable,
java.util.Map<com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState,ExternalState> intToExtStateTable,
com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState initialState)
|
| Method Summary | |
|---|---|
int |
getColumnNumber()
Returns the current column number. |
int |
getLineNumber()
Returns the current line number. |
ExternalState |
getState()
Return the current state of the parser. |
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState |
handleEnterState(com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState currentState,
com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState expectedNextState,
char input)
Invoked when the parser enters a new state. |
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState |
handleExitState(com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState currentState,
com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState expectedNextState,
char input)
Invoked when the parser exits a state. |
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState |
handleInState(com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState currentState,
char input)
Invoked for each character read when no state change occured. |
void |
parse(char input)
Main loop for parsing of input. |
void |
parse(java.lang.String input)
Tell the parser to process the provided String. |
protected void |
record(char input)
Perform some processing on the given character. |
void |
reset()
Reset the parser back to its initial default state. |
void |
setColumnNumber(int columnNumber)
Sets the current column number which is returned during error messages. |
void |
setLineNumber(int lineNumber)
Sets the current line number which is returned during error messages. |
protected void |
setNextState(com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState nextState)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final com.google.gwt.thirdparty.streamhtmlparser.impl.ParserStateTable parserStateTable
protected final java.util.Map<com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState,ExternalState> intToExtStateTable
protected final com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState initialState
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState currentState
protected int lineNumber
protected int columnNumber
| Constructor Detail |
|---|
protected GenericParser(com.google.gwt.thirdparty.streamhtmlparser.impl.ParserStateTable parserStateTable,
java.util.Map<com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState,ExternalState> intToExtStateTable,
com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState initialState)
protected GenericParser(GenericParser aGenericParser)
aGenericParser - the GenericParser to copy| Method Detail |
|---|
public void parse(java.lang.String input)
throws ParseException
String. This is just a
convenience method that wraps over Parser.parse(char).
parse in interface Parserinput - the String to parse
ParseException - if an unrecoverable error occurred during parsing
public void parse(char input)
throws ParseException
Absent any callbacks defined, this function simply determines the
next state to switch to based on the ParserStateTable which is
derived from a state-machine configuration file in the original C++ parser.
However some states have specific callbacks defined which when
receiving specific characters may decide to overwrite the next state to
go to. Hence the next state is a function both of the main state table
in ParserStateTable as well as specific run-time information
from the callback functions.
Also note that the callbacks are called in a proper sequence, first the exit-state one then the enter-state one and finally the in-state one. Changing the order may result in a functional change.
parse in interface Parserinput - the input character to parse (process)
ParseException - if an unrecoverable error occurred during parsingpublic ExternalState getState()
getState in interface Parserpublic void reset()
reset in interface Parserpublic void setLineNumber(int lineNumber)
setLineNumber in interface ParserlineNumber - the line number to set in the parserpublic int getLineNumber()
getLineNumber in interface Parserpublic void setColumnNumber(int columnNumber)
setColumnNumber in interface ParsercolumnNumber - the column number to set in the parserpublic int getColumnNumber()
getColumnNumber in interface Parser
protected void setNextState(com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState nextState)
throws ParseException
ParseException
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState handleEnterState(com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState currentState,
com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState expectedNextState,
char input)
throws ParseException
currentState - the current state of the parserexpectedNextState - the next state according to the
state table definitioninput - the last character parsed
expectedNextState provided
ParseException - if an unrecoverable error occurred during parsing
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState handleExitState(com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState currentState,
com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState expectedNextState,
char input)
throws ParseException
currentState - the current state of the parserexpectedNextState - the next state according to the
state table definitioninput - the last character parsed
expectedNextState provided
ParseException - if an unrecoverable error occurred during parsing
protected com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState handleInState(com.google.gwt.thirdparty.streamhtmlparser.impl.InternalState currentState,
char input)
throws ParseException
currentState - the current state of the parserinput - the last character parsed
expectedNextState provided
ParseException - if an unrecoverable error occurred during parsingprotected void record(char input)
input - the input character to operate on
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||