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, throwOutputError, throwOutputError, verifyNameValidity, wrapAsRawWriter, wrapAsTextWriter, writeRawprotected 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
IOExceptionprotected int getOutputPtr()
getOutputPtr in class XmlWriterprotected final OutputStream getOutputStream()
getOutputStream in class XmlWriterprotected final Writer getWriter()
public void close(boolean forceRealClose)
throws IOException
XmlWriterclose in class XmlWriterIOExceptionpublic final void flush()
throws IOException
flush in class XmlWriterIOExceptionpublic abstract void writeRaw(char[] cbuf,
int offset,
int len)
throws IOException
writeRaw in class XmlWriterIOExceptionpublic abstract void writeRaw(String str, int offset, int len) throws IOException
writeRaw in class XmlWriterIOExceptionpublic final void writeCDataStart()
throws IOException
writeCDataStart in class XmlWriterIOExceptionpublic final void writeCDataEnd()
throws IOException
writeCDataEnd in class XmlWriterIOExceptionpublic final void writeCommentStart()
throws IOException
writeCommentStart in class XmlWriterIOExceptionpublic final void writeCommentEnd()
throws IOException
writeCommentEnd in class XmlWriterIOExceptionpublic final void writePIStart(String target, boolean addSpace) throws IOException
writePIStart in class XmlWriterIOExceptionpublic final void writePIEnd()
throws IOException
writePIEnd in class XmlWriterIOExceptionpublic int writeCData(String data) throws IOException
writeCData in class XmlWriterdata - Contents of the CDATA section to write outIOExceptionpublic int writeCData(char[] cbuf,
int offset,
int len)
throws IOException
writeCData in class XmlWriterIOExceptionpublic final void writeCharacters(String data) throws IOException
writeCharacters in class XmlWriterIOExceptionpublic final void writeCharacters(char[] cbuf,
int offset,
int len)
throws IOException
writeCharacters in class XmlWriterIOExceptionpublic int writeComment(String data) throws IOException
writeComment in class XmlWriterIOExceptionpublic void writeDTD(String data) throws IOException
XmlWriterwriteDTD in class XmlWriterIOExceptionpublic void writeDTD(String rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException
writeDTD in class XmlWriterIOExceptionXMLStreamExceptionpublic void writeEntityReference(String name) throws IOException, XMLStreamException
writeEntityReference in class XmlWriterIOExceptionXMLStreamExceptionpublic void writeXmlDeclaration(String version, String encoding, String standalone) throws IOException
writeXmlDeclaration in class XmlWriterIOExceptionpublic int writePI(String target, String data) throws IOException, XMLStreamException
writePI in class XmlWriterIOExceptionXMLStreamExceptionpublic void writeStartTagStart(String localName) throws IOException, XMLStreamException
XmlWriterNote: 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 XmlWriterIOExceptionXMLStreamExceptionpublic void writeStartTagStart(String prefix, String localName) throws IOException, XMLStreamException
XmlWriterNote: 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 XmlWriterIOExceptionXMLStreamExceptionpublic void writeStartTagEnd()
throws IOException
writeStartTagEnd in class XmlWriterIOExceptionpublic void writeStartTagEmptyEnd()
throws IOException
writeStartTagEmptyEnd in class XmlWriterIOExceptionpublic void writeEndTag(String localName) throws IOException
writeEndTag in class XmlWriterIOExceptionpublic void writeEndTag(String prefix, String localName) throws IOException
writeEndTag in class XmlWriterIOExceptionpublic void writeAttribute(String localName, String value) throws IOException, XMLStreamException
XmlWriterNote: 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 XmlWriterIOExceptionXMLStreamExceptionpublic void writeAttribute(String localName, char[] value, int offset, int len) throws IOException, XMLStreamException
writeAttribute in class XmlWriterIOExceptionXMLStreamExceptionpublic void writeAttribute(String prefix, String localName, String value) throws IOException, XMLStreamException
XmlWriterNote: 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 XmlWriterIOExceptionXMLStreamExceptionpublic void writeAttribute(String prefix, String localName, char[] value, int offset, int len) throws IOException, XMLStreamException
writeAttribute in class XmlWriterIOExceptionXMLStreamExceptionpublic final void writeTypedElement(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)
throws IOException
writeTypedElement in class XmlWriterenc - Encoder that will produce contentIOExceptionpublic final void writeTypedElement(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc,
org.codehaus.stax2.validation.XMLValidator validator,
char[] copyBuffer)
throws IOException,
XMLStreamException
writeTypedElement in class XmlWriterenc - 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 necessaryIOExceptionXMLStreamExceptionpublic void writeTypedAttribute(String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException
XmlWriterXmlWriter.writeAttribute(String,String,char[],int,int)
but where is known not to require escaping.
No validation needs to be performed.writeTypedAttribute in class XmlWriterIOExceptionXMLStreamExceptionpublic void writeTypedAttribute(String prefix, String localName, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException
XmlWriterXmlWriter.writeAttribute(String,String,char[],int,int)
but where is known not to require escaping.
No validation needs to be performed.writeTypedAttribute in class XmlWriterIOExceptionXMLStreamExceptionpublic 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
XmlWriterXmlWriter.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 XmlWriterIOExceptionXMLStreamExceptionprotected final void flushBuffer()
throws IOException
IOExceptionprotected final void writeAscii(byte b)
throws IOException
IOExceptionprotected final void writeAscii(byte b1,
byte b2)
throws IOException
IOExceptionprotected final void writeAscii(String str) throws IOException
IOExceptionpublic final void writeRawAscii(char[] buf,
int offset,
int len)
throws IOException
XmlWriterXmlWriter.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 XmlWriterIOExceptionprotected final int writeAsEntity(int c)
throws IOException
mOutputPtrIOExceptionprotected final void writeName(String name) throws IOException, XMLStreamException
IOExceptionXMLStreamExceptionprotected final void writeNameUnchecked(String name) throws IOException
IOExceptionprotected final int calcSurrogate(int secondSurr)
throws IOException
IOExceptionprotected final void throwUnpairedSurrogate()
throws IOException
IOExceptionprotected final void throwUnpairedSurrogate(int code)
throws IOException
IOExceptionprotected abstract void writeAttrValue(String data) throws IOException
IOExceptionprotected abstract void writeAttrValue(char[] value,
int offset,
int len)
throws IOException
IOExceptionprotected abstract int writeCDataContent(String data) throws IOException
IOExceptionprotected abstract int writeCDataContent(char[] cbuf,
int start,
int len)
throws IOException
IOExceptionprotected abstract int writeCommentContent(String data) throws IOException
IOExceptionprotected abstract int writePIData(String data) throws IOException, XMLStreamException
IOExceptionXMLStreamExceptionprotected abstract void writeTextContent(String data) throws IOException
IOExceptionprotected abstract void writeTextContent(char[] cbuf,
int start,
int len)
throws IOException
IOExceptionCopyright © 2024 FasterXML. All rights reserved.