|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.cometway.xml.XMLParser
public class XMLParser
XMLParser. This class parses min xml into one of 4 kinds of tokens: XML.EMPTY_ELEMENT_TAG, XML.START_TAG, XML.END_TAG, and XML.ELEMENT_CONTENT. The XMLParser is instantiated with a source and characters will be read from this source via a Stream. Successive calls to the nextToken() method will return the next parsed tokens from the stream. Some options can be set, to ignore whitespace or to decode xml 1.0 escape codes in the XML.ELEMENT_CONTENT tokens. A EOFException will be thrown if the stream has reached the end.
XMLToken| Field Summary | |
|---|---|
protected java.io.InputStream |
dataSource
|
protected boolean |
decodeEscapeCodes
Setting this field to true will cause the parser to decode XML 1.0 escape codes in the text |
protected boolean |
ignoreWhitespace
Setting this value to true will cause the parse to remove the whitespace it finds around tags and text. |
| Constructor Summary | |
|---|---|
XMLParser(java.io.InputStream source)
Parse XML from an input stream |
|
XMLParser(java.lang.String source)
Parse XML from a String. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the InputStream used by the parser. |
XMLToken |
nextElementContent()
Returns the next token if it's type is XML.ELEMENT_CONTENT. |
XMLToken |
nextEmptyElementTag()
Returns the next token if it's type is XML.EMPTY_ELEMENT_TAG. |
XMLToken |
nextEndTag()
Returns the next token if it's type is XML.END_TAG. |
XMLToken |
nextStartTag()
Returns the next token if it's type is XML.START_TAG. |
XMLToken |
nextToken()
This method returns the next parsed token from the source Stream. |
XMLToken |
nextToken(java.lang.String data)
Returns the next token if it matches the specified data. |
void |
setDecodeEscapeCodes(boolean decodeEscapeCodes)
The parser will decode escape codes within element content when this option is set to true (default is true). |
void |
setIgnoreWhitespace(boolean ignoreWhitespace)
The parser will ignore whitespace before and after element content when this option is set to true (default is true). |
void |
setLength(int length)
This sets how many characters is to be read from the input source. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean ignoreWhitespace
protected boolean decodeEscapeCodes
protected java.io.InputStream dataSource
| Constructor Detail |
|---|
public XMLParser(java.lang.String source)
public XMLParser(java.io.InputStream source)
| Method Detail |
|---|
public void close()
throws XMLParserException
XMLParserExceptionpublic void setIgnoreWhitespace(boolean ignoreWhitespace)
public void setDecodeEscapeCodes(boolean decodeEscapeCodes)
public void setLength(int length)
public XMLToken nextToken()
throws XMLParserException
XMLParserException
public XMLToken nextToken(java.lang.String data)
throws XMLParserException
XMLParserException - if it does not match the specified data or there is a problem.
public XMLToken nextStartTag()
throws XMLParserException
XMLParserException - if it's type is not XML.START_TAG or there is a problem.
public XMLToken nextEndTag()
throws XMLParserException
XMLParserException - if it's type is not XML.END_TAG or there is a problem.
public XMLToken nextElementContent()
throws XMLParserException
XMLParserException - if it's type is not XML.ELEMENT_CONTENT or there is a problem.
public XMLToken nextEmptyElementTag()
throws XMLParserException
XMLParserException - if it's type is not XML.EMPTY_ELEMENT_TAG or there is a problem.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||