org.apache.xmlrpc

Class XmlRpc

public abstract class XmlRpc extends 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 350048 2005-11-30 21:49:32 +0100 (Mi, 30 Nov 2005) jochen $

Author: Hannes Wallnoefer Daniel L. Rall Andrew Evers

See Also: XmlRpcServer

Nested Class Summary
classXmlRpc.Value
This represents a XML-RPC value parsed from the request.
Field Summary
static intARRAY
static intBASE64
static intBOOLEAN
StringBuffercdata
Used to collect character data (CDATA) of parameter values.
XmlRpc.ValuecurrentValue
static booleandebug
Whether to log debugging output.
static StringdefaultInputEncoding
Java's name for the input encoding we're using.
static intDATE
static StringDEFAULT_PARSER
The default parser to use (MinML).
static intDOUBLE
static Stringencoding
Java's name for the encoding we're using.
interrorLevel
StringerrorMsg
static intFATAL
StringinputEncoding
static intINTEGER
static booleankeepalive
Wheter to use HTTP Keep-Alive headers.
static intmaxThreads
The maximum number of threads which can be used concurrently.
StringmethodName
static intNONE
static ClassparserClass
The class name of SAX parser to use.
booleanreadCdata
static intRECOVERABLE
static HashtablesaxDrivers
static intSTRING
static intSTRUCT
TypeFactorytypeFactory
static String[]types
The list of valid XML elements used for RPC.
TimeZonetz
Stackvalues
static Stringversion
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(String typeFactoryName)
Creates a new instance with the specified TypeFactory.
Method Summary
voidcharacters(char[] ch, int start, int length)
Method called by SAX driver.
TypeFactorycreateTypeFactory(String className)
Creates a new instance of the specified TypeFactory.
voidendElement(String name)
Method called by SAX driver.
voiderror(SAXParseException e)
voidfatalError(SAXParseException e)
static StringgetDefaultInputEncoding()
Return the default input encoding.
StringgetEncoding()
Return the encoding, transforming to the canonical name if possible.
StringgetInputEncoding()
Get the input encoding for this XmlRpc instance.
static booleangetKeepAlive()
get current HTTP keepalive mode.
static intgetMaxThreads()
Gets the maximum number of threads used at any given moment.
TimeZonegetServerTimeZone()
protected abstract voidobjectParsed(Object what)
This method is called when a root level object has been parsed.
voidparse(InputStream is)
Parse the input stream.
static voidsetDebug(boolean val)
Switch debugging output on/off.
static voidsetDefaultInputEncoding(String enc)
Set the default input encoding of the XML.
static voidsetDriver(String driver)
Set the SAX Parser to be used.
static voidsetDriver(Class driver)
Set the SAX Parser to be used by directly passing the Class object.
static voidsetEncoding(String enc)
Set the encoding of the XML.
voidsetInputEncoding(String enc)
Set the input encoding for this XmlRpc instance.
static voidsetKeepAlive(boolean val)
Switch HTTP keepalive on/off.
static voidsetMaxThreads(int maxThreads)
Sets the maximum number of threads used at any given moment.
voidsetServerTimeZone(TimeZone z)
voidstartElement(String name, AttributeList atts)
Method called by SAX driver.

Field Detail

ARRAY

static final int ARRAY

BASE64

static final int BASE64

BOOLEAN

static final int BOOLEAN

cdata

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

currentValue

XmlRpc.Value currentValue

debug

public static boolean debug
Whether to log debugging output.

defaultInputEncoding

static String defaultInputEncoding
Java's name for the input encoding we're using. Defaults to null, signifying the platform default. This may need to be overridden on platforms where the default encoding is not compatible with ASCII (eg. EBCDIC) but the network is still ASCII-like.

DATE

static final int DATE

DEFAULT_PARSER

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

DOUBLE

static final int DOUBLE

encoding

static String encoding
Java's name for the encoding we're using. Defaults to UTF8 (of which ISO8859_1 is a subset).

errorLevel

int errorLevel

errorMsg

String errorMsg

FATAL

static final int FATAL

inputEncoding

private String inputEncoding

INTEGER

static final int INTEGER

keepalive

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

maxThreads

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

methodName

String methodName

NONE

static final int NONE

parserClass

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

readCdata

boolean readCdata

RECOVERABLE

static final int RECOVERABLE

saxDrivers

private static Hashtable saxDrivers

STRING

static final int STRING

STRUCT

static final int STRUCT

typeFactory

private TypeFactory typeFactory

types

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

tz

TimeZone tz

values

Stack values

version

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

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 of TypeFactory.

XmlRpc

protected XmlRpc(String typeFactoryName)
Creates a new instance with the specified TypeFactory.

Parameters: typeFactoryName The fully qualified class name of the TypeFactory implementation to use.

Method Detail

characters

public void characters(char[] ch, int start, int length)
Method called by SAX driver.

createTypeFactory

private TypeFactory createTypeFactory(String className)
Creates a new instance of the specified TypeFactory.

Parameters: className The fully qualified class name of the implementation to use.

Returns: The new type mapping.

endElement

public void endElement(String name)
Method called by SAX driver.

error

public void error(SAXParseException e)

Parameters: e

Throws: SAXException

fatalError

public void fatalError(SAXParseException e)

Parameters: e

Throws: SAXException

getDefaultInputEncoding

public static String getDefaultInputEncoding()
Return the default input encoding. This may be null. This is always a Java encoding name, it is not transformed.

Returns: the Java encoding name to use, if set, otherwise null.

See Also: getInputEncoding

getEncoding

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

See Also: canonicalizeEncoding

getInputEncoding

public String getInputEncoding()
Get the input encoding for this XmlRpc instance. This is a Java encoding name.

Returns: The Java encoding name to use. null if not set.

getKeepAlive

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

getMaxThreads

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

getServerTimeZone

TimeZone getServerTimeZone()

objectParsed

protected abstract void objectParsed(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.

parse

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

setDebug

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

setDefaultInputEncoding

public static void setDefaultInputEncoding(String enc)
Set the default input encoding of the XML. This is used only if set.

Parameters: enc The Java name of the encoding.

See Also: setInputEncoding

setDriver

public static void setDriver(String driver)
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.

setDriver

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

setEncoding

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

Parameters: enc The Java name of the encoding.

setInputEncoding

public void setInputEncoding(String enc)
Set the input encoding for this XmlRpc instance. This can be used when the XMLRPC response does not contain the proper encoding information in the XML declaration.

Parameters: enc The Java name of the encoding.

setKeepAlive

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

setMaxThreads

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

setServerTimeZone

void setServerTimeZone(TimeZone z)

startElement

public void startElement(String name, AttributeList atts)
Method called by SAX driver.
Copyright B) 1999-2002 Apache Software Foundation. All Rights Reserved.