|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ctc.wstx.sw.XmlWriter
com.ctc.wstx.sw.EncodingXmlWriter
public abstract class EncodingXmlWriter
Intermediate base class used when outputting to streams that use an encoding that is compatible with 7-bit single-byte Ascii encoding. That means it can be used for UTF-8, ISO-Latin1 and pure Ascii.
Implementation notes:
Parts of surrogate handling are implemented here in the base class:
storage for the first part of a split surrogate (only possible when
character content is output split in multiple calls) is within
base class. Also, simple checks for unmatched surrogate pairs are
in writeAscii
method, since it is the most convenient
place to catch cases where a text segment ends with an unmatched
surrogate pair half.
Field Summary | |
---|---|
protected java.io.OutputStream |
mOut
Actual output stream to use for outputting encoded content as bytes. |
protected byte[] |
mOutputBuffer
|
protected int |
mOutputPtr
|
protected int |
mSurrogate
In case a split surrogate pair is output (which can only successfully occur with either writeRaw or
writeCharacters ), the first part is temporarily stored
within this member variable. |
Fields inherited from class com.ctc.wstx.sw.XmlWriter |
---|
DEFAULT_QUOTE_CHAR, mAttrValueWriter, mAutoCloseOutput, mCheckContent, mCheckNames, mCheckStructure, mConfig, mEncoding, mFixContent, mLocPastChars, mLocRowNr, mLocRowStartOffset, mNsAware, mRawWrapper, mTextWrapper, mTextWriter, mXml11, SURR1_FIRST, SURR1_LAST, SURR2_FIRST, SURR2_LAST |
Constructor Summary | |
---|---|
EncodingXmlWriter(java.io.OutputStream out,
WriterConfig cfg,
java.lang.String encoding,
boolean autoclose)
|
Method Summary | |
---|---|
protected int |
calcSurrogate(int secondSurr)
|
void |
close()
Method called to flush the buffer(s), and close the output sink (stream or writer). |
void |
flush()
|
protected void |
flushBuffer()
|
protected int |
getOutputPtr()
This method is needed by the super class, to calculate hard byte/char offsets. |
protected java.io.OutputStream |
getOutputStream()
|
protected java.io.Writer |
getWriter()
|
protected void |
throwUnpairedSurrogate()
|
protected void |
throwUnpairedSurrogate(int code)
|
protected void |
writeAscii(byte b)
|
protected void |
writeAscii(byte b1,
byte b2)
|
protected void |
writeAscii(java.lang.String str)
|
protected int |
writeAsEntity(int c)
Entity writing can be optimized quite nicely, since it only needs to output ascii characters. |
void |
writeAttribute(java.lang.String localName,
char[] value,
int offset,
int len)
|
void |
writeAttribute(java.lang.String localName,
java.lang.String value)
Note: can throw XMLStreamException, if name checking is enabled, and name is invalid (name check has to be in this writer, not caller, since it depends not only on xml limitations, but also on encoding limitations) |
void |
writeAttribute(java.lang.String prefix,
java.lang.String localName,
char[] value,
int offset,
int len)
|
void |
writeAttribute(java.lang.String prefix,
java.lang.String localName,
java.lang.String value)
Note: can throw XMLStreamException, if name checking is enabled, and name is invalid (name check has to be in this writer, not caller, since it depends not only on xml limitations, but also on encoding limitations) |
protected abstract void |
writeAttrValue(char[] value,
int offset,
int len)
|
protected abstract void |
writeAttrValue(java.lang.String data)
|
int |
writeCData(char[] cbuf,
int offset,
int len)
|
int |
writeCData(java.lang.String data)
|
protected abstract int |
writeCDataContent(char[] cbuf,
int start,
int len)
|
protected abstract int |
writeCDataContent(java.lang.String data)
|
void |
writeCDataEnd()
|
void |
writeCDataStart()
|
void |
writeCharacters(char[] cbuf,
int offset,
int len)
|
void |
writeCharacters(java.lang.String data)
|
int |
writeComment(java.lang.String data)
Method that will try to output the content as specified. |
protected abstract int |
writeCommentContent(java.lang.String data)
|
void |
writeCommentEnd()
|
void |
writeCommentStart()
|
void |
writeDTD(java.lang.String data)
Older "legacy" output method for outputting DOCTYPE declaration. |
void |
writeDTD(java.lang.String rootName,
java.lang.String systemId,
java.lang.String publicId,
java.lang.String internalSubset)
|
void |
writeEndTag(java.lang.String localName)
|
void |
writeEndTag(java.lang.String prefix,
java.lang.String localName)
|
void |
writeEntityReference(java.lang.String name)
|
protected void |
writeName(java.lang.String name)
|
protected void |
writeNameUnchecked(java.lang.String name)
|
int |
writePI(java.lang.String target,
java.lang.String data)
|
protected abstract int |
writePIData(java.lang.String data)
|
void |
writePIEnd()
|
void |
writePIStart(java.lang.String target,
boolean addSpace)
|
abstract void |
writeRaw(char[] cbuf,
int offset,
int len)
|
abstract void |
writeRaw(java.lang.String str,
int offset,
int len)
|
void |
writeStartTagEmptyEnd()
|
void |
writeStartTagEnd()
|
void |
writeStartTagStart(java.lang.String localName)
Note: can throw XMLStreamException, if name checking is enabled, and name is invalid (name check has to be in this writer, not caller, since it depends not only on xml limitations, but also on encoding limitations) |
void |
writeStartTagStart(java.lang.String prefix,
java.lang.String localName)
Note: can throw XMLStreamException, if name checking is enabled, and name is invalid (name check has to be in this writer, not caller, since it depends not only on xml limitations, but also on encoding limitations) |
protected abstract void |
writeTextContent(char[] cbuf,
int start,
int len)
|
protected abstract void |
writeTextContent(java.lang.String data)
|
void |
writeXmlDeclaration(java.lang.String version,
java.lang.String encoding,
java.lang.String standalone)
|
Methods inherited from class com.ctc.wstx.sw.XmlWriter |
---|
enableXml11, getAbsOffset, getColumn, getRow, reportNwfContent, reportNwfName, reportNwfName, throwInvalidChar, throwOutputError, throwOutputError, verifyNameValidity, wrapAsRawWriter, wrapAsTextWriter, writeRaw |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final java.io.OutputStream mOut
protected final byte[] mOutputBuffer
protected int mOutputPtr
protected int mSurrogate
writeRaw
or
writeCharacters
), the first part is temporarily stored
within this member variable.
Constructor Detail |
---|
public EncodingXmlWriter(java.io.OutputStream out, WriterConfig cfg, java.lang.String encoding, boolean autoclose) throws java.io.IOException
java.io.IOException
Method Detail |
---|
protected int getOutputPtr()
getOutputPtr
in class XmlWriter
protected final java.io.OutputStream getOutputStream()
getOutputStream
in class XmlWriter
protected final java.io.Writer getWriter()
getWriter
in class XmlWriter
public void close() throws java.io.IOException
XmlWriter
close
in class XmlWriter
java.io.IOException
public final void flush() throws java.io.IOException
flush
in class XmlWriter
java.io.IOException
public abstract void writeRaw(char[] cbuf, int offset, int len) throws java.io.IOException
writeRaw
in class XmlWriter
java.io.IOException
public abstract void writeRaw(java.lang.String str, int offset, int len) throws java.io.IOException
writeRaw
in class XmlWriter
java.io.IOException
public final void writeCDataStart() throws java.io.IOException
writeCDataStart
in class XmlWriter
java.io.IOException
public final void writeCDataEnd() throws java.io.IOException
writeCDataEnd
in class XmlWriter
java.io.IOException
public final void writeCommentStart() throws java.io.IOException
writeCommentStart
in class XmlWriter
java.io.IOException
public final void writeCommentEnd() throws java.io.IOException
writeCommentEnd
in class XmlWriter
java.io.IOException
public final void writePIStart(java.lang.String target, boolean addSpace) throws java.io.IOException
writePIStart
in class XmlWriter
java.io.IOException
public final void writePIEnd() throws java.io.IOException
writePIEnd
in class XmlWriter
java.io.IOException
public int writeCData(java.lang.String data) throws java.io.IOException
writeCData
in class XmlWriter
data
- Contents of the CDATA section to write out
java.io.IOException
public int writeCData(char[] cbuf, int offset, int len) throws java.io.IOException
writeCData
in class XmlWriter
java.io.IOException
public final void writeCharacters(java.lang.String data) throws java.io.IOException
writeCharacters
in class XmlWriter
java.io.IOException
public final void writeCharacters(char[] cbuf, int offset, int len) throws java.io.IOException
writeCharacters
in class XmlWriter
java.io.IOException
public int writeComment(java.lang.String data) throws java.io.IOException
writeComment
in class XmlWriter
java.io.IOException
public void writeDTD(java.lang.String data) throws java.io.IOException
XmlWriter
writeDTD
in class XmlWriter
java.io.IOException
public void writeDTD(java.lang.String rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset) throws java.io.IOException, javax.xml.stream.XMLStreamException
writeDTD
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
public void writeEntityReference(java.lang.String name) throws java.io.IOException, javax.xml.stream.XMLStreamException
writeEntityReference
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
public void writeXmlDeclaration(java.lang.String version, java.lang.String encoding, java.lang.String standalone) throws java.io.IOException
writeXmlDeclaration
in class XmlWriter
java.io.IOException
public int writePI(java.lang.String target, java.lang.String data) throws java.io.IOException, javax.xml.stream.XMLStreamException
writePI
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
public void writeStartTagStart(java.lang.String localName) throws java.io.IOException, javax.xml.stream.XMLStreamException
XmlWriter
Note: can throw XMLStreamException, if name checking is enabled, and name is invalid (name check has to be in this writer, not caller, since it depends not only on xml limitations, but also on encoding limitations)
writeStartTagStart
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
public void writeStartTagStart(java.lang.String prefix, java.lang.String localName) throws java.io.IOException, javax.xml.stream.XMLStreamException
XmlWriter
Note: can throw XMLStreamException, if name checking is enabled, and name is invalid (name check has to be in this writer, not caller, since it depends not only on xml limitations, but also on encoding limitations)
writeStartTagStart
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
public void writeStartTagEnd() throws java.io.IOException
writeStartTagEnd
in class XmlWriter
java.io.IOException
public void writeStartTagEmptyEnd() throws java.io.IOException
writeStartTagEmptyEnd
in class XmlWriter
java.io.IOException
public void writeEndTag(java.lang.String localName) throws java.io.IOException
writeEndTag
in class XmlWriter
java.io.IOException
public void writeEndTag(java.lang.String prefix, java.lang.String localName) throws java.io.IOException
writeEndTag
in class XmlWriter
java.io.IOException
public void writeAttribute(java.lang.String localName, java.lang.String value) throws java.io.IOException, javax.xml.stream.XMLStreamException
XmlWriter
Note: can throw XMLStreamException, if name checking is enabled, and name is invalid (name check has to be in this writer, not caller, since it depends not only on xml limitations, but also on encoding limitations)
writeAttribute
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
public void writeAttribute(java.lang.String localName, char[] value, int offset, int len) throws java.io.IOException, javax.xml.stream.XMLStreamException
writeAttribute
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
public void writeAttribute(java.lang.String prefix, java.lang.String localName, java.lang.String value) throws java.io.IOException, javax.xml.stream.XMLStreamException
XmlWriter
Note: can throw XMLStreamException, if name checking is enabled, and name is invalid (name check has to be in this writer, not caller, since it depends not only on xml limitations, but also on encoding limitations)
writeAttribute
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
public void writeAttribute(java.lang.String prefix, java.lang.String localName, char[] value, int offset, int len) throws java.io.IOException, javax.xml.stream.XMLStreamException
writeAttribute
in class XmlWriter
java.io.IOException
javax.xml.stream.XMLStreamException
protected final void flushBuffer() throws java.io.IOException
java.io.IOException
protected final void writeAscii(byte b) throws java.io.IOException
java.io.IOException
protected final void writeAscii(byte b1, byte b2) throws java.io.IOException
java.io.IOException
protected final void writeAscii(java.lang.String str) throws java.io.IOException
java.io.IOException
protected final int writeAsEntity(int c) throws java.io.IOException
mOutputPtr
java.io.IOException
protected final void writeName(java.lang.String name) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected final void writeNameUnchecked(java.lang.String name) throws java.io.IOException
java.io.IOException
protected final int calcSurrogate(int secondSurr) throws java.io.IOException
java.io.IOException
protected final void throwUnpairedSurrogate() throws java.io.IOException
java.io.IOException
protected final void throwUnpairedSurrogate(int code) throws java.io.IOException
java.io.IOException
protected abstract void writeAttrValue(java.lang.String data) throws java.io.IOException
java.io.IOException
protected abstract void writeAttrValue(char[] value, int offset, int len) throws java.io.IOException
java.io.IOException
protected abstract int writeCDataContent(java.lang.String data) throws java.io.IOException
java.io.IOException
protected abstract int writeCDataContent(char[] cbuf, int start, int len) throws java.io.IOException
java.io.IOException
protected abstract int writeCommentContent(java.lang.String data) throws java.io.IOException
java.io.IOException
protected abstract int writePIData(java.lang.String data) throws java.io.IOException, javax.xml.stream.XMLStreamException
java.io.IOException
javax.xml.stream.XMLStreamException
protected abstract void writeTextContent(java.lang.String data) throws java.io.IOException
java.io.IOException
protected abstract void writeTextContent(char[] cbuf, int start, int len) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |