PageMixer API - 3.1

jp.ne.dti.lares.foozy.pagemixer.parser
Class LoosePageState

java.lang.Object
  |
  +--jp.ne.dti.lares.foozy.pagemixer.parser.LoosePageState
All Implemented Interfaces:
PageState

public class LoosePageState
extends java.lang.Object
implements PageState

Page parser simple implementation.

This implementation only focuses on markup language syntax.

Validity of (1)tag names and (2)data structure are ignored, so this focuses on parsing as many markup language sources as possible, in other words.

This can parse tokens shown below. Some of them are for parsing XHTML, XML, BML and so on.


Constructor Summary
LoosePageState()
          Constructor.
LoosePageState(SymbolSet symbolSet)
          Constructor.
LoosePageState(SymbolSet symbolSet, boolean ignoreCase)
          Constructor.
 
Method Summary
protected  Token createCDATAToken()
           
protected  Token createCommentToken()
           
protected  Token createDeclToken()
           
protected  Token createEndTagToken()
           
protected  Token createPIToken()
           
protected  Token createScriptToken()
           
protected  Token createStartTagToken(boolean empty)
           
protected  Token createTextToken()
           
protected  void ensureTokenName(java.lang.String name)
           
protected  void fixAttrName()
           
protected  void fixAttrValue()
           
protected  void fixAttrValue(char c)
           
protected  void fixDeclValue(char c)
           
protected  java.lang.String fixString()
           
protected  Symbol fixSymbol(int type)
           
protected  void fixTokenName(int type)
           
 Token flush()
          Indicate no more character to parse.
 Token input(char c)
          Parse next character.
protected  void push(char c)
          Push character to queue.
 void reset()
          Reset current status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoosePageState

public LoosePageState()
Constructor.

This is equivalent to LoosePageState(HTMLSymbolSet.SET, true).


LoosePageState

public LoosePageState(SymbolSet symbolSet)
Constructor.

This is equivalent to LoosePageState(symbolSet, true).


LoosePageState

public LoosePageState(SymbolSet symbolSet,
                      boolean ignoreCase)
Constructor.

Name of start/ end tag tokens and attributes are lower-cased to unify as symbol, if you specify true as 'ignoreCase'. If so, you can use both upper-case and lower-case for same names in same page.

ATTENTION: "DOCTYPE" for DocTypeToken and "CDATA" for CDATAToken are upper-cased, and name of processing instructions are parsed case sensitively always.

Parameters:
symbolSet - to resolve name of tokens and attributes
ignoreCase - whether name of tokens are case insensitive or not
Method Detail

push

protected void push(char c)
Push character to queue.
Parameters:
c - character to push
See Also:
fixSymbol(int), fixString()

fixTokenName

protected void fixTokenName(int type)
                     throws PageParseException

fixAttrName

protected void fixAttrName()
                    throws PageParseException

fixSymbol

protected Symbol fixSymbol(int type)
                    throws PageParseException

ensureTokenName

protected void ensureTokenName(java.lang.String name)
                        throws PageParseException

fixString

protected java.lang.String fixString()

createTextToken

protected Token createTextToken()

createStartTagToken

protected Token createStartTagToken(boolean empty)

fixAttrValue

protected void fixAttrValue()

fixAttrValue

protected void fixAttrValue(char c)

createEndTagToken

protected Token createEndTagToken()

createCommentToken

protected Token createCommentToken()

createDeclToken

protected Token createDeclToken()
                         throws PageParseException

fixDeclValue

protected void fixDeclValue(char c)

createScriptToken

protected Token createScriptToken()

createCDATAToken

protected Token createCDATAToken()
                          throws PageParseException

createPIToken

protected Token createPIToken()

input

public Token input(char c)
            throws PageParseException
Description copied from interface: PageState
Parse next character.

Input next character in character sequence of page to parse, and return Token, if it recognizes.

Almost all Token, derived class in fact, consists of so many characters, so this method returns null frequently.

Specified by:
input in interface PageState
Following copied from interface: jp.ne.dti.lares.foozy.pagemixer.parser.PageState
Parameters:
c - next character in page to parse
Returns:
token if recognizes. otherwise null.

flush

public Token flush()
            throws PageParseException
Description copied from interface: PageState
Indicate no more character to parse.

Indicate there is no more character in character sequence of page to parse, and return Token, if it recognizes.

This method works like "input(EOF)".

Specified by:
flush in interface PageState
Following copied from interface: jp.ne.dti.lares.foozy.pagemixer.parser.PageState
Returns:
token if recognizes. otherwise null.

reset

public void reset()
Description copied from interface: PageState
Reset current status.

Reset current status of page state to re-use it.

This must not cause PageParseException though PageState.flush() may cause.

Specified by:
reset in interface PageState

PageMixer API - 3.1