class XmlWriter
extends java.io.OutputStreamWriter
ByteArrayInputStream, it may be necessary to call
writer.flush() before calling
buffer.toByteArray() to get the data written to
your byte buffer.| Modifier and Type | Field and Description |
|---|---|
protected static java.lang.String |
AMPERSAND_ENTITY |
protected static Base64 |
base64Codec |
protected static java.lang.String |
CLOSING_TAG_START |
(package private) 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 |
(package private) boolean |
hasWrittenProlog
Whether the XML prolog has been written.
|
(package private) static java.lang.String |
ISO8859_1
Java's name for the ISO-8859-1 encoding.
|
protected static java.lang.String |
LESS_THAN_ENTITY |
private static char[] |
PROLOG |
protected static java.lang.String |
PROLOG_END |
protected static java.lang.String |
PROLOG_START |
protected static java.lang.String |
SINGLE_TAG_END |
protected static TypeDecoder |
typeDecoder
Class to delegate type decoding to.
|
(package private) static java.lang.String |
UTF16
Java's name for the UTF-16 encoding.
|
(package private) static java.lang.String |
UTF8
Java's name for the UTF-8 encoding.
|
| Constructor and Description |
|---|
XmlWriter(java.io.OutputStream out,
java.lang.String enc)
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
protected static java.lang.String |
canonicalizeEncoding(java.lang.String javaEncoding)
Deprecated.
This method will not be visible in 2.0.
|
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) |
private static java.lang.String |
forceUnicode(java.lang.String encoding) |
private static boolean |
isValidXMLChar(char c)
Section 2.2 of the XML spec describes which Unicode code points
are valid in XML:
#x9 | #xA | #xD | [#x20-#xD7FF] |
[#xE000-#xFFFD] | [#x10000-#x10FFFF]
Code points outside this set must be entity encoded to be
represented in XML. |
protected static void |
setTypeDecoder(TypeDecoder newTypeDecoder) |
protected void |
startElement(java.lang.String elem) |
protected void |
write(byte[] byteData)
This is used to write out the Base64 output...
|
void |
write(char c)
A mostly pass-through implementation wrapping
OutputStreamWriter.write() which assures that the
XML prolog is written before any other data. |
void |
write(char[] cbuf,
int off,
int len)
A mostly pass-through implementation wrapping
OutputStreamWriter.write() which assures that the
XML prolog is written before any other data. |
void |
write(java.lang.String str,
int off,
int len)
A mostly pass-through implementation wrapping
OutputStreamWriter.write() which assures that the
XML prolog is written before any other data. |
private void |
writeCharacterReference(char c)
Writes characters like '\r' (0xd) as " ".
|
void |
writeObject(java.lang.Object obj)
Writes the XML representation of a supported Java object type.
|
protected static final java.lang.String PROLOG_START
protected static final java.lang.String PROLOG_END
protected static final java.lang.String CLOSING_TAG_START
protected static final java.lang.String SINGLE_TAG_END
protected static final java.lang.String LESS_THAN_ENTITY
protected static final java.lang.String GREATER_THAN_ENTITY
protected static final java.lang.String AMPERSAND_ENTITY
private static final char[] PROLOG
static final java.lang.String ISO8859_1
static final java.lang.String UTF8
static final java.lang.String UTF16
protected static final Base64 base64Codec
protected static TypeDecoder typeDecoder
private static java.util.Properties encodings
DateTool dateTool
DateFormat object used
to parse date/time values.boolean hasWrittenProlog
public XmlWriter(java.io.OutputStream out,
java.lang.String enc)
throws java.io.UnsupportedEncodingException
out - The stream to write output to.enc - The encoding to using for outputing XML. Only UTF-8
and UTF-16 are supported. If another encoding is specified,
UTF-8 will be used instead for widest XML parser
interoperability.java.io.UnsupportedEncodingException - Since unsupported
encodings are internally converted to UTF-8, this should only
be seen as the result of an internal error.private static java.lang.String forceUnicode(java.lang.String encoding)
encoding - A caller-specified encoding.protected static java.lang.String canonicalizeEncoding(java.lang.String javaEncoding)
javaEncoding - The name of the encoding as known by Java.public void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
OutputStreamWriter.write() which assures that the
XML prolog is written before any other data.write in class java.io.OutputStreamWriterjava.io.IOExceptionjava.io.OutputStreamWriter.write(char[], int, int)public void write(char c)
throws java.io.IOException
OutputStreamWriter.write() which assures that the
XML prolog is written before any other data.java.io.IOExceptionjava.io.OutputStreamWriter.write(char)public void write(java.lang.String str,
int off,
int len)
throws java.io.IOException
OutputStreamWriter.write() which assures that the
XML prolog is written before any other data.write in class java.io.OutputStreamWriterjava.io.IOExceptionjava.io.OutputStreamWriter.write(String, int, int)public void writeObject(java.lang.Object obj)
throws XmlRpcException,
java.io.IOException
obj - The Object to write.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).protected void write(byte[] byteData)
throws java.io.IOException
java.io.IOExceptionprivate void writeCharacterReference(char c)
throws java.io.IOException
java.io.IOExceptionprotected void startElement(java.lang.String elem)
throws java.io.IOException
elem - java.io.IOExceptionprotected void endElement(java.lang.String elem)
throws java.io.IOException
elem - java.io.IOExceptionprotected void emptyElement(java.lang.String elem)
throws java.io.IOException
elem - java.io.IOExceptionprotected void chardata(java.lang.String text)
throws XmlRpcException,
java.io.IOException
PCDATA.text - The data to write.XmlRpcException - Unsupported character data found.java.io.IOException - Problem writing data.private static final boolean isValidXMLChar(char c)
#x9 | #xA | #xD | [#x20-#xD7FF] |
[#xE000-#xFFFD] | [#x10000-#x10FFFF]
Code points outside this set must be entity encoded to be
represented in XML.c - The character to inspect.protected static void setTypeDecoder(TypeDecoder newTypeDecoder)
Copyright ? 1999-2002 Apache Software Foundation. All Rights Reserved.