org.apache.xmlrpc
Class XmlRpc

java.lang.Object
  extended byorg.xml.sax.HandlerBase
      extended byorg.apache.xmlrpc.XmlRpc
All Implemented Interfaces:
org.xml.sax.DocumentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler
Direct Known Subclasses:
XmlRpcClient.Worker, XmlRpcRequestProcessor

public abstract class XmlRpc
extends org.xml.sax.HandlerBase

This abstract base class provides basic capabilities for XML-RPC, like parsing of parameters or encoding Java objects into XML-RPC format. Any XML parser with a SAX interface can be used.

XmlRpcServer and XmlRpcClient are the classes that actually implement an XML-RPC server and client.

Version:
$Id: XmlRpc.java,v 1.35 2002/11/21 01:28:16 dlr Exp $
Author:
Hannes Wallnoefer, Daniel Rall, Andrew Evers
See Also:
XmlRpcServer, XmlRpcClient

Nested Class Summary
(package private)  class XmlRpc.Value
          This represents a XML-RPC value parsed from the request.
 
Field Summary
(package private) static int ARRAY
           
(package private) static int BASE64
           
(package private) static int BOOLEAN
           
(package private)  java.lang.StringBuffer cdata
          Used to collect character data (CDATA) of parameter values.
(package private)  XmlRpc.Value currentValue
           
(package private) static int DATE
           
static boolean debug
          Whether to log debugging output.
private static java.lang.String DEFAULT_PARSER
          The default parser to use (MinML).
(package private) static int DOUBLE
           
(package private) static java.lang.String encoding
          Java's name for the encoding we're using.
(package private)  int errorLevel
           
(package private)  java.lang.String errorMsg
           
(package private) static int FATAL
           
(package private) static int INTEGER
           
(package private) static boolean keepalive
          Wheter to use HTTP Keep-Alive headers.
private static int maxThreads
          The maximum number of threads which can be used concurrently.
(package private)  java.lang.String methodName
           
(package private) static int NONE
           
private static java.lang.Class parserClass
          The class name of SAX parser to use.
(package private)  boolean readCdata
           
(package private) static int RECOVERABLE
           
private static java.util.Hashtable saxDrivers
           
(package private) static int STRING
           
(package private) static int STRUCT
           
private  TypeFactory typeFactory
           
(package private) static java.lang.String[] types
          The list of valid XML elements used for RPC.
(package private)  java.util.Stack values
           
static java.lang.String version
          The version string used in HTTP communication.
 
Constructor Summary
protected XmlRpc()
          Creates a new instance with the TypeFactory set to an instance of the class named by the org.apache.xmlrpc.TypeFactory System property.
protected XmlRpc(java.lang.String typeFactory)
          Creates a new instance with the specified TypeFactory.
 
Method Summary
 void characters(char[] ch, int start, int length)
          Method called by SAX driver.
private  TypeFactory createTypeFactory(java.lang.Class typeFactory)
          Creates a new instance of the specified TypeFactory.
 void endElement(java.lang.String name)
          Method called by SAX driver.
 void error(org.xml.sax.SAXParseException e)
          Receive notification of a recoverable parser error.
 void fatalError(org.xml.sax.SAXParseException e)
          Report a fatal XML parsing error.
 java.lang.String getEncoding()
          Return the encoding, transforming to the canonical name if possible.
static boolean getKeepAlive()
          get current HTTP keepalive mode.
static int getMaxThreads()
          Gets the maximum number of threads used at any given moment.
protected abstract  void objectParsed(java.lang.Object what)
          This method is called when a root level object has been parsed.
(package private)  void parse(java.io.InputStream is)
          Parse the input stream.
static void setDebug(boolean val)
          Switch debugging output on/off.
static void setDriver(java.lang.Class driver)
          Set the SAX Parser to be used by directly passing the Class object.
static void setDriver(java.lang.String driver)
          Set the SAX Parser to be used.
static void setEncoding(java.lang.String enc)
          Set the encoding of the XML.
static void setKeepAlive(boolean val)
          Switch HTTP keepalive on/off.
static void setMaxThreads(int maxThreads)
          Sets the maximum number of threads used at any given moment.
 void startElement(java.lang.String name, org.xml.sax.AttributeList atts)
          Method called by SAX driver.
 
Methods inherited from class org.xml.sax.HandlerBase
endDocument, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, startDocument, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static final java.lang.String version
The version string used in HTTP communication.

See Also:
Constant Field Values

DEFAULT_PARSER

private static final java.lang.String DEFAULT_PARSER
The default parser to use (MinML).


maxThreads

private static int maxThreads
The maximum number of threads which can be used concurrently.


methodName

java.lang.String methodName

parserClass

private static java.lang.Class parserClass
The class name of SAX parser to use.


saxDrivers

private static java.util.Hashtable saxDrivers

values

java.util.Stack values

currentValue

XmlRpc.Value currentValue

cdata

java.lang.StringBuffer cdata
Used to collect character data (CDATA) of parameter values.


readCdata

boolean readCdata

STRING

static final int STRING
See Also:
Constant Field Values

INTEGER

static final int INTEGER
See Also:
Constant Field Values

BOOLEAN

static final int BOOLEAN
See Also:
Constant Field Values

DOUBLE

