Package com.fasterxml.aalto.out
Class CharXmlWriter
java.lang.Object
com.fasterxml.aalto.out.WNameFactory
com.fasterxml.aalto.out.XmlWriter
com.fasterxml.aalto.out.CharXmlWriter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Writer
Actual Writer to use for outputting buffered data as appropriate.protected char[]
protected final int
protected int
(package private) static final int
And this value determines size of the intermediate copy buffer to use.(package private) static final int
This value determines a threshold to choose how much data do we want to buffer at minimum, before output.(package private) final XmlCharTypes
Validation tables used for verifying validity (and need for quoting)private final int
First Unicode character (one with lowest value) after (and including) which character entities have to be used.protected final int
This is the threshold used to check what is considered a "small" write; small writes will be buffered until resulting size will be above the threshold.private final int
First Unicode character that is NOT to be checked against static validity table.Fields inherited from class com.fasterxml.aalto.out.XmlWriter
_cfgNsAware, _checkContent, _checkNames, _config, _copyBuffer, _copyBufferLen, _locPastChars, _locRowNr, _locRowStartOffset, _xml11, ATTR_MIN_ARRAYCOPY, DEFAULT_COPYBUFFER_LEN, MIN_ARRAYCOPY, SURR1_FIRST, SURR1_LAST, SURR2_FIRST, SURR2_LAST
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
_closeTarget
(boolean doClose) void
constructName
(String localName) constructName
(String prefix, String localName) private final void
fastWriteRaw
(char c) private final void
fastWriteRaw
(char c1, char c2) private final void
fastWriteRaw
(String str) final void
flush()
private final void
int
Method called by error reporting code, to figure out if a given character is encodable (without using character entities) with the current encoding or not.protected int
protected int
verifyCDataContent
(char[] c, int start, int end) protected int
verifyCDataContent
(String content) protected int
verifyCommentContent
(String content) protected final void
writeAsEntity
(int c) void
writeAttribute
(WName name, char[] value, int offset, int vlen) void
writeAttribute
(WName name, 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)final void
writeAttribute
(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) private final void
writeAttrValue
(char[] cbuf, int offset, int len) private final void
writeAttrValue
(String value, int len) int
writeCData
(char[] cbuf, int offset, int len) int
writeCData
(String data) private int
writeCDataContents
(char[] cbuf, int offset, int len) final void
final void
void
writeCharacters
(char[] cbuf, int offset, int len) void
writeCharacters
(String text) int
writeComment
(String data) Method that will try to output the content as specified.private int
writeCommentContents
(char[] cbuf, int offset, int len, boolean last) Note: the only way to fix comment contents is to inject a space to split up consequtive '--' (or '-' that ends a comment).final void
final void
void
void
Older "legacy" output method for outputting DOCTYPE declaration.void
writeEndTag
(WName name) void
writeEntityReference
(WName name) protected final void
int
private int
writePIContents
(char[] cbuf, int offset, int len) void
writeRaw
(char[] cbuf, int offset, int len) void
protected void
writeSegmentedCData
(char[] c, int start, int len, int index) protected void
writeSegmentedCData
(String content, int index) protected void
writeSegmentedComment
(String content, int index) void
writeSpace
(char[] cbuf, int offset, int len) void
writeSpace
(String data) private final void
writeSplitAttrValue
(char[] cbuf, int offset, int len) void
void
void
writeStartTagStart
(WName name) 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
writeTypedValue
(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) void
writeXmlDeclaration
(String version, String encoding, String standalone) Methods inherited from class com.fasterxml.aalto.out.XmlWriter
close, enableXml11, getAbsOffset, getColumn, getRow, guessEncodingBitSize, reportFailedEscaping, reportInvalidChar, reportInvalidEmptyName, reportNwfContent, reportNwfContent, reportNwfName, reportNwfName, throwOutputError, throwOutputError
-
Field Details
-
DEFAULT_SMALL_SIZE
static final int DEFAULT_SMALL_SIZEThis value determines a threshold to choose how much data do we want to buffer at minimum, before output. This is done since actual underlying writer may have significant per-call overhead, and if so, it is much cheaper to coalesce content. But on the other hand, this extra buffering has overhead of its own, so we'll try to find a sweet spot.- See Also:
-
DEFAULT_FULL_BUFFER_SIZE
static final int DEFAULT_FULL_BUFFER_SIZEAnd this value determines size of the intermediate copy buffer to use.- See Also:
-
mSmallWriteSize
protected final int mSmallWriteSizeThis is the threshold used to check what is considered a "small" write; small writes will be buffered until resulting size will be above the threshold. -
_out
Actual Writer to use for outputting buffered data as appropriate. During active usage, remains as the writer initially set; set to null when this writer is closed. -
_outputBuffer
protected char[] _outputBuffer -
_outputPtr
protected int _outputPtr -
_outputBufferLen
protected final int _outputBufferLen -
mEncHighChar
private final int mEncHighCharFirst Unicode character (one with lowest value) after (and including) which character entities have to be used. -
mTableCheckEnd
private final int mTableCheckEndFirst Unicode character that is NOT to be checked against static validity table. Usually the size of check table, but lower for some encodings (like ascii) -
mCharTypes
Validation tables used for verifying validity (and need for quoting)
-
-
Constructor Details
-
CharXmlWriter
-
-
Method Details
-
getOutputPtr
protected int getOutputPtr()- Specified by:
getOutputPtr
in classXmlWriter
-
getHighestEncodable
public int getHighestEncodable()Description copied from class:XmlWriter
Method called by error reporting code, to figure out if a given character is encodable (without using character entities) with the current encoding or not.- Specified by:
getHighestEncodable
in classXmlWriter
- Returns:
- Character code of the highest character that can be natively encoded.
-
constructName
- Specified by:
constructName
in classXmlWriter
-
constructName
- Specified by:
constructName
in classXmlWriter
-
_releaseBuffers
public void _releaseBuffers()- Overrides:
_releaseBuffers
in classXmlWriter
-
_closeTarget
- Specified by:
_closeTarget
in classXmlWriter
- Throws:
IOException
-
flush
- Specified by:
flush
in classXmlWriter
- Throws:
IOException
-
writeRaw
- Specified by:
writeRaw
in classXmlWriter
- Throws:
IOException
-
writeRaw
- Specified by:
writeRaw
in classXmlWriter
- Throws:
IOException
-
writeCDataStart
- Throws:
IOException
-
writeCDataEnd
- Throws:
IOException
-
writeCommentStart
- Throws:
IOException
-
writeCommentEnd
- Throws:
IOException
-
writeCData
- Specified by:
writeCData
in classXmlWriter
- Parameters:
data
- Contents of the CDATA section to write out- Returns:
- -1 to indicate succesful write, or index of the problematic character in input (first ']' from "]]>" sequence, in non-fixing mode)
- Throws:
IOException
XMLStreamException
-
writeCData
- Specified by:
writeCData
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeCDataContents
private int writeCDataContents(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeCharacters
- Specified by:
writeCharacters
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeCharacters
public void writeCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Specified by:
writeCharacters
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeSpace
- Specified by:
writeSpace
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeSpace
- Specified by:
writeSpace
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeComment
Method that will try to output the content as specified. If the content passed in has embedded "--" in it, it will either add an intervening space between consequtive hyphens (if content fixing is enabled), or return the offset of the first hyphen in multi-hyphen sequence.- Specified by:
writeComment
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeCommentContents
private int writeCommentContents(char[] cbuf, int offset, int len, boolean last) throws IOException, XMLStreamException Note: the only way to fix comment contents is to inject a space to split up consequtive '--' (or '-' that ends a comment).- Throws:
IOException
XMLStreamException
-
writeDTD
Description copied from class:XmlWriter
Older "legacy" output method for outputting DOCTYPE declaration. Assumes that the passed-in String contains a complete DOCTYPE declaration properly quoted.- Specified by:
writeDTD
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeDTD
public void writeDTD(WName rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException - Specified by:
writeDTD
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeEntityReference
- Specified by:
writeEntityReference
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeXmlDeclaration
public void writeXmlDeclaration(String version, String encoding, String standalone) throws IOException, XMLStreamException - Specified by:
writeXmlDeclaration
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writePI
- Specified by:
writePI
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writePIContents
private int writePIContents(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeStartTagStart
Description copied from class: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)
- Specified by:
writeStartTagStart
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeStartTagEnd
- Specified by:
writeStartTagEnd
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeStartTagEmptyEnd
- Specified by:
writeStartTagEmptyEnd
in classXmlWriter
- Throws:
IOException
-
writeEndTag
- Specified by:
writeEndTag
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeAttribute
Description copied from class: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)
- Specified by:
writeAttribute
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeAttribute
public void writeAttribute(WName name, char[] value, int offset, int vlen) throws IOException, XMLStreamException - Specified by:
writeAttribute
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeAttrValue
- Throws:
IOException
XMLStreamException
-
writeAttrValue
private final void writeAttrValue(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeSplitAttrValue
private final void writeSplitAttrValue(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeTypedValue
public void writeTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Specified by:
writeTypedValue
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
writeAttribute
public final void writeAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Specified by:
writeAttribute
in classXmlWriter
- Throws:
IOException
XMLStreamException
-
flushBuffer
- Throws:
IOException
-
writeName
- Throws:
IOException
-
fastWriteRaw
- Throws:
IOException
-
fastWriteRaw
- Throws:
IOException
-
fastWriteRaw
- Throws:
IOException
-
verifyCDataContent
- Returns:
- Index at which a problem was found, if any; -1 if there's no problem.
-
verifyCDataContent
protected int verifyCDataContent(char[] c, int start, int end) -
verifyCommentContent
-
writeSegmentedCData
- Throws:
IOException
-
writeSegmentedCData
- Throws:
IOException
-
writeSegmentedComment
- Throws:
IOException
-
writeAsEntity
- Throws:
IOException
-