com.flat502.rox.marshal.xmlrpc
Class XmlRpcMethod

java.lang.Object
  extended by com.flat502.rox.marshal.xmlrpc.XmlRpcMethod
All Implemented Interfaces:
RpcMethod, XmlRpcConstants
Direct Known Subclasses:
XmlRpcMethodCall, XmlRpcMethodResponse

public abstract class XmlRpcMethod
extends java.lang.Object
implements RpcMethod, XmlRpcConstants

This is the base class for XML-RPC method calls and responses.

For details about the marshalling process see XmlRpcMarshaller.


Nested Class Summary
 
Nested classes/interfaces inherited from interface com.flat502.rox.marshal.xmlrpc.XmlRpcConstants
XmlRpcConstants.ContentTypes, XmlRpcConstants.Formats, XmlRpcConstants.Tags, XmlRpcConstants.Types
 
Constructor Summary
protected XmlRpcMethod(FieldNameEncoder fieldNameEncoder)
          Initialize a new instance of this class.
 
Method Summary
 java.lang.String getContentType()
          Called to get the value for the Content-Type HTTP header.
 java.lang.String getHttpMethod()
           
 java.lang.String getHttpURI(java.net.URL url)
           
 byte[] marshal()
          Marshals the current instance into a byte array encoded using UTF-8.
 byte[] marshal(java.nio.charset.Charset charSet)
          Marshals the current instance into a byte array encoded using the specified character set.
 void marshal(java.io.OutputStream out)
          Marshals the current instance to an OutputStream encoded using UTF-8.
 void marshal(java.io.OutputStream out, java.nio.charset.Charset charSet)
          Marshals the current instance to an OutputStream encoded using the specified character set.
protected abstract  void marshalImpl(XmlPrinter out)
          The central hook for marshalling for sub-classes.
protected  void marshalValue(XmlPrinter out, int depth, java.lang.Object param)
           
 void setCompactXml(boolean compact)
          Configure the compactness of the marshalled form of this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XmlRpcMethod

protected XmlRpcMethod(FieldNameEncoder fieldNameEncoder)
Initialize a new instance of this class.

Parameters:
fieldNameEncoder - An implementation of FieldNameEncoder used when struct members are marshalled. May be null.
Method Detail

setCompactXml

public void setCompactXml(boolean compact)
Configure the compactness of the marshalled form of this instance.

The marshalled form of instances is compact by default.

Parameters:
compact - A flag indicating whether to produce compact XML (true) or more readable XML (true).

getHttpMethod

public java.lang.String getHttpMethod()

getHttpURI

public java.lang.String getHttpURI(java.net.URL url)

getContentType

public java.lang.String getContentType()
Description copied from interface: RpcMethod
Called to get the value for the Content-Type HTTP header.

This is used when constructing requests and responses, and when validating requests and responses.

Specified by:
getContentType in interface RpcMethod
Returns:
The value text/xml.

marshal

public byte[] marshal()
               throws java.io.IOException,
                      MarshallingException
Marshals the current instance into a byte array encoded using UTF-8.

Returns:
A byte array containing the marshalled form of this instance.
Throws:
java.io.IOException - if an error occurs while storing the marshalled form of this instance out this instance.
MarshallingException - if an error occurs while marshalling this instance.

marshal

public byte[] marshal(java.nio.charset.Charset charSet)
               throws java.io.IOException,
                      MarshallingException
Marshals the current instance into a byte array encoded using the specified character set.

Parameters:
charSet - The character set to use when encoding the marshalled form of this instance.
Returns:
A byte array containing the marshalled form of this instance.
Throws:
java.io.IOException - if an error occurs while storing the marshalled form of this instance out this instance.
MarshallingException - if an error occurs while marshalling this instance.

marshal

public void marshal(java.io.OutputStream out)
             throws java.io.IOException,
                    MarshallingException
Marshals the current instance to an OutputStream encoded using UTF-8.

Parameters:
out - The OutputStream to marshal this instance to.
Throws:
java.io.IOException - if an error occurs while storing the marshalled form of this instance out this instance.
MarshallingException - if an error occurs while marshalling this instance.

marshal

public void marshal(java.io.OutputStream out,
                    java.nio.charset.Charset charSet)
             throws java.io.IOException,
                    MarshallingException
Marshals the current instance to an OutputStream encoded using the specified character set.

Specified by:
marshal in interface RpcMethod
Parameters:
out - The OutputStream to marshal this instance to.
charSet - The character set to use when encoding the marshalled form of this instance.
Throws:
java.io.IOException - if an error occurs while storing the marshalled form of this instance out this instance.
MarshallingException - if an error occurs while marshalling this instance.

marshalImpl

protected abstract void marshalImpl(XmlPrinter out)
                             throws java.io.IOException,
                                    MarshallingException
The central hook for marshalling for sub-classes.

Implementations should write their marshalled form to the given stream which has already been initialized with an appropriate encoding.

Parameters:
out - The stream implementations should marshal themselves to.
Throws:
java.io.IOException - Implementations may raise an exception if a problem occurs while writing the marshalled form of this instance out.
MarshallingException - Implementations may raise an exception if a problem occurs while marshalling is being attempted.

marshalValue

protected void marshalValue(XmlPrinter out,
                            int depth,
                            java.lang.Object param)
                     throws MarshallingException,
                            java.io.IOException
Throws:
MarshallingException
java.io.IOException