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 WriterActual Writer to use for outputting buffered data as appropriate.protected char[]protected final intprotected int(package private) static final intAnd this value determines size of the intermediate copy buffer to use.(package private) static final intThis value determines a threshold to choose how much data do we want to buffer at minimum, before output.(package private) final XmlCharTypesValidation tables used for verifying validity (and need for quoting)private final intFirst Unicode character (one with lowest value) after (and including) which character entities have to be used.protected final intThis 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 intFirst Unicode character that is NOT to be checked against static validity table.Fields inherited from class 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) voidconstructName(String localName) constructName(String prefix, String localName) private final voidfastWriteRaw(char c) private final voidfastWriteRaw(char c1, char c2) private final voidfastWriteRaw(String str) final voidflush()private final voidintMethod 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 intprotected intverifyCDataContent(char[] c, int start, int end) protected intverifyCDataContent(String content) protected intverifyCommentContent(String content) protected final voidwriteAsEntity(int c) voidwriteAttribute(WName name, char[] value, int offset, int vlen) voidwriteAttribute(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 voidwriteAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) private final voidwriteAttrValue(char[] cbuf, int offset, int len) private final voidwriteAttrValue(String value, int len) intwriteCData(char[] cbuf, int offset, int len) intwriteCData(String data) private intwriteCDataContents(char[] cbuf, int offset, int len) final voidfinal voidvoidwriteCharacters(char[] cbuf, int offset, int len) voidwriteCharacters(String text) intwriteComment(String data) Method that will try to output the content as specified.private intwriteCommentContents(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 voidfinal voidvoidvoidOlder "legacy" output method for outputting DOCTYPE declaration.voidwriteEndTag(WName name) voidwriteEntityReference(WName name) protected final voidintprivate intwritePIContents(char[] cbuf, int offset, int len) voidwriteRaw(char[] cbuf, int offset, int len) voidprotected voidwriteSegmentedCData(char[] c, int start, int len, int index) protected voidwriteSegmentedCData(String content, int index) protected voidwriteSegmentedComment(String content, int index) voidwriteSpace(char[] cbuf, int offset, int len) voidwriteSpace(String data) private final voidwriteSplitAttrValue(char[] cbuf, int offset, int len) voidvoidvoidwriteStartTagStart(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)voidwriteTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) voidwriteXmlDeclaration(String version, String encoding, String standalone) Methods inherited from class 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:
getOutputPtrin classXmlWriter
-
getHighestEncodable
public int getHighestEncodable()Description copied from class:XmlWriterMethod 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:
getHighestEncodablein classXmlWriter- Returns:
- Character code of the highest character that can be natively encoded.
-
constructName
- Specified by:
constructNamein classXmlWriter
-
constructName
- Specified by:
constructNamein classXmlWriter
-
_releaseBuffers
public void _releaseBuffers()- Overrides:
_releaseBuffersin classXmlWriter
-
_closeTarget
- Specified by:
_closeTargetin classXmlWriter- Throws:
IOException
-
flush
- Specified by:
flushin classXmlWriter- Throws:
IOException
-
writeRaw
- Specified by:
writeRawin classXmlWriter- Throws:
IOException
-
writeRaw
- Specified by:
writeRawin classXmlWriter- Throws:
IOException
-
writeCDataStart
- Throws:
IOException
-
writeCDataEnd
- Throws:
IOException
-
writeCommentStart
- Throws:
IOException
-
writeCommentEnd
- Throws:
IOException
-
writeCData
- Specified by:
writeCDatain 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:
IOExceptionXMLStreamException
-
writeCData
- Specified by:
writeCDatain classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeCDataContents
private int writeCDataContents(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeCharacters
- Specified by:
writeCharactersin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeCharacters
public void writeCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Specified by:
writeCharactersin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeSpace
- Specified by:
writeSpacein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeSpace
- Specified by:
writeSpacein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
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:
writeCommentin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
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:
IOExceptionXMLStreamException
-
writeDTD
Description copied from class:XmlWriterOlder "legacy" output method for outputting DOCTYPE declaration. Assumes that the passed-in String contains a complete DOCTYPE declaration properly quoted.- Specified by:
writeDTDin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeDTD
public void writeDTD(WName rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException - Specified by:
writeDTDin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeEntityReference
- Specified by:
writeEntityReferencein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeXmlDeclaration
public void writeXmlDeclaration(String version, String encoding, String standalone) throws IOException, XMLStreamException - Specified by:
writeXmlDeclarationin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writePI
- Specified by:
writePIin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writePIContents
private int writePIContents(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeStartTagStart
Description copied from class: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)
- Specified by:
writeStartTagStartin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeStartTagEnd
- Specified by:
writeStartTagEndin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeStartTagEmptyEnd
- Specified by:
writeStartTagEmptyEndin classXmlWriter- Throws:
IOException
-
writeEndTag
- Specified by:
writeEndTagin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeAttribute
Description copied from class: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)
- Specified by:
writeAttributein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeAttribute
public void writeAttribute(WName name, char[] value, int offset, int vlen) throws IOException, XMLStreamException - Specified by:
writeAttributein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeAttrValue
- Throws:
IOExceptionXMLStreamException
-
writeAttrValue
private final void writeAttrValue(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeSplitAttrValue
private final void writeSplitAttrValue(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeTypedValue
public void writeTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Specified by:
writeTypedValuein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeAttribute
public final void writeAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Specified by:
writeAttributein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
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
-