public class UTF8XMLWriter extends XMLWriter
| Modifier and Type | Class and Description |
|---|---|
private static class |
UTF8XMLWriter.ReplacementTextOutputStream |
| Modifier and Type | Field and Description |
|---|---|
private byte[] |
buf |
private int |
bufUsed |
private static int |
DEFAULT_BUF_LENGTH |
private static int |
DEFAULT_OPTIONS |
private boolean |
inStartTag |
private java.lang.String |
lineSeparator |
static int |
MINIMIZE_EMPTY_ELEMENTS |
static int |
MINIMIZE_EMPTY_ELEMENTS_HTML |
private boolean |
minimizeEmptyElements |
private boolean |
minimizeEmptyElementsHtml |
private java.io.OutputStream |
out |
private boolean |
quoteWhitespace |
private java.lang.String |
sysLineSeparator |
| Constructor and Description |
|---|
UTF8XMLWriter(java.io.OutputStream out)
Create an XML writer that will write in UTF-8 to the specified
OutputStream with the default options.
|
UTF8XMLWriter(java.io.OutputStream out,
int options)
Create an XML writer that will write in UTF-8 to the specified
OutputStream with the specified options.
|
| Modifier and Type | Method and Description |
|---|---|
void |
attribute(java.lang.String name,
java.lang.String value)
Writes an attribute.
|
void |
cdataSection(java.lang.String content)
Writes a CDATA section.
|
void |
characterReference(int n)
Writes a character reference.
|
void |
close() |
void |
comment(java.lang.String body)
Writes a comment.
|
void |
endAttribute()
Ends an attribute.
|
void |
endElement(java.lang.String name)
Ends an element.
|
void |
endReplacementText()
Ends the replacement text for an internal entity.
|
void |
entityReference(boolean isParam,
java.lang.String name)
Writes an entity reference.
|
private void |
finishStartTag() |
void |
flush() |
private void |
flushBuf() |
void |
markup(java.lang.String str)
Writes markup.
|
void |
processingInstruction(java.lang.String target,
java.lang.String data)
Writes a processing instruction.
|
private void |
put(byte b) |
void |
startAttribute(java.lang.String name)
Starts an attribute.
|
void |
startElement(java.lang.String name)
Starts an element.
|
void |
startReplacementText()
Starts the replacement text for an internal entity.
|
void |
write(char c) |
void |
write(char[] cbuf,
int off,
int len) |
void |
write(java.lang.String str) |
void |
write(java.lang.String str,
int off,
int len) |
private void |
writeMarkup(java.lang.String str) |
private void |
writeMB(char c) |
private void |
writeQuote(char c) |
private void |
writeQuote(java.lang.String str,
int off,
int len) |
private void |
writeRaw(java.lang.String str) |
private void |
writeSurrogatePair(char c1,
char c2) |
void |
writeUTF8(byte[] buf,
int off,
int len) |
private java.io.OutputStream out
private boolean inStartTag
private boolean quoteWhitespace
private static final int DEFAULT_BUF_LENGTH
private byte[] buf
private int bufUsed
private java.lang.String sysLineSeparator
private java.lang.String lineSeparator
private boolean minimizeEmptyElements
private boolean minimizeEmptyElementsHtml
public static final int MINIMIZE_EMPTY_ELEMENTS
public static final int MINIMIZE_EMPTY_ELEMENTS_HTML
private static final int DEFAULT_OPTIONS
public UTF8XMLWriter(java.io.OutputStream out,
int options)
public UTF8XMLWriter(java.io.OutputStream out)
public void writeUTF8(byte[] buf,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionpublic void write(char[] cbuf,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void write(char c)
throws java.io.IOException
java.io.IOExceptionpublic void write(java.lang.String str)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionpublic void write(java.lang.String str,
int off,
int len)
throws java.io.IOException
write in class java.io.Writerjava.io.IOExceptionprivate final void writeQuote(java.lang.String str,
int off,
int len)
throws java.io.IOException
java.io.IOExceptionprivate final void writeQuote(char c)
throws java.io.IOException
java.io.IOExceptionprivate void writeRaw(java.lang.String str)
throws java.io.IOException
java.io.IOExceptionprivate final void writeMB(char c)
throws java.io.IOException
java.io.IOExceptionprivate final void writeSurrogatePair(char c1,
char c2)
throws java.io.IOException
java.io.IOExceptionpublic void startElement(java.lang.String name)
throws java.io.IOException
XMLWriterattribute.
The start-tag will be closed by the first following call to any method
other than attribute.startElement in class XMLWriterjava.io.IOExceptionprivate void finishStartTag()
throws java.io.IOException
java.io.IOExceptionpublic void attribute(java.lang.String name,
java.lang.String value)
throws java.io.IOException
XMLWriterattribute since the last call to startElement,
unless inside a startAttribute, endAttribute
pair.public void startAttribute(java.lang.String name)
throws java.io.IOException
XMLWriter= and the opening
quote.
This provides an alternative to attribute
that allows markup to be included in the attribute value.
The value of the attribute is written using the normal
write methods;
endAttribute must be called at the end
of the attribute value.
Entity and character references can be written using
entityReference and characterReference.startAttribute in class XMLWriterjava.io.IOExceptionpublic void endAttribute()
throws java.io.IOException
XMLWriterendAttribute in class XMLWriterjava.io.IOExceptionpublic void endElement(java.lang.String name)
throws java.io.IOException
XMLWriterendElement in class XMLWriterjava.io.IOExceptionpublic void processingInstruction(java.lang.String target,
java.lang.String data)
throws java.io.IOException
XMLWriterdata is non-empty a space will be inserted automatically
to separate it from the target.processingInstruction in class XMLWriterjava.io.IOExceptionpublic void comment(java.lang.String body)
throws java.io.IOException
XMLWriterpublic void entityReference(boolean isParam,
java.lang.String name)
throws java.io.IOException
XMLWriterentityReference in class XMLWriterjava.io.IOExceptionpublic void characterReference(int n)
throws java.io.IOException
XMLWritercharacterReference in class XMLWriterjava.io.IOExceptionpublic void cdataSection(java.lang.String content)
throws java.io.IOException
XMLWritercdataSection in class XMLWriterjava.io.IOExceptionpublic void markup(java.lang.String str)
throws java.io.IOException
XMLWriterstartReplacementText).public void startReplacementText()
throws java.io.IOException
XMLWriterendReplacementText.
This enables an extra level of escaping that protects
against the process of constructing an entity's replacement
text from the literal entity value.
See Section 4.5 of the XML Recommendation.
Between a call to startReplacementText
and endReplacementText, the argument to
markup would specify entity replacement text;
these would be escaped so that when processed as
a literal entity value, the specified entity replacement text
would be constructed.
This call does not itself cause anything to be written.startReplacementText in class XMLWriterjava.io.IOExceptionpublic void endReplacementText()
throws java.io.IOException
XMLWriterstartReplacementText.
This call does not itself cause anything to be written.endReplacementText in class XMLWriterjava.io.IOExceptionprivate void writeMarkup(java.lang.String str)
throws java.io.IOException
java.io.IOExceptionprivate final void put(byte b)
throws java.io.IOException
java.io.IOExceptionprivate final void flushBuf()
throws java.io.IOException
java.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.Writerjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.Writerjava.io.IOException