static final int DOUBLE
See Also:
Constant Field Values

DATE

static final int DATE
See Also:
Constant Field Values

BASE64

static final int BASE64
See Also:
Constant Field Values

STRUCT

static final int STRUCT
See Also:
Constant Field Values

ARRAY

static final int ARRAY
See Also:
Constant Field Values

errorLevel

int errorLevel

errorMsg

java.lang.String errorMsg

NONE

static final int NONE
See Also:
Constant Field Values

RECOVERABLE

static final int RECOVERABLE
See Also:
Constant Field Values

FATAL

static final int FATAL
See Also:
Constant Field Values

keepalive

static boolean keepalive
Wheter to use HTTP Keep-Alive headers.


debug

public static boolean debug
Whether to log debugging output.


types

static final java.lang.String[] types
The list of valid XML elements used for RPC.


encoding

static java.lang.String encoding
Java's name for the encoding we're using. Defaults to ISO8859_1.


typeFactory

private TypeFactory typeFactory
Constructor Detail

XmlRpc

protected XmlRpc()
Creates a new instance with the TypeFactory set to an instance of the class named by the org.apache.xmlrpc.TypeFactory System property. If property not set or class is unavailable, uses the default.


XmlRpc

protected XmlRpc(java.lang.String typeFactory)
Creates a new instance with the specified TypeFactory.

Parameters:
typeFactory - The implementation to use.
Method Detail

createTypeFactory

private TypeFactory createTypeFactory(java.lang.Class typeFactory)
Creates a new instance of the specified TypeFactory.

Parameters:
typeFactory - The implementation to use.
Returns:
The new type mapping.

setDriver

public static void setDriver(java.lang.String driver)
                      throws java.lang.ClassNotFoundException
Set the SAX Parser to be used. The argument can either be the full class name or a user friendly shortcut if the parser is known to this class. The parsers that can currently be set by shortcut are listed in the main documentation page. If you are using another parser please send me the name of the SAX driver and I'll include it in a future release. If setDriver() is never called then the System property "sax.driver" is consulted. If that is not defined the driver defaults to OpenXML.

Throws:
java.lang.ClassNotFoundException

setDriver

public static void setDriver(java.lang.Class driver)
Set the SAX Parser to be used by directly passing the Class object.


setEncoding

public static void setEncoding(java.lang.String enc)
Set the encoding of the XML.

Parameters:
enc - The Java name of the encoding.

getEncoding

public java.lang.String getEncoding()
Return the encoding, transforming to the canonical name if possible.

See Also:
XmlWriter.canonicalizeEncoding(String)

getMaxThreads

public static int getMaxThreads()
Gets the maximum number of threads used at any given moment.


setMaxThreads

public static void setMaxThreads(int maxThreads)
Sets the maximum number of threads used at any given moment.


setDebug

public static void setDebug(boolean val)
Switch debugging output on/off.


setKeepAlive

public static void setKeepAlive(boolean val)
Switch HTTP keepalive on/off.


getKeepAlive

public static boolean getKeepAlive()
get current HTTP keepalive mode.


parse

void parse(java.io.InputStream is)
     throws java.lang.Exception
Parse the input stream. For each root level object, method objectParsed is called.

Throws:
java.lang.Exception

objectParsed

protected abstract void objectParsed(java.lang.Object what)
This method is called when a root level object has been parsed. Sub-classes implement this callback to receive the fully parsed object.


characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
Method called by SAX driver.

Parameters:
ch - The characters.
start - The start position in the character array.
length - The number of characters to use from the character array.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.characters(char[], int, int)

endElement

public void endElement(java.lang.String name)
                throws org.xml.sax.SAXException
Method called by SAX driver.

Parameters:
name - The element type name.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.endElement(java.lang.String)

startElement

public void startElement(java.lang.String name,
                         org.xml.sax.AttributeList atts)
                  throws org.xml.sax.SAXException
Method called by SAX driver.

Parameters:
name - The element type name.
atts - The specified or defaulted attributes.
Throws:
org.xml.sax.SAXException - Any SAX exception, possibly wrapping another exception.
See Also:
DocumentHandler.startElement(java.lang.String, org.xml.sax.AttributeList)

error

public void error(org.xml.sax.SAXParseException e)
           throws org.xml.sax.SAXException
Description copied from class: org.xml.sax.HandlerBase
Receive notification of a recoverable parser error.

The default implementation does nothing. Application writers may override this method in a subclass to take specific actions for each error, such as inserting the message in a log file or printing it to the console.

Parameters:
e -
Throws:
org.xml.sax.SAXException
See Also:
ErrorHandler.warning(org.xml.sax.SAXParseException), SAXParseException

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
                throws org.xml.sax.SAXException
Description copied from class: org.xml.sax.HandlerBase
Report a fatal XML parsing error.

The default implementation throws a SAXParseException. Application writers may override this method in a subclass if they need to take specific actions for each fatal error (such as collecting all of the errors into a single report): in any case, the application must stop all regular processing when this method is invoked, since the document is no longer reliable, and the parser may no longer report parsing events.

Parameters:
e -
Throws:
org.xml.sax.SAXException
See Also:
ErrorHandler.fatalError(org.xml.sax.SAXParseException), SAXParseException


Copyright © ${year} Apache Software Foundation. All Rights Reserved.