org.apache.xmlrpc
Class XmlWriter

java.lang.Object
  extended byjava.io.Writer
      extended byjava.io.OutputStreamWriter
          extended byorg.apache.xmlrpc.XmlWriter

class XmlWriter
extends java.io.OutputStreamWriter

A quick and dirty XML writer. If you feed it a ByteArrayInputStream, it may be necessary to call writer.flush() before calling buffer.toByteArray() to get the data written to your byte buffer.

Author:
Hannes Wallnoefer, Daniel Rall

Field Summary
protected static java.lang.String AMPERSAND_ENTITY
           
protected static java.lang.String CLOSING_TAG_START
           
private static DateTool dateTool
          Thread-safe wrapper for the DateFormat object used to parse date/time values.
private static java.util.Properties encodings
          Mapping between Java encoding names and "real" names used in XML prolog.
protected static java.lang.String GREATER_THAN_ENTITY
           
protected static java.lang.String ISO8859_1
          Java's name for the the ISO8859_1 encoding.
protected static java.lang.String LESS_THAN_ENTITY
           
protected static java.lang.String PROLOG_END
           
protected static java.lang.String PROLOG_START
           
protected static java.lang.String SINGLE_TAG_END
           
protected static java.lang.String UTF8
          Java's name for the the UTF8 encoding.
 
Fields inherited from class java.io.OutputStreamWriter
 
Fields inherited from class java.io.Writer
lock
 
Constructor Summary
XmlWriter(java.io.OutputStream out, java.lang.String enc)
          Creates a new instance.
 
Method Summary
protected static java.lang.String canonicalizeEncoding(java.lang.String javaEncoding)
          Tranforms a Java encoding to the canonical XML form (if a mapping is available).
protected  void chardata(java.lang.String text)
          Writes text as PCDATA.
protected  void emptyElement(java.lang.String elem)
           
protected  void endElement(java.lang.String elem)
           
protected  void startElement(java.lang.String elem)
           
protected  void write(byte[] byteData)
          This is used to write out the Base64 output...
 void writeObject(java.lang.Object obj)
          Writes the XML representation of a supported Java object type.
 
Methods inherited from class java.io.OutputStreamWriter
close, flush, getEncoding, write, write, write
 
Methods inherited from class java.io.Writer
write, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROLOG_START

protected static final java.lang.String PROLOG_START
See Also:
Constant Field Values

PROLOG_END

protected static final java.lang.String PROLOG_END
See Also:
Constant Field Values

CLOSING_TAG_START

protected static final java.lang.String CLOSING_TAG_START
See Also:
Constant Field Values

SINGLE_TAG_END

protected static final java.lang.String SINGLE_TAG_END
See Also:
Constant Field Values

LESS_THAN_ENTITY

protected static final java.lang.String LESS_THAN_ENTITY
See Also:
Constant Field Values

GREATER_THAN_ENTITY

protected static final java.lang.String GREATER_THAN_ENTITY
See Also:
Constant Field Values

AMPERSAND_ENTITY

protected static final java.lang.String AMPERSAND_ENTITY
See Also:
Constant Field Values

ISO8859_1

protected static final java.lang.String ISO8859_1
Java's name for the the ISO8859_1 encoding.

See Also:
Constant Field Values

UTF8

protected static final java.lang.String UTF8
Java's name for the the UTF8 encoding.

See Also:
Constant Field Values

encodings

private static java.util.Properties encodings
Mapping between Java encoding names and "real" names used in XML prolog.


dateTool

private static DateTool dateTool
Thread-safe wrapper for the DateFormat object used to parse date/time values.

Constructor Detail

XmlWriter

public XmlWriter(java.io.OutputStream out,
                 java.lang.String enc)
          throws java.io.UnsupportedEncodingException,
                 java.io.IOException
Creates a new instance.

Parameters:
out - The stream to write output to.
enc - The encoding to using for outputing XML.
Throws:
java.io.UnsupportedEncodingException - Encoding unrecognized.
java.io.IOException - Problem writing.
Method Detail

canonicalizeEncoding

protected static java.lang.String canonicalizeEncoding(java.lang.String javaEncoding)
Tranforms a Java encoding to the canonical XML form (if a mapping is available).

Parameters:
javaEncoding - The name of the encoding as known by Java.
Returns:
The XML encoding (if a mapping is available); otherwise, the encoding as provided.

writeObject

public void writeObject(java.lang.Object obj)
                 throws XmlRpcException,
                        java.io.IOException
Writes the XML representation of a supported Java object type.

Parameters:
obj - The Object to write.
Throws:
XmlRpcException - Unsupported character data found.
java.io.IOException - Problem writing data.
java.lang.IllegalArgumentException - If a null parameter is passed to this method (not supported by the XML-RPC specification).

write

protected void write(byte[] byteData)
              throws java.io.IOException
This is used to write out the Base64 output...

Throws:
java.io.IOException

startElement

protected void startElement(java.lang.String elem)
                     throws java.io.IOException
Parameters:
elem -
Throws:
java.io.IOException

endElement

protected void endElement(java.lang.String elem)
                   throws java.io.IOException
Parameters:
elem -
Throws:
java.io.IOException

emptyElement

protected void emptyElement(java.lang.String elem)
                     throws java.io.IOException
Parameters:
elem -
Throws:
java.io.IOException

chardata

protected void chardata(java.lang.String text)
                 throws XmlRpcException,
                        java.io.IOException
Writes text as PCDATA.

Parameters:
text - The data to write.
Throws:
XmlRpcException - Unsupported character data found.
java.io.IOException - Problem writing data.


Copyright © ${year} Apache Software Foundation. All Rights Reserved.