net.wotonomy.web.xml
Class XMLRPCEncoder

java.lang.Object
  extended by net.wotonomy.web.xml.XMLRPCEncoder
All Implemented Interfaces:
net.wotonomy.foundation.xml.XMLEncoder

public class XMLRPCEncoder
extends java.lang.Object
implements net.wotonomy.foundation.xml.XMLEncoder

An implementation of XMLEncoder that serializes objects into XMLRPC format, which is found at http://xmlrpc.com/spec. We extend that standard only in that we add a "class" attribute to the "value" tag, so that a java-based decoder can more closely reconstruct the original java data structure. The class attribute can be safely ignored by clients. This implementation is not thread-safe, so a new instances should be created to accomodate multiple threads.


Field Summary
static java.lang.String ARRAY
           
static java.lang.String BASE64
           
static java.lang.String BOOLEAN
           
static java.lang.String CLASS
           
static java.lang.String DATA
           
static java.lang.String DATE
           
static java.text.Format DATEFORMAT8601
           
static java.lang.String DOUBLE
           
static java.lang.String FALSE
           
static java.lang.String FAULT
           
static java.lang.String FAULTCODE
           
static java.lang.String FAULTSTRING
           
static java.lang.String I4
           
static java.lang.String INT
           
static java.lang.String MEMBER
           
static java.lang.String METHODCALL
           
static java.lang.String METHODNAME
           
static java.lang.String METHODRESPONSE
           
static java.lang.String NAME
           
static java.lang.String NIL
           
static java.lang.String PARAM
           
static java.lang.String PARAMS
           
static java.lang.String STRING
           
static java.lang.String STRUCT
           
static java.lang.String TRUE
           
static java.lang.String VALUE
           
 
Constructor Summary
XMLRPCEncoder()
           
 
Method Summary
 void encode(java.lang.Object anObject, java.io.OutputStream anOutputStream)
          Encodes an object to the specified output stream as XML.
 void encodeFault(int aFaultCode, java.lang.String aFaultString, java.io.OutputStream anOutputStream)
          Encodes a fault response in XML-RPC format in a "methodResponse" tag, and writes the XML to the specified output stream.
 void encodeRequest(java.lang.String aMethodName, java.lang.Object[] aParameterArray, java.io.OutputStream anOutputStream)
          Encodes a method request in XML-RPC format in a "methodCall" tag, and writes the XML to the specified output stream.
 void encodeResponse(java.lang.Object aResult, java.io.OutputStream anOutputStream)
          Encodes a method response in XML-RPC format in a "methodResponse" tag, and writes the XML to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHODCALL

public static final java.lang.String METHODCALL
See Also:
Constant Field Values

METHODNAME

public static final java.lang.String METHODNAME
See Also:
Constant Field Values

METHODRESPONSE

public static final java.lang.String METHODRESPONSE
See Also:
Constant Field Values

PARAMS

public static final java.lang.String PARAMS
See Also:
Constant Field Values

PARAM

public static final java.lang.String PARAM
See Also:
Constant Field Values

FAULT

public static final java.lang.String FAULT
See Also:
Constant Field Values

FAULTCODE

public static final java.lang.String FAULTCODE
See Also:
Constant Field Values

FAULTSTRING

public static final java.lang.String FAULTSTRING
See Also:
Constant Field Values

VALUE

public static final java.lang.String VALUE
See Also:
Constant Field Values

CLASS

public static final java.lang.String CLASS
See Also:
Constant Field Values

STRUCT

public static final java.lang.String STRUCT
See Also:
Constant Field Values

MEMBER

public static final java.lang.String MEMBER
See Also:
Constant Field Values

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values

ARRAY

public static final java.lang.String ARRAY
See Also:
Constant Field Values

DATA

public static final java.lang.String DATA
See Also:
Constant Field Values

NIL

public static final java.lang.String NIL
See Also:
Constant Field Values

INT

public static final java.lang.String INT
See Also:
Constant Field Values

I4

public static final java.lang.String I4
See Also:
Constant Field Values

BOOLEAN

public static final java.lang.String BOOLEAN
See Also:
Constant Field Values

STRING

public static final java.lang.String STRING
See Also:
Constant Field Values

DOUBLE

public static final java.lang.String DOUBLE
See Also:
Constant Field Values

DATE

public static final java.lang.String DATE
See Also:
Constant Field Values

BASE64

public static final java.lang.String BASE64
See Also:
Constant Field Values

TRUE

public static final java.lang.String TRUE
See Also:
Constant Field Values

FALSE

public static final java.lang.String FALSE
See Also:
Constant Field Values

DATEFORMAT8601

public static final java.text.Format DATEFORMAT8601
Constructor Detail

XMLRPCEncoder

public XMLRPCEncoder()
Method Detail

encode

public void encode(java.lang.Object anObject,
                   java.io.OutputStream anOutputStream)
Encodes an object to the specified output stream as XML.

Specified by:
encode in interface net.wotonomy.foundation.xml.XMLEncoder
Parameters:
anObject - The object to be serialized to XML format.
anOutputStream - The output stream to which the object will be written.

encodeRequest

public void encodeRequest(java.lang.String aMethodName,
                          java.lang.Object[] aParameterArray,
                          java.io.OutputStream anOutputStream)
Encodes a method request in XML-RPC format in a "methodCall" tag, and writes the XML to the specified output stream. This method only writes XML: the caller is responsible for generating the appropriate header, if any, which should set the content type as "text/xml" and the content length as appropriate. The caller is also responsible for writing the xml version tag.

Parameters:
aMethodName - The method name to appear in the "methodName" tag.
aParameterArray - An array of objects, each of which will be encoded as values enclosed in a "param" tag, all of which will be enclosed in a "params" tag.
anOutputStream - The stream to which the XML will be written.

encodeResponse

public void encodeResponse(java.lang.Object aResult,
                           java.io.OutputStream anOutputStream)
Encodes a method response in XML-RPC format in a "methodResponse" tag, and writes the XML to the specified output stream. This method only writes XML: the caller is responsible for generating the appropriate header, if any, which should set the content type as "text/xml" and the content length as appropriate. The caller is also responsible for writing the xml version tag.

Parameters:
aResult - A object which will be encoded as values enclosed in a "param" tag, all of which will be enclosed in a "params" tag.
anOutputStream - The stream to which the XML will be written.

encodeFault

public void encodeFault(int aFaultCode,
                        java.lang.String aFaultString,
                        java.io.OutputStream anOutputStream)
Encodes a fault response in XML-RPC format in a "methodResponse" tag, and writes the XML to the specified output stream. This method only writes XML: the caller is responsible for first generating the appropriate header, if any, which should set the content type as "text/xml" and the content length as appropriate. The caller is also responsible for writing the xml version tag.

Parameters:
aFaultCode - An application-defined error code.
aFaultString - A human-readable error description.
anOutputStream - The stream to which the XML will be written.


Copyright © 2006 null. All Rights Reserved.