|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--rabbit.html.HTMLParser
This is a class that is used to parse a block of HTML code into separate tokens. This parser uses a recursive descent approach.
Field Summary | |
protected HTMLBlock |
block
The block we have. |
static int |
COMMENT
A HTML comment "<!-- some text -->" |
static int |
DOUBLEQUOTE
This is the character '"' |
static int |
DQSTRING
This is a Double Quoted String a "string" |
static int |
END
This indicates the end of a block. |
static int |
EQUALS
Equals '=' |
protected int |
index
Index of the parse. |
protected int |
lastTagStart
The last tag started here. |
protected int |
length
The size of the data to parse. |
static int |
LT
Less Than '<' |
static int |
MT
More Than '>' |
protected int |
nextToken
The type of the next token. |
protected byte[] |
pagepart
The actual data to parse. |
static int |
SINGELQUOTE
This is the character ''' |
static int |
SQSTRING
This is a Single Quoted String a 'string' |
static int |
START
This indicates the start of a block. |
static int |
STRING
This indicate a String value was found. |
protected int |
stringLength
the current start of string. |
protected java.lang.String |
stringValue
The current value as a String. |
protected boolean |
tagmode
True if were in a Tag, false otherwise. |
protected int |
tagStart
The current tag started here. |
static int |
UNKNOWN
Unknown token. |
Constructor Summary | |
HTMLParser()
Create a new HTMLParser |
|
HTMLParser(byte[] page)
Create a new HTMLParser for the given page. |
Method Summary | |
protected void |
arglist(Tag tag)
Scan an argument list from the block. |
protected java.lang.String |
getTokenString(int token)
Get a String describing the token. |
protected boolean |
isComment()
Is this tag a comment? |
static void |
main(java.lang.String[] args)
Simple self test function. |
protected int |
match(int token)
Match the token with next token and scan the (new)next token. |
protected void |
page()
Scan a page from the block. |
HTMLBlock |
parse()
Get a HTMLBlock from the pagepart given. |
protected int |
scanComment()
Scan a comment from the block, that is the string up to and including "-->". |
protected int |
scanQuotedString()
Scan a quoted tring from the block. |
protected int |
scanString()
Scan a String from the block. |
void |
setText(byte[] page)
Set the data block to parse. |
void |
setText(byte[] page,
int length)
Set the data block to parse. |
void |
setText(java.lang.String page)
Set the data to parse. |
protected Tag |
tag(int ltagStart)
Scan a tag from the block. |
protected java.lang.String |
value()
Scan a value from the block. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected byte[] pagepart
protected int length
protected int nextToken
protected int index
protected int tagStart
protected java.lang.String stringValue
protected int stringLength
protected boolean tagmode
protected int lastTagStart
protected HTMLBlock block
public static final int START
public static final int STRING
public static final int SQSTRING
public static final int DQSTRING
public static final int SINGELQUOTE
public static final int DOUBLEQUOTE
public static final int LT
public static final int MT
public static final int EQUALS
public static final int COMMENT
public static final int END
public static final int UNKNOWN
Constructor Detail |
public HTMLParser()
public HTMLParser(byte[] page)
page
- the block to parse.Method Detail |
public void setText(byte[] page)
page
- the block to parse.public void setText(byte[] page, int length)
page
- the block to parse.length
- the length of the data.public void setText(java.lang.String page)
page
- the block to parse.protected java.lang.String getTokenString(int token)
token
- the token type (like STRING).
protected int scanString() throws HTMLParseException
HTMLParseException
- if an error occurs.protected int scanQuotedString() throws HTMLParseException
HTMLParseException
- if an error occurs.protected boolean isComment()
protected int scanComment() throws HTMLParseException
HTMLParseException
protected int match(int token) throws HTMLParseException
token
- the token to match.
HTMLParseException
protected java.lang.String value() throws HTMLParseException
HTMLParseException
protected void arglist(Tag tag) throws HTMLParseException
tag
- the Tag that have the arguments.
HTMLParseException
protected Tag tag(int ltagStart) throws HTMLParseException
ltagStart
- the index of the last tag started.
HTMLParseException
protected void page() throws HTMLParseException
HTMLParseException
public HTMLBlock parse() throws HTMLParseException
HTMLParseException
public static void main(java.lang.String[] args)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |