Top Description Fields Constructors Methods
com.fasterxml.aalto.out

public final Class CharXmlWriter

extends XmlWriter
Class Inheritance
Imports
java.io.*, javax.xml.stream.*, org.codehaus.stax2.ri.typed.AsciiValueEncoder, com.fasterxml.aalto.impl.ErrorConsts, com.fasterxml.aalto.io.UTF8Writer, com.fasterxml.aalto.util.XmlCharTypes

This is the generic implementation of XmlWriter, used if the destination is a character based, like a java.io.Writer.

Field Summary

Modifier and TypeField and Description
protected Writer
_out

Actual Writer to use for outputting buffered data as appropriate.

protected char[]
protected final int
protected int
pack-priv static final int
DEFAULT_FULL_BUFFER_SIZE

And this value determines size of the intermediate copy buffer to use.

pack-priv static final int
DEFAULT_SMALL_SIZE

This value determines a threshold to choose how much data do we want to buffer at minimum, before output.

pack-priv final XmlCharTypes
mCharTypes

Validation tables used for verifying validity (and need for quoting)

private final int
mEncHighChar

First Unicode character (one with lowest value) after (and including) which character entities have to be used.

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.

private final int
mTableCheckEnd

First Unicode character that is NOT to be checked against static validity table.

Inherited from com.fasterxml.aalto.out.XmlWriter:
_cfgNsAware_checkContent_checkNames_config_copyBuffer_copyBufferLen_locPastChars_locRowNr_locRowStartOffset_xml11ATTR_MIN_ARRAYCOPYDEFAULT_COPYBUFFER_LENMIN_ARRAYCOPYSURR1_FIRSTSURR1_LASTSURR2_FIRSTSURR2_LAST

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
_closeTarget(boolean doClose)

Implements abstract com.fasterxml.aalto.out.XmlWriter._closeTarget.

public void
public WName
public WName
private final void
fastWriteRaw(char c)

private final void
fastWriteRaw(char c1, char c2)

private final void
public final void
private final void
public int
getHighestEncodable()

Implements abstract com.fasterxml.aalto.out.XmlWriter.getHighestEncodable.

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

Returns:

Index at which a problem was found, if any; -1 if there's no problem.
verifyCDataContent
(String content)

protected int
verifyCDataContent(char[] c, int start, int end)

protected int
protected final void
public void
writeAttribute(WName name, String value)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeAttribute.

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)

public void
writeAttribute(WName name, char[] value, int offset, int vlen)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeAttribute.

public final void
private final void
writeAttrValue(String value, int len)

private final void
writeAttrValue(char[] cbuf, int offset, int len)

public int

Returns:

-1 to indicate succesful write, or index of the problematic character in input (first ']' from "]]>" sequence, in non-fixing mode)
writeCData
(String
Contents of the CDATA section to write out
data
)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeCData.

public int
writeCData(char[] cbuf, int offset, int len)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeCData.

private int
writeCDataContents(char[] cbuf, int offset, int len)

public final void
public final void
public void
public void
writeCharacters(char[] cbuf, int offset, int len)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeCharacters.

public int
writeComment(String data)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeComment.

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).

public final void
public final void
public void
writeDTD(String data)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeDTD.

Older "legacy" output method for outputting DOCTYPE declaration.
public void
writeDTD(WName rootName, String systemId, String publicId, String internalSubset)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeDTD.

public void
public void
protected final void
public int
private int
writePIContents(char[] cbuf, int offset, int len)

public void
writeRaw(char[] cbuf, int offset, int len)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeRaw.

public void
writeRaw(String str, int offset, int len)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeRaw.

protected void
writeSegmentedCData(String content, int index)

protected void
writeSegmentedCData(char[] c, int start, int len, int index)

protected void
writeSegmentedComment(String content, int index)

public void
public void
writeSpace(char[] cbuf, int offset, int len)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeSpace.

private final void
writeSplitAttrValue(char[] cbuf, int offset, int len)

public void
public void
public void
writeStartTagStart(WName name)

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeStartTagStart.

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)

public void
public void
Inherited from com.fasterxml.aalto.out.XmlWriter:
closeenableXml11getAbsOffsetgetColumngetRowguessEncodingBitSizereportFailedEscapingreportInvalidCharreportInvalidEmptyNamereportNwfContentreportNwfContentreportNwfNamereportNwfNamethrowOutputErrorthrowOutputError

Field Detail

_outback to summary
protected 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.

_outputBufferback to summary
protected char[] _outputBuffer
_outputBufferLenback to summary
protected final int _outputBufferLen
_outputPtrback to summary
protected int _outputPtr
DEFAULT_FULL_BUFFER_SIZEback to summary
pack-priv static final int DEFAULT_FULL_BUFFER_SIZE

And this value determines size of the intermediate copy buffer to use.

DEFAULT_SMALL_SIZEback to summary
pack-priv static final int DEFAULT_SMALL_SIZE

This 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.

mCharTypesback to summary
pack-priv final XmlCharTypes mCharTypes

Validation tables used for verifying validity (and need for quoting)

mEncHighCharback to summary
private final int mEncHighChar

First Unicode character (one with lowest value) after (and including) which character entities have to be used.

mSmallWriteSizeback to summary
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.

mTableCheckEndback to summary
private final int mTableCheckEnd

First 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)

Constructor Detail

CharXmlWriterback to summary
public CharXmlWriter(WriterConfig cfg, Writer out)

Method Detail

_closeTargetback to summary
public void _closeTarget(boolean doClose) throws IOException

Implements abstract com.fasterxml.aalto.out.XmlWriter._closeTarget.

Annotations
@Override
_releaseBuffersback to summary
public void _releaseBuffers()

Overrides com.fasterxml.aalto.out.XmlWriter._releaseBuffers.

Annotations
@Override
constructNameback to summary
public WName constructName(String localName)

Implements abstract com.fasterxml.aalto.out.XmlWriter.constructName.

Annotations
@Override
constructNameback to summary
public WName constructName(String prefix, String localName)

Implements abstract com.fasterxml.aalto.out.XmlWriter.constructName.

Annotations
@Override
fastWriteRawback to summary
private final void fastWriteRaw(char c) throws IOException
fastWriteRawback to summary
private final void fastWriteRaw(char c1, char c2) throws IOException
fastWriteRawback to summary
private final void fastWriteRaw(String str) throws IOException
flushback to summary
public final void flush() throws IOException

Implements abstract com.fasterxml.aalto.out.XmlWriter.flush.

Annotations
@Override
flushBufferback to summary
private final void flushBuffer() throws IOException
getHighestEncodableback to summary
public int getHighestEncodable()

Implements abstract com.fasterxml.aalto.out.XmlWriter.getHighestEncodable.

Doc from com.fasterxml.aalto.out.XmlWriter.getHighestEncodable.

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.

Returns:int

Character code of the highest character that can be natively encoded.

Annotations
@Override
getOutputPtrback to summary
protected int getOutputPtr()

Implements abstract com.fasterxml.aalto.out.XmlWriter.getOutputPtr.

Annotations
@Override
verifyCDataContentback to summary
protected int verifyCDataContent(String content)
Returns:int

Index at which a problem was found, if any; -1 if there's no problem.

verifyCDataContentback to summary
protected int verifyCDataContent(char[] c, int start, int end)
verifyCommentContentback to summary
protected int verifyCommentContent(String content)
writeAsEntityback to summary
protected final void writeAsEntity(int c) throws IOException
writeAttributeback to summary
public void writeAttribute(WName name, String value) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeAttribute.

Doc from com.fasterxml.aalto.out.XmlWriter.writeAttribute.

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)

Annotations
@Override
writeAttributeback to summary
public void writeAttribute(WName name, char[] value, int offset, int vlen) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeAttribute.

Annotations
@Override
writeAttributeback to summary
public final void writeAttribute(WName name, AsciiValueEncoder enc) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeAttribute.

Annotations
@Override
writeAttrValueback to summary
private final void writeAttrValue(String value, int len) throws IOException, XMLStreamException
writeAttrValueback to summary
private final void writeAttrValue(char[] cbuf, int offset, int len) throws IOException, XMLStreamException
writeCDataback to summary
public int writeCData(String data) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeCData.

Parameters
data:String

Doc from com.fasterxml.aalto.out.XmlWriter.writeCData.

Contents of the CDATA section to write out

Returns:int

-1 to indicate succesful write, or index of the problematic character in input (first ']' from "]]>" sequence, in non-fixing mode)

Annotations
@Override
writeCDataback to summary
public int writeCData(char[] cbuf, int offset, int len) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeCData.

Annotations
@Override
writeCDataContentsback to summary
private int writeCDataContents(char[] cbuf, int offset, int len) throws IOException, XMLStreamException
writeCDataEndback to summary
public final void writeCDataEnd() throws IOException
writeCDataStartback to summary
public final void writeCDataStart() throws IOException
writeCharactersback to summary
public void writeCharacters(String text) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeCharacters.

Annotations
@Override
writeCharactersback to summary
public void writeCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeCharacters.

Annotations
@Override
writeCommentback to summary
public int writeComment(String data) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.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.

Annotations
@Override
writeCommentContentsback to summary
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).

writeCommentEndback to summary
public final void writeCommentEnd() throws IOException
writeCommentStartback to summary
public final void writeCommentStart() throws IOException
writeDTDback to summary
public void writeDTD(String data) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeDTD.

Doc from com.fasterxml.aalto.out.XmlWriter.writeDTD.

Older "legacy" output method for outputting DOCTYPE declaration. Assumes that the passed-in String contains a complete DOCTYPE declaration properly quoted.

Annotations
@Override
writeDTDback to summary
public void writeDTD(WName rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeDTD.

Annotations
@Override
writeEndTagback to summary
public void writeEndTag(WName name) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeEndTag.

Annotations
@Override
writeEntityReferenceback to summary
public void writeEntityReference(WName name) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeEntityReference.

Annotations
@Override
writeNameback to summary
protected final void writeName(WName name) throws IOException
writePIback to summary
public int writePI(WName target, String data) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writePI.

Annotations
@Override
writePIContentsback to summary
private int writePIContents(char[] cbuf, int offset, int len) throws IOException, XMLStreamException
writeRawback to summary
public void writeRaw(char[] cbuf, int offset, int len) throws IOException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeRaw.

Annotations
@Override
writeRawback to summary
public void writeRaw(String str, int offset, int len) throws IOException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeRaw.

Annotations
@Override
writeSegmentedCDataback to summary
protected void writeSegmentedCData(String content, int index) throws IOException
writeSegmentedCDataback to summary
protected void writeSegmentedCData(char[] c, int start, int len, int index) throws IOException
writeSegmentedCommentback to summary
protected void writeSegmentedComment(String content, int index) throws IOException
writeSpaceback to summary
public void writeSpace(String data) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeSpace.

Annotations
@Override
writeSpaceback to summary
public void writeSpace(char[] cbuf, int offset, int len) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeSpace.

Annotations
@Override
writeSplitAttrValueback to summary
private final void writeSplitAttrValue(char[] cbuf, int offset, int len) throws IOException, XMLStreamException
writeStartTagEmptyEndback to summary
public void writeStartTagEmptyEnd() throws IOException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeStartTagEmptyEnd.

Annotations
@Override
writeStartTagEndback to summary
public void writeStartTagEnd() throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeStartTagEnd.

Annotations
@Override
writeStartTagStartback to summary
public void writeStartTagStart(WName name) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeStartTagStart.

Doc from com.fasterxml.aalto.out.XmlWriter.writeStartTagStart.

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)

Annotations
@Override
writeTypedValueback to summary
public void writeTypedValue(AsciiValueEncoder enc) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeTypedValue.

Annotations
@Override
writeXmlDeclarationback to summary
public void writeXmlDeclaration(String version, String encoding, String standalone) throws IOException, XMLStreamException

Implements abstract com.fasterxml.aalto.out.XmlWriter.writeXmlDeclaration.

Annotations
@Override