com.google.streamhtmlparser
Interface Parser

All Known Subinterfaces:
HtmlParser, JavascriptParser
All Known Implementing Classes:
GenericParser, HtmlParserImpl, JavascriptParserImpl

public interface Parser

Defines essential functionality that every parser we implement will support. This is then extended for HTML and Javascript parsing.

The typical caller is a Template System and will usually ask us to parse either a character at a time or a fragment of a template at a time, stopping only when it needs to determine the state of the parser for escaping purposes.

We will later add methods to save and restore the full state of the parser to better support conditional processing.


Field Summary
static ExternalState STATE_ERROR
           
 
Method Summary
 int getColumnNumber()
          Returns the current column number.
 int getLineNumber()
          Returns the current line number.
 ExternalState getState()
          Returns the current state of the parser.
 void parse(char input)
          Tell the parser to process the provided char.
 void parse(String input)
          Tell the parser to process the provided String.
 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.
 

Field Detail

STATE_ERROR

static final ExternalState STATE_ERROR
Method Detail

parse

void parse(char input)
           throws ParseException
Tell the parser to process the provided char. Throws exception on an unrecoverable parsing error.

Parameters:
input - the character read
Throws:
ParseException - if an unrecoverable error occurred during parsing

parse

void parse(String input)
           throws ParseException
Tell the parser to process the provided String. Throws exception on an unrecoverable parsing error.

Parameters:
input - the String to parse
Throws:
ParseException - if an unrecoverable error occurred during parsing

reset

void reset()
Reset the parser back to its initial default state.


getState

ExternalState getState()
Returns the current state of the parser. May be STATE_ERROR if the parser encountered an error. Such an error may be recoverable and the caller may want to continue parsing until parse(String) returns false.

Returns:
current state of the parser

setLineNumber

void setLineNumber(int lineNumber)
Sets the current line number which is returned during error messages.

Parameters:
lineNumber - the line number to set in the parser

getLineNumber

int getLineNumber()
Returns the current line number.


setColumnNumber

void setColumnNumber(int columnNumber)
Sets the current column number which is returned during error messages.

Parameters:
columnNumber - the column number to set in the parser

getColumnNumber

int getColumnNumber()
Returns the current column number.



Copyright © 2010-2012 Google. All Rights Reserved.