|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmarquee.xmlrpc.XmlRpcParser
public abstract class XmlRpcParser
An XmlRpcParser converts inbound XML-RPC messages to their Java counterparts through the use of a SAX compliant parser. This is an abstract class that is only concerned with the XML-RPC values contained in a message. Deriving classes supply a handleParsedValue() method that is called when an XML-RPC value has been parsed.
If a class needs to be notified of additional parts of an XML-RPC message, the startElement() or endElement() methods are overridden and extended with checks for the appropriate element. This is the case with XmlRpcClient that wants to know if a fault element is present. Also, the XmlRpcServer wants to know the name of the method for which values are supplied.
Internally, the implementation uses pre-calculated hash values of the element names to allow for switch() constructs when comparing elements supplied by the SAX parser.
Field Summary | |
---|---|
static int |
ARRAY
The hash value of |
static int |
BASE64
The hash value of |
static int |
BOOLEAN
The hash value of |
static int |
DATE
The hash value of |
static int |
DOUBLE
The hash value of |
static int |
I4
The hash value of |
static int |
INT
The hash value of |
static int |
MEMBER
The hash value of |
static int |
NAME
The hash value of |
static int |
STRING
The hash value of |
static int |
STRUCT
The hash value of |
static int |
VALUE
The hash value of |
Constructor Summary | |
---|---|
XmlRpcParser()
|
Method Summary | |
---|---|
void |
characters(char[] data,
int start,
int length)
Called by the SAX driver when character data is available |
void |
endDocument()
|
void |
endElement(java.lang.String name)
Called by SAX driver when a new end-element has been found in the message. |
void |
ignorableWhitespace(char[] ch,
int start,
int length)
|
void |
parse(java.io.InputStream is)
Parses the XML-RPC message contained in the supplied input stream. |
void |
processingInstruction(java.lang.String target,
java.lang.String data)
|
void |
setDocumentLocator(org.xml.sax.Locator locator)
|
static void |
setDriver(java.lang.Class _driver)
Sets the SAX driver to use whan parsing XML-RPC messages and responses. |
static void |
setDriver(java.lang.String driverName)
Sets the SAX driver to use whan parsing XML-RPC messages and responses. |
void |
startDocument()
|
void |
startElement(java.lang.String name,
org.xml.sax.AttributeList attributes)
Called by SAX driver when a new element has been found in the message. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int VALUE
public static final int STRING
public static final int I4
public static final int INT
public static final int BOOLEAN
public static final int DOUBLE
public static final int DATE
public static final int BASE64
public static final int STRUCT
public static final int ARRAY
public static final int MEMBER
public static final int NAME
Constructor Detail |
---|
public XmlRpcParser()
Method Detail |
---|
public static void setDriver(java.lang.String driverName)
driverName
- The fully qualified class name of the SAX driver to use.public static void setDriver(java.lang.Class _driver)
driver
- The SAX driver class.public void parse(java.io.InputStream is) throws java.lang.Exception
is
- The input stream containing the XML-RPC message
java.lang.Exception
- If anything went wrong during the whole parsing phasepublic void startElement(java.lang.String name, org.xml.sax.AttributeList attributes) throws org.xml.sax.SAXException
This implementation uses a switch construct on the hash value of the element name. This increases readability, in my opinion, and perhaps performance as well (only one loop -- in hashCode() -- instead of in every equals() call).
startElement
in interface org.xml.sax.DocumentHandler
See
- SAX documentation
org.xml.sax.SAXException
public void endElement(java.lang.String name) throws org.xml.sax.SAXException
This implementation determines if our current state is that we have a current
value that needs to be processed, and if that value has some character data
in the buffer required to finalize the value. The handleParsedValue() method
is only called if a top-level
Note that struct values are processed when the
endElement
in interface org.xml.sax.DocumentHandler
See
- SAX documentation
org.xml.sax.SAXException
public void characters(char[] data, int start, int length)
This implementation appends the data to an internal string buffer. The method is called for every element, wether characters are included int the element or not. This leads to the buffer being prepended with whitespace until actual character data is aquired. This is removed using the trim() method when the character data is consumed.
characters
in interface org.xml.sax.DocumentHandler
See
- SAX documentationpublic void setDocumentLocator(org.xml.sax.Locator locator)
setDocumentLocator
in interface org.xml.sax.DocumentHandler
public void startDocument()
startDocument
in interface org.xml.sax.DocumentHandler
public void endDocument() throws org.xml.sax.SAXException
endDocument
in interface org.xml.sax.DocumentHandler
org.xml.sax.SAXException
public void ignorableWhitespace(char[] ch, int start, int length) throws org.xml.sax.SAXException
ignorableWhitespace
in interface org.xml.sax.DocumentHandler
org.xml.sax.SAXException
public void processingInstruction(java.lang.String target, java.lang.String data) throws org.xml.sax.SAXException
processingInstruction
in interface org.xml.sax.DocumentHandler
org.xml.sax.SAXException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |