Package com.fasterxml.aalto.out
Class XmlWriter
java.lang.Object
com.fasterxml.aalto.out.WNameFactory
com.fasterxml.aalto.out.XmlWriter
- Direct Known Subclasses:
ByteXmlWriter
,CharXmlWriter
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
FieldsModifier and TypeFieldDescriptionprotected final boolean
protected final boolean
protected final boolean
protected final WriterConfig
protected char[]
Intermediate buffer, in which content (esp.protected final int
protected int
Number of characters output prior to currently buffered outputprotected int
protected int
Offset of the first character on this line.protected boolean
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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void
_closeTarget
(boolean doClose) void
final void
close
(boolean forceTargetClose) Method called to flush the buffer(s), and close the output sink (stream or writer).abstract WName
constructName
(String localName) abstract WName
constructName
(String prefix, String localName) void
abstract void
flush()
int
int
abstract 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 abstract int
int
getRow()
static final int
Method used to figure out which part of the Unicode char set the encoding can natively support.protected void
reportFailedEscaping
(String type, int ch) protected void
reportInvalidChar
(int c) protected void
protected void
reportNwfContent
(String msg) 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
reportNwfName
(String msg, Object arg) protected void
throwOutputError
(String msg) protected void
throwOutputError
(String format, Object arg) abstract void
writeAttribute
(WName name, char[] value, int offset, int len) 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)abstract void
writeAttribute
(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) abstract int
writeCData
(char[] cbuf, int offset, int len) abstract int
writeCData
(String data) abstract void
writeCharacters
(char[] cbuf, int offset, int len) abstract void
writeCharacters
(String data) abstract int
writeComment
(String data) Method that will try to output the content as specified.abstract void
abstract void
Older "legacy" output method for outputting DOCTYPE declaration.abstract void
writeEndTag
(WName name) abstract void
writeEntityReference
(WName name) abstract int
abstract void
writeRaw
(char[] cbuf, int offset, int len) abstract void
abstract void
writeSpace
(char[] cbuf, int offset, int len) abstract void
writeSpace
(String data) abstract void
abstract void
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)abstract void
writeTypedValue
(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) abstract void
writeXmlDeclaration
(String version, String enc, String standalone)
-
Field Details
-
SURR1_FIRST
protected static final int SURR1_FIRST- See Also:
-
SURR1_LAST
protected static final int SURR1_LAST- See Also:
-
SURR2_FIRST
protected static final int SURR2_FIRST- See Also:
-
SURR2_LAST
protected static final int SURR2_LAST- See Also:
-
MIN_ARRAYCOPY
protected static final int MIN_ARRAYCOPY- See Also:
-
ATTR_MIN_ARRAYCOPY
protected static final int ATTR_MIN_ARRAYCOPY- See Also:
-
DEFAULT_COPYBUFFER_LEN
protected static final int DEFAULT_COPYBUFFER_LEN- See Also:
-
_config
-
_copyBuffer
protected char[] _copyBufferIntermediate buffer, in which content (esp. Strings) can be copied to, before being output. -
_copyBufferLen
protected final int _copyBufferLen -
_xml11
protected boolean _xml11Indicates whether output is to be compliant; if false, is to be xml 1.0 compliant, if true, xml 1.1 compliant. -
_cfgNsAware
protected final boolean _cfgNsAware -
_locPastChars
protected int _locPastCharsNumber of characters output prior to currently buffered output -
_locRowNr
protected int _locRowNr -
_locRowStartOffset
protected int _locRowStartOffsetOffset of the first character on this line. May be negative, if the offset was in a buffer that has been flushed out. -
_checkContent
protected final boolean _checkContent -
_checkNames
protected final boolean _checkNames
-
-
Constructor Details
-
XmlWriter
-
-
Method Details
-
constructName
- Specified by:
constructName
in classWNameFactory
- Throws:
XMLStreamException
-
constructName
- Specified by:
constructName
in classWNameFactory
- Throws:
XMLStreamException
-
enableXml11
public void enableXml11() -
getOutputPtr
protected abstract int getOutputPtr() -
getHighestEncodable
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:
- Character code of the highest character that can be natively encoded.
-
close
Method called to flush the buffer(s), and close the output sink (stream or writer).- Throws:
IOException
-
_releaseBuffers
public void _releaseBuffers() -
_closeTarget
- Throws:
IOException
-
flush
- Throws:
IOException
-
writeCData
- Parameters:
data
- Contents of the CDATA section to write out- Returns:
- offset of the (first) illegal content segment ("]]>") in passed content, if not in repairing mode; or -1 if none
- Throws:
IOException
XMLStreamException
-
writeCData
public abstract int writeCData(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeCharacters
- Throws:
IOException
XMLStreamException
-
writeCharacters
public abstract void writeCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeSpace
- Throws:
IOException
XMLStreamException
-
writeSpace
public abstract void writeSpace(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - 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.- Throws:
IOException
XMLStreamException
-
writeDTD
Older "legacy" output method for outputting DOCTYPE declaration. Assumes that the passed-in String contains a complete DOCTYPE declaration properly quoted.- Throws:
IOException
XMLStreamException
-
writeDTD
public abstract void writeDTD(WName rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeEntityReference
- Throws:
IOException
XMLStreamException
-
writePI
- Throws:
IOException
XMLStreamException
-
writeRaw
public abstract void writeRaw(String str, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeRaw
public abstract void writeRaw(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeXmlDeclaration
public abstract void writeXmlDeclaration(String version, String enc, String standalone) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
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)
- Throws:
IOException
XMLStreamException
-
writeStartTagEnd
- Throws:
IOException
XMLStreamException
-
writeStartTagEmptyEnd
- Throws:
IOException
XMLStreamException
-
writeEndTag
- Throws:
IOException
XMLStreamException
-
writeAttribute
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)
- Throws:
IOException
XMLStreamException
-
writeAttribute
public abstract void writeAttribute(WName name, char[] value, int offset, int len) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeTypedValue
public abstract void writeTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
writeAttribute
public abstract void writeAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Throws:
IOException
XMLStreamException
-
getRow
public int getRow() -
getColumn
public int getColumn() -
getAbsOffset
public int getAbsOffset() -
guessEncodingBitSize
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. -
reportNwfName
This is the method called when an output method call violates name well-formedness checks and name validation is enabled.- Throws:
XMLStreamException
-
reportNwfName
- Throws:
XMLStreamException
-
reportNwfContent
- Throws:
XMLStreamException
-
reportNwfContent
- Throws:
XMLStreamException
-
reportFailedEscaping
- Throws:
XMLStreamException
-
reportInvalidEmptyName
- Throws:
XMLStreamException
-
reportInvalidChar
- Throws:
XMLStreamException
-
throwOutputError
- Throws:
XMLStreamException
-
throwOutputError
- Throws:
XMLStreamException
-