|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.lwuit.xml.XMLParser
public class XMLParser
The parser class is used to parse an XML document into a DOM object (Element).
Constructor Summary | |
---|---|
XMLParser()
Constructs the XMLParser |
Method Summary | |
---|---|
void |
addCharEntitiesRange(java.lang.String[] symbols,
int startcode)
Adds the given symbols array to the user defined char entities table with the startcode provided as the code of the first string, startcode+1 for the second etc. |
void |
addCharEntity(java.lang.String symbol,
int code)
Adds the given symbol and code to the user defined char entities table http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references |
protected void |
attribute(java.lang.String tag,
java.lang.String attributeName,
java.lang.String value)
Invoked for every attribute value of the givne tag This callback method is invoked only on the eventParser. |
protected java.lang.String |
convertCharEntity(java.lang.String charEntity)
Converts a char entity to the matching character. |
protected Element |
createNewElement(java.lang.String name)
Creates a new element. |
protected Element |
createNewTextElement(java.lang.String text)
Creates a new text element. |
protected void |
endTag(java.lang.String tag)
Invoked when a tag ends This callback method is invoked only on the eventParser. |
void |
eventParser(java.io.Reader r)
The event parser requires deriving this class and overriding callback methods to work effectively. |
protected java.lang.String |
getSupportedStandardName()
Returns a string identifying the document type this parser supports. |
protected boolean |
isEmptyTag(java.lang.String tagName)
Checks whether the specified tag is an empty tag |
protected boolean |
isSupported(Element element)
Returns true if this element is supported, false otherwise In XMLParser this always returns true, but subclasses can determine if an element is supported in their context according to its name etc. |
protected boolean |
isWhiteSpace(char ch)
Checks if the specified character is a white space or not. |
protected void |
notifyError(int errorId,
java.lang.String tag,
java.lang.String attribute,
java.lang.String value,
java.lang.String description)
A utility method used to notify an error to the ParserCallback and throw an IllegalArgumentException if parsingError returned false |
Element |
parse(java.io.Reader is)
This is the entry point for parsing a document and the only non-private member method in this class |
protected Element |
parseCommentOrXMLDeclaration(java.io.Reader is,
java.lang.String endTag)
This utility method is used to parse comments and XML declarations in the XML. |
protected Element |
parseTag(java.io.Reader is)
This method collects the tag name and all of its attributes. |
protected void |
parseTagContent(Element element,
java.io.Reader is)
Parses tags content, accumulating text and child elements . |
void |
setIncludeWhitespacesBetweenTags(boolean include)
|
void |
setParserCallback(ParserCallback parserCallback)
Sets the specified callback to serve as the callback for parsing errors |
protected boolean |
shouldEvaluate(Element element)
Checks if this element should be evaluated by the parser This can be overriden by subclasses to skip certain elements |
protected boolean |
startTag(java.lang.String tag)
Invoked when a tag is opened, this method should return true to process the tag or return false to skip the tag. |
protected void |
textElement(java.lang.String text)
Invoked when the event parser encounters a text element. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XMLParser()
Method Detail |
---|
protected java.lang.String getSupportedStandardName()
public void addCharEntity(java.lang.String symbol, int code)
symbol
- The symbol to addcode
- The symbol's codepublic void addCharEntitiesRange(java.lang.String[] symbols, int startcode)
symbols
- The symbols to addstartcode
- The symbol's codeprotected java.lang.String convertCharEntity(java.lang.String charEntity)
charEntity
- The char entity to convert
public Element parse(java.io.Reader is)
is
- The InputStream containing the XML
protected Element createNewElement(java.lang.String name)
name
- The new element's name
protected Element createNewTextElement(java.lang.String text)
text
- The new element's text
public void setIncludeWhitespacesBetweenTags(boolean include)
public void eventParser(java.io.Reader r) throws java.io.IOException
r
- the reader from which the data should be parsed
java.io.IOException
- if an exception is thrown by the readerprotected void textElement(java.lang.String text)
text
- the text encounteredprotected boolean startTag(java.lang.String tag)
tag
- the tag name
protected void endTag(java.lang.String tag)
tag
- the tag nameprotected void attribute(java.lang.String tag, java.lang.String attributeName, java.lang.String value)
tag
- the tag nameprotected void parseTagContent(Element element, java.io.Reader is) throws java.io.IOException
element
- The current parent elementis
- The InputStream containing the XML
java.io.IOException
- if an I/O error in the stream is encounteredprotected boolean isWhiteSpace(char ch)
ch
- The character to check
protected Element parseTag(java.io.Reader is) throws java.io.IOException
is
- The InputStream containing the XML
java.io.IOException
- if an I/O error in the stream is encounteredprotected Element parseCommentOrXMLDeclaration(java.io.Reader is, java.lang.String endTag) throws java.io.IOException
is
- The inputstreamendTag
- The endtag to look for
java.io.IOException
protected boolean isEmptyTag(java.lang.String tagName)
tagName
- The tag name to check
protected void notifyError(int errorId, java.lang.String tag, java.lang.String attribute, java.lang.String value, java.lang.String description)
errorId
- The error ID, one of the ERROR_* constants in ParserCallbacktag
- The tag in which the error occured (Can be null for non-tag related errors)attribute
- The attribute in which the error occured (Can be null for non-attribute related errors)value
- The value in which the error occured (Can be null for non-value related errors)description
- A verbal description of the error
java.lang.IllegalArgumentException
- If the parser callback returned false on this errorprotected boolean isSupported(Element element)
element
- The element to check
protected boolean shouldEvaluate(Element element)
element
- The element to check
public void setParserCallback(ParserCallback parserCallback)
parserCallback
- The callback to use for parsing errors
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |