public abstract class EncodingXmlWriter extends XmlWriter
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.
Modifier and Type | Field and Description |
---|---|
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. |
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 and Description |
---|
EncodingXmlWriter(OutputStream out,
WriterConfig cfg,
String encoding,
boolean autoclose) |
Modifier and Type | Method and Description |
---|---|
protected int |
calcSurrogate(int secondSurr) |
void |
close(boolean forceRealClose)
Method called to flush the buffer(s), and close the output
sink (stream or writer) if enabled (auto-closing) or
forced.
|
void |
flush() |
protected void |
flushBuffer() |
protected int |
getOutputPtr()
This method is needed by the super class, to calculate hard
byte/char offsets.
|
protected OutputStream |
getOutputStream() |
protected 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(String str) |
protected int |
writeAsEntity(int c)
Entity writing can be optimized quite nicely, since it only
needs to output ascii characters.
|
void |
writeAttribute(String localName,
char[] value,
int offset,
int len) |
void |
writeAttribute(String localName,
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(String prefix,
String localName,
char[] value,
int offset,
int len) |
void |
writeAttribute(String prefix,
String localName,
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(String data) |
int |
writeCData(char[] cbuf,
int offset,
int len) |
int |
writeCData(String data) |
protected abstract int |
writeCDataContent(char[] cbuf,
int start,
int len) |
protected abstract int |
writeCDataContent(String data) |
void |
writeCDataEnd() |
void |
writeCDataStart() |
void |
writeCharacters(char[] cbuf,
int offset,
int len) |
void |
writeCharacters(String data) |
int |
writeComment(String data)
Method that will try to output the content as specified.
|
protected abstract int |
writeCommentContent(String data) |
void |
writeCommentEnd() |
void |
writeCommentStart() |
void |
writeDTD(String data)
Older "legacy" output method for outputting DOCTYPE declaration.
|
void |
writeDTD(String rootName,
String systemId,
String publicId,
String internalSubset) |
void |
writeEndTag(String localName) |
void |
writeEndTag(String prefix,
String localName) |
void |
writeEntityReference(String name) |
protected void |
writeName(String name) |
protected void |
writeNameUnchecked(String name) |
int |
writePI(String target,
String data) |
protected abstract int |
writePIData(String data) |
void |
writePIEnd() |
void |
writePIStart(String target,
boolean addSpace) |
abstract void |
writeRaw(char[] cbuf,
int offset,
int len) |
abstract void |
writeRaw(String str,
int offset,
int len) |
void |
writeRawAscii(char[] buf,
int offset,
int len)
Like
XmlWriter.writeRaw(java.lang.String, int, int) , but caller guarantees that the contents
additionally are known to be in 7-bit ascii range. |
void |
writeStartTagEmptyEnd() |
void |
writeStartTagEnd() |
void |
writeStartTagStart(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(String prefix,
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(String data) |
void |
writeTypedAttribute(String localName,
org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)
Method similar to
XmlWriter.writeAttribute(String,String,char[],int,int)
but where is known not to require escaping. |
void |
writeTypedAttribute(String prefix,
String localName,
org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)
Method similar to
XmlWriter.writeAttribute(String,String,char[],int,int)
but where is known not to require escaping. |
void |
writeTypedAttribute(String prefix,
String localName,
String nsURI,
org.codehaus.stax2.ri.typed.AsciiValueEncoder enc,
org.codehaus.stax2.validation.XMLValidator validator,
char[] copyBuffer)
Method similar to
XmlWriter.writeAttribute(String,String,char[],int,int)
but where is known not to require escaping. |
void |
writeTypedElement(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)
Non-validating version of typed write method
|
void |
writeTypedElement(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc,
org.codehaus.stax2.validation.XMLValidator validator,
char[] copyBuffer)
Validating version of typed write method
|
void |
writeXmlDeclaration(String version,
String encoding,
String standalone) |
enableXml11, getAbsOffset, getColumn, getRow, handleInvalidChar, reportNwfContent, reportNwfName, reportNwfName, throwOutputError, throwOutputError, verifyNameValidity, wrapAsRawWriter, wrapAsTextWriter, writeRaw
protected byte[] mOutputBuffer
protected int mOutputPtr
protected int mSurrogate
writeRaw
or
writeCharacters
), the first part is temporarily stored
within this member variable.public EncodingXmlWriter(OutputStream out, WriterConfig cfg, String encoding, boolean autoclose) throws IOException
IOException
protected int getOutputPtr()
getOutputPtr
in class XmlWriter
protected final OutputStream getOutputStream()
getOutputStream
in class XmlWriter
protected final Writer getWriter()
public void close(boolean forceRealClose) throws IOException
XmlWriter
close
in class XmlWriter
IOException
public final void flush() throws IOException
flush
in class XmlWriter
IOException
public abstract void writeRaw(char[] cbuf, int offset, int len) throws IOException
writeRaw
in class XmlWriter
IOException
public abstract void writeRaw(String str, int offset, int len) throws IOException
writeRaw
in class XmlWriter
IOException
public final void writeCDataStart() throws IOException
writeCDataStart
in class XmlWriter
IOException
public final void writeCDataEnd() throws IOException
writeCDataEnd
in class XmlWriter
IOException
public final void writeCommentStart() throws IOException
writeCommentStart
in class XmlWriter
IOException
public final void writeCommentEnd() throws IOException
writeCommentEnd
in class XmlWriter
IOException
public final void writePIStart(String target, boolean addSpace) throws IOException
writePIStart
in class XmlWriter
IOException
public final void writePIEnd() throws IOException
writePIEnd
in class XmlWriter
IOException
public int writeCData(String data) throws IOException
writeCData
in class XmlWriter
data
- Contents of the CDATA section to write outIOException
public int writeCData(char[] cbuf, int offset, int len) throws IOException
writeCData
in class XmlWriter
IOException
public final void writeCharacters(String data) throws IOException
writeCharacters
in class XmlWriter
IOException
public final void writeCharacters(char[] cbuf, int offset, int len) throws IOException
writeCharacters
in class XmlWriter
IOException
public int writeComment(String data) throws IOException
writeComment
in class XmlWriter
IOException
public void writeDTD(String data) throws IOException
XmlWriter
writeDTD
in class XmlWriter
IOException
public void writeDTD(String rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException
writeDTD
in class XmlWriter
IOException
XMLStreamException
public void writeEntityReference(String name) throws IOException, XMLStreamException
writeEntityReference
in class XmlWriter
IOException
XMLStreamException
public void writeXmlDeclaration(String version, String encoding, String standalone) throws IOException
writeXmlDeclaration
in class XmlWriter
IOException
public int writePI(String target, String data) throws IOException, XMLStreamException
writePI
in class XmlWriter
IOException
XMLStreamException
public void writeStartTagStart(String localName) throws IOException, 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
IOException
XMLStreamException
public void writeStartTagStart(String prefix, String localName) throws IOException, 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
IOException
XMLStreamException
public void writeStartTagEnd() throws IOException
writeStartTagEnd
in class XmlWriter
IOException
public void writeStartTagEmptyEnd() throws IOException
writeStartTagEmptyEnd
in class XmlWriter
IOException
public void writeEndTag(String localName) throws IOException
writeEndTag
in class XmlWriter
IOException
public void writeEndTag(String prefix, String localName) throws IOException
writeEndTag
in class XmlWriter
IOException
public void writeAttribute(String localName, String value) throws IOException, 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
IOException
XMLStreamException
public void writeAttribute(String localName, char[] value, int offset, int len) throws IOException, XMLStreamException
writeAttribute
in class XmlWriter
IOException
XMLStreamException
public void writeAttribute(String prefix, String localName, String value) throws IOException, 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
IOException
XMLStreamException
public void writeAttribute(String prefix, String localName, char[] value, int offset, int len) throws IOException, XMLStreamException
writeAttribute
in class XmlWriter
IOException
XMLStreamException
public final void writeTypedElement(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException
writeTypedElement
in class XmlWriter
enc
- Encoder that will produce contentIOException
public final void writeTypedElement(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc, org.codehaus.stax2.validation.XMLValidator validator, char[] copyBuffer) throws IOException, XMLStreamException
writeTypedElement
in class XmlWriter
enc
- Encoder that will produce contentvalidator
- Validator to use for validating serialized textual
content (can not be null)copyBuffer
- Temporary buffer that writer can use for temporary
copies as necessaryIOException
XMLStreamException
public void writeTypedAttribute(String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException
XmlWriter
XmlWriter.writeAttribute(String,String,char[],int,int)
but where is known not to require escaping.
No validation needs to be performed.writeTypedAttribute
in class XmlWriter
IOException
XMLStreamException
public void writeTypedAttribute(String prefix, String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException
XmlWriter
XmlWriter.writeAttribute(String,String,char[],int,int)
but where is known not to require escaping.
No validation needs to be performed.writeTypedAttribute
in class XmlWriter
IOException
XMLStreamException
public void writeTypedAttribute(String prefix, String localName, String nsURI, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc, org.codehaus.stax2.validation.XMLValidator validator, char[] copyBuffer) throws IOException, XMLStreamException
XmlWriter
XmlWriter.writeAttribute(String,String,char[],int,int)
but where is known not to require escaping.
Validation of the attribute value must be done by calling given
validator appropriately.writeTypedAttribute
in class XmlWriter
IOException
XMLStreamException
protected final void flushBuffer() throws IOException
IOException
protected final void writeAscii(byte b) throws IOException
IOException
protected final void writeAscii(byte b1, byte b2) throws IOException
IOException
protected final void writeAscii(String str) throws IOException
IOException
public final void writeRawAscii(char[] buf, int offset, int len) throws IOException
XmlWriter
XmlWriter.writeRaw(java.lang.String, int, int)
, but caller guarantees that the contents
additionally are known to be in 7-bit ascii range.writeRawAscii
in class XmlWriter
IOException
protected final int writeAsEntity(int c) throws IOException
mOutputPtr
IOException
protected final void writeName(String name) throws IOException, XMLStreamException
IOException
XMLStreamException
protected final void writeNameUnchecked(String name) throws IOException
IOException
protected final int calcSurrogate(int secondSurr) throws IOException
IOException
protected final void throwUnpairedSurrogate() throws IOException
IOException
protected final void throwUnpairedSurrogate(int code) throws IOException
IOException
protected abstract void writeAttrValue(String data) throws IOException
IOException
protected abstract void writeAttrValue(char[] value, int offset, int len) throws IOException
IOException
protected abstract int writeCDataContent(String data) throws IOException
IOException
protected abstract int writeCDataContent(char[] cbuf, int start, int len) throws IOException
IOException
protected abstract int writeCommentContent(String data) throws IOException
IOException
protected abstract int writePIData(String data) throws IOException, XMLStreamException
IOException
XMLStreamException
protected abstract void writeTextContent(String data) throws IOException
IOException
protected abstract void writeTextContent(char[] cbuf, int start, int len) throws IOException
IOException
Copyright © 2012–2015 FasterXML. All rights reserved.