org.apache.xmlrpc

Class XmlRpc

Known Direct Subclasses:
XmlRpcClientResponseProcessor, 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 350048 2005-11-30 21:49:32 +0100 (Mi, 30 Nov 2005) jochen $
Authors:
Hannes Wallnoefer
Daniel L. 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) static int
DATE
private static String
DEFAULT_PARSER
The default parser to use (MinML).
(package private) static int
DOUBLE
(package private) static int
FATAL
(package private) static int
INTEGER
(package private) static int
NONE
(package private) static int
RECOVERABLE
(package private) static int
STRING
(package private) static int
STRUCT
(package private) StringBuffer
cdata
Used to collect character data (CDATA) of parameter values.
(package private) XmlRpc.Value
currentValue
static boolean
debug
Whether to log debugging output.
(package private) static String
defaultInputEncoding
Java's name for the input encoding we're using.
(package private) static String
encoding
Java's name for the encoding we're using.
(package private) int
errorLevel
(package private) String
errorMsg
private String
inputEncoding
(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) String
methodName
private static Class
parserClass
The class name of SAX parser to use.
(package private) boolean
readCdata
private static Hashtable
saxDrivers
private TypeFactory
typeFactory
(package private) static String[]
types
The list of valid XML elements used for RPC.
(package private) TimeZone
tz
(package private) Stack
values
static String
version
The version string used in HTTP communication.

Constructor Summary

XmlRpc()
Creates a new instance with the TypeFactory set to an instance of the class named by the org.apache.xmlrpc.TypeFactory System property.
XmlRpc(String typeFactoryName)
Creates a new instance with the specified TypeFactory.

Method Summary

void
characters(ch[] , int start, int length)
Method called by SAX driver.
private TypeFactory
createTypeFactory(String className)
Creates a new instance of the specified TypeFactory.
void
endElement(String name)
Method called by SAX driver.
void
error(org.xml.sax.SAXParseException e)
void
fatalError(org.xml.sax.SAXParseException e)
static String
getDefaultInputEncoding()
Return the default input encoding.
String
getEncoding()
Return the encoding, transforming to the canonical name if possible.
String
getInputEncoding()
Get the input encoding for this XmlRpc instance.
static boolean
getKeepAlive()
get current HTTP keepalive mode.
static int
getMaxThreads()
Gets the maximum number of threads used at any given moment.
(package private) TimeZone
getServerTimeZone()
protected abstract void
objectParsed(Object what)
This method is called when a root level object has been parsed.
(package private) void
parse(InputStream is)
Parse the input stream.
static void
setDebug(boolean val)
Switch debugging output on/off.
static void
setDefaultInputEncoding(String enc)
Set the default input encoding of the XML.
static void
setDriver(Class driver)
Set the SAX Parser to be used by directly passing the Class object.
static void
setDriver(String driver)
Set the SAX Parser to be used.
static void
setEncoding(String enc)
Set the encoding of the XML.
void
setInputEncoding(String enc)
Set the input encoding for this XmlRpc instance.
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.
(package private) void
setServerTimeZone(TimeZone z)
void
startElement(String name, org.xml.sax.AttributeList atts)
Method called by SAX driver.

Field Details

ARRAY

(package private) static final int ARRAY
Field Value:
7

BASE64

(package private) static final int BASE64
Field Value:
5

BOOLEAN

(package private) static final int BOOLEAN
Field Value:
2

DATE

(package private) static final int DATE
Field Value:
4

DEFAULT_PARSER

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

DOUBLE

(package private) static final int DOUBLE
Field Value:
3

FATAL

(package private) static final int FATAL
Field Value:
2

INTEGER

(package private) static final int INTEGER
Field Value:
1

NONE

(package private) static final int NONE
Field Value:
0

RECOVERABLE

(package private) static final int RECOVERABLE
Field Value:
1

STRING

(package private) static final int STRING
Field Value:
0

STRUCT

(package private) static final int STRUCT
Field Value:
6

cdata

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

currentValue

(package private)  XmlRpc.Value currentValue

debug

public static boolean debug
Whether to log debugging output.

defaultInputEncoding

(package private) 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.

encoding

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

errorLevel

(package private)  int errorLevel

errorMsg

(package private)  String errorMsg

inputEncoding

private String inputEncoding

keepalive

(package private) 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

(package private)  String methodName

parserClass

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

readCdata

(package private)  boolean readCdata

saxDrivers

private static Hashtable saxDrivers

typeFactory

private TypeFactory typeFactory

types

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

tz

(package private)  TimeZone tz

values

(package private)  Stack values

version

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

Constructor Details

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)
Parameters:
typeFactoryName - The fully qualified class name of the TypeFactory implementation to use.

Method Details

characters

public void characters(ch[] ,
                       int start,
                       int length)
            throws org.xml.sax.SAXException
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)
            throws org.xml.sax.SAXException
Method called by SAX driver.

error

public void error(org.xml.sax.SAXParseException e)
            throws org.xml.sax.SAXException
Parameters:
e -

fatalError

public void fatalError(org.xml.sax.SAXParseException e)
            throws org.xml.sax.SAXException
Parameters:
e -

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.

getEncoding

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

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

(package private)  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

(package private)  void parse(InputStream is)
            throws Exception
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.

setDriver

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

setDriver

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

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

(package private)  void setServerTimeZone(TimeZone z)

startElement

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

Copyright B) 1999-2002 Apache Software Foundation. All Rights Reserved.