|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.flat502.rox.marshal.xmlrpc.XmlRpcMarshaller
public class XmlRpcMarshaller
This class supports marshalling of XML-RPC values, not
execution. For that functionality see the
XmlRpcClient
class.
The relationship between Java and XML-RPC data types is given in the following table:
Java | XML-RPC | Notes |
---|---|---|
Integer or int | <int> or <i4> | This implementation always uses the <int> form when marshalling integers. |
Boolean or boolean | <boolean> | |
String or char[] | <string> | This implementation always uses an explicit <string> tag when marshalling strings. |
Float, float, Double or double | <double> | If the target field is a float (or Float )
then the value may be truncated. |
java.util.Date | <dateTime.iso8601> | Date values are interpreted as UTC dates for the purposes of unmarshalling. |
byte[] | <base64> | |
Object or java.util.Map | <struct> | Objects are marshalled (and unmarshalled) by treating their public
fields as keys in a map. The names of the public fields are transformed by
calls to the encodeFieldName(String) method.
transient fields and fields with a null
value are ignored during marshalling. |
Object[] or java.util.List | <array> |
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 |
XmlRpcMarshaller(FieldNameEncoder fieldNameEncoder)
Initialize a new instance of this class. |
Method Summary | |
---|---|
protected java.lang.String |
encodeFieldName(java.lang.String name)
Determine the name of an XML-RPC struct member from an Object field name. |
protected java.lang.String |
getBase64TagName()
|
protected java.lang.String |
getBooleanTagName()
|
protected java.text.DateFormat |
getDateFormat()
|
protected java.lang.String |
getDateTagName()
|
protected java.lang.String |
getDoubleTagName()
|
protected java.lang.String |
getIntTagName()
|
protected java.lang.String |
getStringTagName()
|
protected void |
marshalList(XmlPrinter out,
int depth,
java.util.List list)
|
protected void |
marshalMap(XmlPrinter out,
int depth,
java.util.Map param)
|
protected void |
marshalObject(XmlPrinter out,
int depth,
java.lang.Object param)
Marshals an Object that is not one of the standard types in the
mapping table discussed in the
description of this class . |
protected void |
marshalValue(XmlPrinter out,
java.lang.Boolean val)
|
protected void |
marshalValue(XmlPrinter out,
byte[] val)
|
protected void |
marshalValue(XmlPrinter out,
java.lang.Character val)
|
protected void |
marshalValue(XmlPrinter out,
java.util.Date val)
|
protected void |
marshalValue(XmlPrinter out,
int depth,
java.lang.Object param)
|
protected void |
marshalValue(XmlPrinter out,
java.lang.Number val)
|
protected void |
marshalValue(XmlPrinter out,
java.lang.String val)
|
protected java.text.DateFormat |
newDateFormat()
Initialize a new DateFormat for use when formatting
XML-RPC date values. |
protected XmlPrinter |
newXmlWriter(java.io.OutputStream out,
java.nio.charset.Charset charSet)
A factory method invoked to create a new instance of XmlPrinter . |
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 |
---|
protected XmlRpcMarshaller(FieldNameEncoder fieldNameEncoder)
This constructor calls newDateFormat()
to initialize the underlying date formatter.
fieldNameEncoder
- An implementation of FieldNameEncoder
used when
struct members are marshalled. May be null
.Method Detail |
---|
public void setCompactXml(boolean compact)
The marshalled form of instances is compact by default.
compact
- A flag indicating whether to produce compact XML (true
)
or more readable XML (true
).protected XmlPrinter newXmlWriter(java.io.OutputStream out, java.nio.charset.Charset charSet) throws java.io.IOException
XmlPrinter
.
Implementations are free to ignore the compact
parameter.
It is intended as hint to ease debugging. This implementation "pretty
prints" the XML if compact
is false
, using
indentation and line terminators to lay the document out in a more
readable form. The result is likely to be a considerably larger XML
document.
out
- The OutputStream
the returned instance should
write to.charSet
- The character encoding that should be used when writing
textual data to the underlying stream.
XmlPrinter
that will print
to the given stream.
java.io.IOException
protected java.text.DateFormat getDateFormat()
protected java.lang.String getIntTagName()
protected java.lang.String getBooleanTagName()
protected java.lang.String getStringTagName()
null
if strings should
be encoded without a type tag.protected java.lang.String getDoubleTagName()
protected java.lang.String getDateTagName()
protected java.lang.String getBase64TagName()
protected java.text.DateFormat newDateFormat()
DateFormat
for use when formatting
XML-RPC date values.
This method may be invoked multiple times and it must
return an equivalent formatter on each invocation. Equivalent
formatters always produce the same string literal when formatting
a given Date
instance.
protected void marshalValue(XmlPrinter out, int depth, java.lang.Object param) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected void marshalValue(XmlPrinter out, java.lang.Boolean val) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected void marshalValue(XmlPrinter out, java.lang.Character val) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected void marshalValue(XmlPrinter out, java.lang.String val) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected void marshalValue(XmlPrinter out, java.lang.Number val) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected void marshalValue(XmlPrinter out, java.util.Date val) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected void marshalValue(XmlPrinter out, byte[] val) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected void marshalObject(XmlPrinter out, int depth, java.lang.Object param) throws MarshallingException, java.io.IOException
Object
that is not one of the standard types in the
mapping table discussed in the
description of this class
.
The object is not a simple type (Integer
etc) and does not
implement either the Map
or List
interface.
depth
- Used for pretty printing the output. Implementations are free
to ignore this parameter.param
- The object to marshal
MarshallingException
java.io.IOException
protected void marshalMap(XmlPrinter out, int depth, java.util.Map param) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected void marshalList(XmlPrinter out, int depth, java.util.List list) throws MarshallingException, java.io.IOException
MarshallingException
java.io.IOException
protected java.lang.String encodeFieldName(java.lang.String name)
The default implementation defers to the
FieldNameEncoder
this instance was initialized with.
name
- The name of the Object field.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |