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

public abstract Class XmlWriter

extends WNameFactory
Class Inheritance
Known Direct Subclasses
com.fasterxml.aalto.out.ByteXmlWriter, com.fasterxml.aalto.out.CharXmlWriter
Imports
java.io.*, java.text.MessageFormat, javax.xml.stream.*, org.codehaus.stax2.ri.typed.AsciiValueEncoder, com.fasterxml.aalto.impl.ErrorConsts, .IoStreamException, com.fasterxml.aalto.util.CharsetNames, .XmlChars, .XmlConsts

Base class for output type / encoding-specific serializers used to do actual physical output of serialized xml content. At this level, no namespace handling is done, and only those checks directly related to encoding (including optional validity checks for xml content) are implemented.

Field Summary

Modifier and TypeField and Description
protected final boolean
protected final boolean
protected final boolean
protected final WriterConfig
protected char[]
_copyBuffer

Intermediate buffer, in which content (esp.

protected final int
protected int
_locPastChars

Number of characters output prior to currently buffered output

protected int
protected int
_locRowStartOffset

Offset of the first character on this line.

protected boolean
_xml11

Indicates whether output is to be compliant; if false, is to be xml 1.0 compliant, if true, xml 1.1 compliant.

protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int
protected static final int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

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

public void
public final void
close(boolean forceTargetClose)

Method called to flush the buffer(s), and close the output sink (stream or writer).

public abstract WName
public abstract WName
public void
public abstract void
public int
public int
public abstract int

Returns:

Character code of the highest character that can be natively encoded.
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 abstract int
public int
public static final int
guessEncodingBitSize(WriterConfig cfg)

Method used to figure out which part of the Unicode char set the encoding can natively support.

protected void
protected void
protected void
protected void
protected void
reportNwfContent(String format, Object arg1, Object arg2)

protected void
reportNwfName(String msg)

This is the method called when an output method call violates name well-formedness checks and name validation is enabled.

protected void
protected void
protected void
public abstract 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)

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

public abstract void
public abstract int

Returns:

offset of the (first) illegal content segment ("]]>") in passed content, if not in repairing mode; or -1 if none
writeCData
(String
Contents of the CDATA section to write out
data
)

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

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

public abstract int
writeComment(String data)

Method that will try to output the content as specified.

public abstract void
writeDTD(String data)

Older "legacy" output method for outputting DOCTYPE declaration.

public abstract void
writeDTD(WName rootName, String systemId, String publicId, String internalSubset)

public abstract void
public abstract void
public abstract int
writePI(WName target, String data)

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

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

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

public abstract void
public abstract void
public abstract 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)

public abstract void
public abstract void
writeXmlDeclaration(String version, String enc, String standalone)

Field Detail

_cfgNsAwareback to summary
protected final boolean _cfgNsAware
_checkContentback to summary
protected final boolean _checkContent
_checkNamesback to summary
protected final boolean _checkNames
_configback to summary
protected final WriterConfig _config
_copyBufferback to summary
protected char[] _copyBuffer

Intermediate buffer, in which content (esp. Strings) can be copied to, before being output.

_copyBufferLenback to summary
protected final int _copyBufferLen
_locPastCharsback to summary
protected int _locPastChars

Number of characters output prior to currently buffered output

_locRowNrback to summary
protected int _locRowNr
_locRowStartOffsetback to summary
protected int _locRowStartOffset

Offset of the first character on this line. May be negative, if the offset was in a buffer that has been flushed out.

_xml11back to summary
protected boolean _xml11

Indicates whether output is to be compliant; if false, is to be xml 1.0 compliant, if true, xml 1.1 compliant.

ATTR_MIN_ARRAYCOPYback to summary
protected static final int ATTR_MIN_ARRAYCOPY
DEFAULT_COPYBUFFER_LENback to summary
protected static final int DEFAULT_COPYBUFFER_LEN
MIN_ARRAYCOPYback to summary
protected static final int MIN_ARRAYCOPY
SURR1_FIRSTback to summary
protected static final int SURR1_FIRST
SURR1_LASTback to summary
protected static final int SURR1_LAST
SURR2_FIRSTback to summary
protected static final int SURR2_FIRST
SURR2_LASTback to summary
protected static final int SURR2_LAST

Constructor Detail

XmlWriterback to summary
protected XmlWriter(WriterConfig cfg)

Method Detail

_closeTargetback to summary
public abstract void _closeTarget(boolean doClose) throws IOException
_releaseBuffersback to summary
public void _releaseBuffers()
closeback to summary
public final void close(boolean forceTargetClose) throws IOException

Method called to flush the buffer(s), and close the output sink (stream or writer).

constructNameback to summary
public abstract WName constructName(String localName) throws XMLStreamException

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

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

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

Annotations
@Override
enableXml11back to summary
public void enableXml11()
flushback to summary
public abstract void flush() throws IOException
getAbsOffsetback to summary
public int getAbsOffset()
getColumnback to summary
public int getColumn()
getHighestEncodableback to summary
public abstract int 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.

getOutputPtrback to summary
protected abstract int getOutputPtr()
getRowback to summary
public int getRow()
guessEncodingBitSizeback to summary
public static final int guessEncodingBitSize(WriterConfig cfg)

Method used to figure out which part of the Unicode char set the encoding can natively support. Values returned are 7, 8 and 16, to indicate (respectively) "ascii", "ISO-Latin" and "native Unicode". These just best guesses, but should work ok for the most common encodings.

reportFailedEscapingback to summary
protected void reportFailedEscaping(String type, int ch) throws XMLStreamException
reportInvalidCharback to summary
protected void reportInvalidChar(int c) throws XMLStreamException
reportInvalidEmptyNameback to summary
protected void reportInvalidEmptyName() throws XMLStreamException
reportNwfContentback to summary
protected void reportNwfContent(String msg) throws XMLStreamException
reportNwfContentback to summary
protected void reportNwfContent(String format, Object arg1, Object arg2) throws XMLStreamException
reportNwfNameback to summary
protected void reportNwfName(String msg) throws XMLStreamException

This is the method called when an output method call violates name well-formedness checks and name validation is enabled.

reportNwfNameback to summary
protected void reportNwfName(String msg, Object arg) throws XMLStreamException
throwOutputErrorback to summary
protected void throwOutputError(String msg) throws XMLStreamException
throwOutputErrorback to summary
protected void throwOutputError(String format, Object arg) throws XMLStreamException
writeAttributeback to summary
public abstract void writeAttribute(WName name, String value) throws IOException, XMLStreamException

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)

writeAttributeback to summary
public abstract void writeAttribute(WName name, char[] value, int offset, int len) throws IOException, XMLStreamException
writeAttributeback to summary
public abstract void writeAttribute(WName name, AsciiValueEncoder enc) throws IOException, XMLStreamException
writeCDataback to summary
public abstract int writeCData(String data) throws IOException, XMLStreamException
Parameters
data:String

Contents of the CDATA section to write out

Returns:int

offset of the (first) illegal content segment ("]]>") in passed content, if not in repairing mode; or -1 if none

writeCDataback to summary
public abstract int writeCData(char[] cbuf, int offset, int len) throws IOException, XMLStreamException
writeCharactersback to summary
public abstract void writeCharacters(String data) throws IOException, XMLStreamException
writeCharactersback to summary
public abstract void writeCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException
writeCommentback to summary
public abstract int writeComment(String data) throws IOException, XMLStreamException

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.

writeDTDback to summary
public abstract void writeDTD(String data) throws IOException, XMLStreamException

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

writeDTDback to summary
public abstract void writeDTD(WName rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException
writeEndTagback to summary
public abstract void writeEndTag(WName name) throws IOException, XMLStreamException
writeEntityReferenceback to summary
public abstract void writeEntityReference(WName name) throws IOException, XMLStreamException
writePIback to summary
public abstract int writePI(WName target, String data) throws IOException, XMLStreamException
writeRawback to summary
public abstract void writeRaw(String str, int offset, int len) throws IOException, XMLStreamException
writeRawback to summary
public abstract void writeRaw(char[] cbuf, int offset, int len) throws IOException, XMLStreamException
writeSpaceback to summary
public abstract void writeSpace(String data) throws IOException, XMLStreamException
writeSpaceback to summary
public abstract void writeSpace(char[] cbuf, int offset, int len) throws IOException, XMLStreamException
writeStartTagEmptyEndback to summary
public abstract void writeStartTagEmptyEnd() throws IOException, XMLStreamException
writeStartTagEndback to summary
public abstract void writeStartTagEnd() throws IOException, XMLStreamException
writeStartTagStartback to summary
public abstract void writeStartTagStart(WName name) throws IOException, XMLStreamException

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)

writeTypedValueback to summary
public abstract void writeTypedValue(AsciiValueEncoder enc) throws IOException, XMLStreamException
writeXmlDeclarationback to summary
public abstract void writeXmlDeclaration(String version, String enc, String standalone) throws IOException, XMLStreamException