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
Fields Modifier and Type Field Description protected java.io.Writer_outActual Writer to use for outputting buffered data as appropriate.protected char[]_outputBufferprotected int_outputBufferLenprotected int_outputPtrprotected intmSmallWriteSizeThis 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.-
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 Constructor Description CharXmlWriter(WriterConfig cfg, java.io.Writer out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void_closeTarget(boolean doClose)void_releaseBuffers()WNameconstructName(java.lang.String localName)WNameconstructName(java.lang.String prefix, java.lang.String localName)voidflush()intgetHighestEncodable()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 intgetOutputPtr()protected intverifyCDataContent(char[] c, int start, int end)protected intverifyCDataContent(java.lang.String content)protected intverifyCommentContent(java.lang.String content)protected voidwriteAsEntity(int c)voidwriteAttribute(WName name, char[] value, int offset, int vlen)voidwriteAttribute(WName name, 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)voidwriteAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)intwriteCData(char[] cbuf, int offset, int len)intwriteCData(java.lang.String data)voidwriteCDataEnd()voidwriteCDataStart()voidwriteCharacters(char[] cbuf, int offset, int len)voidwriteCharacters(java.lang.String text)intwriteComment(java.lang.String data)Method that will try to output the content as specified.voidwriteCommentEnd()voidwriteCommentStart()voidwriteDTD(WName rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset)voidwriteDTD(java.lang.String data)Older "legacy" output method for outputting DOCTYPE declaration.voidwriteEndTag(WName name)voidwriteEntityReference(WName name)protected voidwriteName(WName name)intwritePI(WName target, java.lang.String data)voidwriteRaw(char[] cbuf, int offset, int len)voidwriteRaw(java.lang.String str, int offset, int len)protected voidwriteSegmentedCData(char[] c, int start, int len, int index)protected voidwriteSegmentedCData(java.lang.String content, int index)protected voidwriteSegmentedComment(java.lang.String content, int index)voidwriteSpace(char[] cbuf, int offset, int len)voidwriteSpace(java.lang.String data)voidwriteStartTagEmptyEnd()voidwriteStartTagEnd()voidwriteStartTagStart(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(java.lang.String version, java.lang.String encoding, java.lang.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 Detail
-
mSmallWriteSize
protected final int mSmallWriteSize
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.
-
_out
protected java.io.Writer _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
-
-
Constructor Detail
-
CharXmlWriter
public CharXmlWriter(WriterConfig cfg, java.io.Writer out)
-
-
Method Detail
-
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
public WName constructName(java.lang.String localName)
- Specified by:
constructNamein classXmlWriter
-
constructName
public WName constructName(java.lang.String prefix, java.lang.String localName)
- Specified by:
constructNamein classXmlWriter
-
_releaseBuffers
public void _releaseBuffers()
- Overrides:
_releaseBuffersin classXmlWriter
-
_closeTarget
public void _closeTarget(boolean doClose) throws java.io.IOException- Specified by:
_closeTargetin classXmlWriter- Throws:
java.io.IOException
-
flush
public final void flush() throws java.io.IOException
-
writeRaw
public void writeRaw(char[] cbuf, int offset, int len) throws java.io.IOException
-
writeRaw
public void writeRaw(java.lang.String str, int offset, int len) throws java.io.IOException
-
writeCDataStart
public final void writeCDataStart() throws java.io.IOException- Throws:
java.io.IOException
-
writeCDataEnd
public final void writeCDataEnd() throws java.io.IOException- Throws:
java.io.IOException
-
writeCommentStart
public final void writeCommentStart() throws java.io.IOException- Throws:
java.io.IOException
-
writeCommentEnd
public final void writeCommentEnd() throws java.io.IOException- Throws:
java.io.IOException
-
writeCData
public int writeCData(java.lang.String data) throws java.io.IOException, javax.xml.stream.XMLStreamException- 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:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeCData
public int writeCData(char[] cbuf, int offset, int len) throws java.io.IOException, javax.xml.stream.XMLStreamException- Specified by:
writeCDatain classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeCharacters
public void writeCharacters(java.lang.String text) throws java.io.IOException, javax.xml.stream.XMLStreamException- Specified by:
writeCharactersin classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeCharacters
public void writeCharacters(char[] cbuf, int offset, int len) throws java.io.IOException, javax.xml.stream.XMLStreamException- Specified by:
writeCharactersin classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeSpace
public void writeSpace(java.lang.String data) throws java.io.IOException, javax.xml.stream.XMLStreamException- Specified by:
writeSpacein classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeSpace
public void writeSpace(char[] cbuf, int offset, int len) throws java.io.IOException, javax.xml.stream.XMLStreamException- Specified by:
writeSpacein classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeComment
public int writeComment(java.lang.String data) throws java.io.IOException, javax.xml.stream.XMLStreamExceptionMethod 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:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeDTD
public void writeDTD(java.lang.String data) throws java.io.IOException, javax.xml.stream.XMLStreamExceptionDescription copied from class:XmlWriterOlder "legacy" output method for outputting DOCTYPE declaration. Assumes that the passed-in String contains a complete DOCTYPE declaration properly quoted.
-
writeDTD
public void writeDTD(WName rootName, java.lang.String systemId, java.lang.String publicId, java.lang.String internalSubset) throws java.io.IOException, javax.xml.stream.XMLStreamException
-
writeEntityReference
public void writeEntityReference(WName name) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Specified by:
writeEntityReferencein classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeXmlDeclaration
public void writeXmlDeclaration(java.lang.String version, java.lang.String encoding, java.lang.String standalone) throws java.io.IOException, javax.xml.stream.XMLStreamException- Specified by:
writeXmlDeclarationin classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writePI
public int writePI(WName target, java.lang.String data) throws java.io.IOException, javax.xml.stream.XMLStreamException
-
writeStartTagStart
public void writeStartTagStart(WName name) throws java.io.IOException, javax.xml.stream.XMLStreamException
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:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeStartTagEnd
public void writeStartTagEnd() throws java.io.IOException, javax.xml.stream.XMLStreamException- Specified by:
writeStartTagEndin classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeStartTagEmptyEnd
public void writeStartTagEmptyEnd() throws java.io.IOException- Specified by:
writeStartTagEmptyEndin classXmlWriter- Throws:
java.io.IOException
-
writeEndTag
public void writeEndTag(WName name) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Specified by:
writeEndTagin classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeAttribute
public void writeAttribute(WName name, java.lang.String value) throws java.io.IOException, javax.xml.stream.XMLStreamException
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:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeAttribute
public void writeAttribute(WName name, char[] value, int offset, int vlen) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Specified by:
writeAttributein classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeTypedValue
public void writeTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws java.io.IOException, javax.xml.stream.XMLStreamException- Specified by:
writeTypedValuein classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeAttribute
public final void writeAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws java.io.IOException, javax.xml.stream.XMLStreamException
- Specified by:
writeAttributein classXmlWriter- Throws:
java.io.IOExceptionjavax.xml.stream.XMLStreamException
-
writeName
protected final void writeName(WName name) throws java.io.IOException
- Throws:
java.io.IOException
-
verifyCDataContent
protected int verifyCDataContent(java.lang.String content)
- 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
protected int verifyCommentContent(java.lang.String content)
-
writeSegmentedCData
protected void writeSegmentedCData(java.lang.String content, int index) throws java.io.IOException- Throws:
java.io.IOException
-
writeSegmentedCData
protected void writeSegmentedCData(char[] c, int start, int len, int index) throws java.io.IOException- Throws:
java.io.IOException
-
writeSegmentedComment
protected void writeSegmentedComment(java.lang.String content, int index) throws java.io.IOException- Throws:
java.io.IOException
-
writeAsEntity
protected final void writeAsEntity(int c) throws java.io.IOException- Throws:
java.io.IOException
-
-