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 booleanprotected final booleanprotected final booleanprotected final WriterConfigprotected char[]Intermediate buffer, in which content (esp.protected final intprotected intNumber of characters output prior to currently buffered outputprotected intprotected intOffset of the first character on this line.protected booleanIndicates whether output is to be compliant; if false, is to be xml 1.0 compliant, if true, xml 1.1 compliant.protected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final intprotected static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract void_closeTarget(boolean doClose) voidfinal voidclose(boolean forceTargetClose) Method called to flush the buffer(s), and close the output sink (stream or writer).abstract WNameconstructName(String localName) abstract WNameconstructName(String prefix, String localName) voidabstract voidflush()intintabstract intMethod 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 intintgetRow()static final intMethod used to figure out which part of the Unicode char set the encoding can natively support.protected voidreportFailedEscaping(String type, int ch) protected voidreportInvalidChar(int c) protected voidprotected voidreportNwfContent(String msg) protected voidreportNwfContent(String format, Object arg1, Object arg2) protected voidreportNwfName(String msg) This is the method called when an output method call violates name well-formedness checks and name validation is enabled.protected voidreportNwfName(String msg, Object arg) protected voidthrowOutputError(String msg) protected voidthrowOutputError(String format, Object arg) abstract voidwriteAttribute(WName name, char[] value, int offset, int len) abstract 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)abstract voidwriteAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) abstract intwriteCData(char[] cbuf, int offset, int len) abstract intwriteCData(String data) abstract voidwriteCharacters(char[] cbuf, int offset, int len) abstract voidwriteCharacters(String data) abstract intwriteComment(String data) Method that will try to output the content as specified.abstract voidabstract voidOlder "legacy" output method for outputting DOCTYPE declaration.abstract voidwriteEndTag(WName name) abstract voidwriteEntityReference(WName name) abstract intabstract voidwriteRaw(char[] cbuf, int offset, int len) abstract voidabstract voidwriteSpace(char[] cbuf, int offset, int len) abstract voidwriteSpace(String data) abstract voidabstract voidabstract 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)abstract voidwriteTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) abstract voidwriteXmlDeclaration(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:
constructNamein classWNameFactory- Throws:
XMLStreamException
-
constructName
- Specified by:
constructNamein 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:
IOExceptionXMLStreamException
-
writeCData
public abstract int writeCData(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeCharacters
- Throws:
IOExceptionXMLStreamException
-
writeCharacters
public abstract void writeCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeSpace
- Throws:
IOExceptionXMLStreamException
-
writeSpace
public abstract void writeSpace(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - 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.- Throws:
IOExceptionXMLStreamException
-
writeDTD
Older "legacy" output method for outputting DOCTYPE declaration. Assumes that the passed-in String contains a complete DOCTYPE declaration properly quoted.- Throws:
IOExceptionXMLStreamException
-
writeDTD
public abstract void writeDTD(WName rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeEntityReference
- Throws:
IOExceptionXMLStreamException
-
writePI
- Throws:
IOExceptionXMLStreamException
-
writeRaw
public abstract void writeRaw(String str, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeRaw
public abstract void writeRaw(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeXmlDeclaration
public abstract void writeXmlDeclaration(String version, String enc, String standalone) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
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:
IOExceptionXMLStreamException
-
writeStartTagEnd
- Throws:
IOExceptionXMLStreamException
-
writeStartTagEmptyEnd
- Throws:
IOExceptionXMLStreamException
-
writeEndTag
- Throws:
IOExceptionXMLStreamException
-
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:
IOExceptionXMLStreamException
-
writeAttribute
public abstract void writeAttribute(WName name, char[] value, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeTypedValue
public abstract void writeTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeAttribute
public abstract void writeAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
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
-