Package com.fasterxml.aalto.out
Class ByteXmlWriter
java.lang.Object
com.fasterxml.aalto.out.WNameFactory
com.fasterxml.aalto.out.XmlWriter
com.fasterxml.aalto.out.ByteXmlWriter
- Direct Known Subclasses:
SingleByteXmlWriter,Utf8XmlWriter
This abstract base class (partial implementation of
XmlWriter)
is used if the destination is byte-based OutputStream.
Further, all existing implementations are for encodings that are 7-bit ascii compatible. This is important since this means that marker and separator characters are identical independent of actual encoding. This would not hold if support for encodings like EBCDIC were supported using this class.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final XmlCharTypesValidation tables used for verifying validity (and need for quoting)protected OutputStreamActual Writer to use for outputting buffered data as appropriate.protected byte[]protected final intprotected intprotected intIn case a split surrogate pair is output (which can occur for only some of the methods, possibly depending on encoding), the first part is temporarily stored within this member variable.(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte(package private) static final byte[](package private) static final byte[](package private) static final byte[](package private) static final byte[](package private) static final byte[](package private) static final byte[](package private) static final byte[](package private) static final intDefault intermediate copy buffer size, to be used for efficient access to String content.(package private) static final intAnd this value determines size of the intermediate copy buffer to use.(package private) static final intLet's try avoid short writes, since some output streams have high per-call penalty (like network streams).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
ConstructorsModifierConstructorDescriptionprotectedByteXmlWriter(WriterConfig cfg, OutputStream out, XmlCharTypes charTypes) -
Method Summary
Modifier and TypeMethodDescriptionvoid_closeTarget(boolean doClose) voidprotected final intcalcSurrogate(int surr1, int surr2, String context) final WNameconstructName(String localName) constructName(String prefix, String localName) protected abstract WNamedoConstructName(String localName) protected abstract WNamedoConstructName(String prefix, String localName) protected final intfastWriteAttrValue(char[] vbuf, int offset, int len, byte[] bbuf, int ptr) Method called to copy given attribute value, when it's known that it will completely fit in the output buffer without further checksfinal voidflush()protected final voidprotected static final byte[]protected static final voidprotected static final voidprotected final intprivate final voidlongWriteCharacters(String text) protected abstract voidoutput2ByteChar(int ch) protected abstract intoutputMultiByteChar(int ch, char[] cbuf, int inputOffset, int inputLen) Method called to output a character beyond basic 1- or 2-byte encoding (code 0x0800 and above); possibly using character entities, if necessaryprotected abstract intoutputStrictMultiByteChar(int ch, char[] cbuf, int inputOffset, int inputLen) Method called to output a character beyond basic 1- or 2-byte encoding (code 0x0800 and above), without being able to use character entitiesprotected abstract voidoutputSurrogates(int surr1, int surr2) Method called to output a composite character, result of combining 2 surrogate characters.protected final voidprotected final voidthrowUnpairedSurrogate(int code) protected voidverifyNameComponent(String part) Method used to verify that a name component (prefix, local name) is a legal as per xml 1.0 specification.protected final voidwriteAsEntity(int c) final voidwriteAttribute(WName name, char[] vbuf, int offset, int vlen) final 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)final voidwriteAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) private final voidwriteAttrNameEqQ(WName name) protected final voidwriteAttrValue(char[] vbuf, int offset, int len) intwriteCData(char[] cbuf, int offset, int len) intwriteCData(String data) protected intwriteCDataContents(char[] cbuf, int offset, int len) protected final voidprotected final voidfinal voidwriteCharacters(char[] cbuf, int offset, int len) final voidwriteCharacters(String text) intwriteComment(String data) Method that will try to output the content as specified.protected intwriteCommentContents(char[] cbuf, int offset, int len) Note: the only way to fix comment contents is to inject a space to split up consecutive '--' (or '-' that ends a comment).protected final voidprotected final voidvoidvoidOlder "legacy" output method for outputting DOCTYPE declaration.final voidwriteEndTag(WName name) voidwriteEntityReference(WName name) protected final voidwriteLongAttribute(WName name, String value, int vlen) protected final voidprotected final voidprotected final voidintprotected intwritePIData(char[] cbuf, int offset, int len) protected final voidwriteRaw(byte b) protected final voidwriteRaw(byte[] buf) protected final voidwriteRaw(byte[] buf, int offset, int len) protected final voidwriteRaw(byte b1, byte b2) abstract voidwriteRaw(char[] cbuf, int offset, int len) This method is heavily encoding-dependant, so it needs to be deferred to sub-classesfinal voidvoidwriteSpace(char[] cbuf, int offset, int len) final voidwriteSpace(String data) private final voidwriteSplitCharacters(char[] cbuf, int offset, int len) This method is called when it is possible that the output may cross the output buffer boundary.voidfinal voidfinal 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(String version, String encoding, String standalone) Methods inherited from class com.fasterxml.aalto.out.XmlWriter
close, enableXml11, getAbsOffset, getColumn, getHighestEncodable, getRow, guessEncodingBitSize, reportFailedEscaping, reportInvalidChar, reportInvalidEmptyName, reportNwfContent, reportNwfContent, reportNwfName, reportNwfName, throwOutputError, throwOutputError
-
Field Details
-
DEFAULT_FULL_BUFFER_SIZE
static final int DEFAULT_FULL_BUFFER_SIZEAnd this value determines size of the intermediate copy buffer to use.- See Also:
-
DEFAULT_COPY_BUFFER_SIZE
static final int DEFAULT_COPY_BUFFER_SIZEDefault intermediate copy buffer size, to be used for efficient access to String content. Smaller, since it's in characters, plus will not be used for actual write operations- See Also:
-
SMALL_WRITE
static final int SMALL_WRITELet's try avoid short writes, since some output streams have high per-call penalty (like network streams).- See Also:
-
BYTE_SPACE
static final byte BYTE_SPACE- See Also:
-
BYTE_COLON
static final byte BYTE_COLON- See Also:
-
BYTE_SEMICOLON
static final byte BYTE_SEMICOLON- See Also:
-
BYTE_LBRACKET
static final byte BYTE_LBRACKET- See Also:
-
BYTE_RBRACKET
static final byte BYTE_RBRACKET- See Also:
-
BYTE_QMARK
static final byte BYTE_QMARK- See Also:
-
BYTE_EQ
static final byte BYTE_EQ- See Also:
-
BYTE_SLASH
static final byte BYTE_SLASH- See Also:
-
BYTE_HASH
static final byte BYTE_HASH- See Also:
-
BYTE_HYPHEN
static final byte BYTE_HYPHEN- See Also:
-
BYTE_LT
static final byte BYTE_LT- See Also:
-
BYTE_GT
static final byte BYTE_GT- See Also:
-
BYTE_AMP
static final byte BYTE_AMP- See Also:
-
BYTE_QUOT
static final byte BYTE_QUOT- See Also:
-
BYTE_APOS
static final byte BYTE_APOS- See Also:
-
BYTE_A
static final byte BYTE_A- See Also:
-
BYTE_G
static final byte BYTE_G- See Also:
-
BYTE_L
static final byte BYTE_L- See Also:
-
BYTE_M
static final byte BYTE_M- See Also:
-
BYTE_O
static final byte BYTE_O- See Also:
-
BYTE_P
static final byte BYTE_P- See Also:
-
BYTE_Q
static final byte BYTE_Q- See Also:
-
BYTE_S
static final byte BYTE_S- See Also:
-
BYTE_T
static final byte BYTE_T- See Also:
-
BYTE_U
static final byte BYTE_U- See Also:
-
BYTE_X
static final byte BYTE_X- See Also:
-
BYTES_CDATA_START
static final byte[] BYTES_CDATA_START -
BYTES_CDATA_END
static final byte[] BYTES_CDATA_END -
BYTES_COMMENT_START
static final byte[] BYTES_COMMENT_START -
BYTES_COMMENT_END
static final byte[] BYTES_COMMENT_END -
BYTES_XMLDECL_START
static final byte[] BYTES_XMLDECL_START -
BYTES_XMLDECL_ENCODING
static final byte[] BYTES_XMLDECL_ENCODING -
BYTES_XMLDECL_STANDALONE
static final byte[] BYTES_XMLDECL_STANDALONE -
_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 byte[] _outputBuffer -
_outputPtr
protected int _outputPtr -
_outputBufferLen
protected final int _outputBufferLen -
_surrogate
protected int _surrogateIn case a split surrogate pair is output (which can occur for only some of the methods, possibly depending on encoding), the first part is temporarily stored within this member variable. -
_charTypes
Validation tables used for verifying validity (and need for quoting)
-
-
Constructor Details
-
ByteXmlWriter
-
-
Method Details
-
getOutputPtr
protected final int getOutputPtr()- Specified by:
getOutputPtrin classXmlWriter
-
constructName
- Specified by:
constructNamein classXmlWriter- Throws:
XMLStreamException
-
constructName
- Specified by:
constructNamein classXmlWriter- Throws:
XMLStreamException
-
doConstructName
- Throws:
XMLStreamException
-
doConstructName
- Throws:
XMLStreamException
-
verifyNameComponent
Method used to verify that a name component (prefix, local name) is a legal as per xml 1.0 specification.- Throws:
IllegalArgumentException- If name component contains an invalid (non-name; or for the initial characters, non-name-first) character.XMLStreamException
-
outputSurrogates
protected abstract void outputSurrogates(int surr1, int surr2) throws IOException, XMLStreamException Method called to output a composite character, result of combining 2 surrogate characters.- Throws:
IOExceptionXMLStreamException
-
output2ByteChar
- Throws:
IOExceptionXMLStreamException
-
outputStrictMultiByteChar
protected abstract int outputStrictMultiByteChar(int ch, char[] cbuf, int inputOffset, int inputLen) throws IOException, XMLStreamException Method called to output a character beyond basic 1- or 2-byte encoding (code 0x0800 and above), without being able to use character entities- Throws:
IOExceptionXMLStreamException
-
outputMultiByteChar
protected abstract int outputMultiByteChar(int ch, char[] cbuf, int inputOffset, int inputLen) throws IOException, XMLStreamException Method called to output a character beyond basic 1- or 2-byte encoding (code 0x0800 and above); possibly using character entities, if necessary- Throws:
IOExceptionXMLStreamException
-
_releaseBuffers
public void _releaseBuffers()- Overrides:
_releaseBuffersin classXmlWriter
-
_closeTarget
- Specified by:
_closeTargetin classXmlWriter- Throws:
IOException
-
flush
- Specified by:
flushin classXmlWriter- Throws:
IOException
-
writeRaw
- Specified by:
writeRawin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeRaw
public abstract void writeRaw(char[] cbuf, int offset, int len) throws IOException, XMLStreamException This method is heavily encoding-dependant, so it needs to be deferred to sub-classes- Specified by:
writeRawin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeStartTagStart
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:
IOExceptionXMLStreamException
-
writeStartTagEnd
- Specified by:
writeStartTagEndin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeStartTagEmptyEnd
- Specified by:
writeStartTagEmptyEndin classXmlWriter- Throws:
IOException
-
writeEndTag
- Specified by:
writeEndTagin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeAttribute
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:
IOExceptionXMLStreamException
-
writeAttribute
public final void writeAttribute(WName name, char[] vbuf, int offset, int vlen) throws IOException, XMLStreamException - Specified by:
writeAttributein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
fastWriteAttrValue
protected final int fastWriteAttrValue(char[] vbuf, int offset, int len, byte[] bbuf, int ptr) throws IOException, XMLStreamException Method called to copy given attribute value, when it's known that it will completely fit in the output buffer without further checks- Throws:
IOExceptionXMLStreamException
-
writeAttrValue
protected final void writeAttrValue(char[] vbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeLongAttribute
protected final void writeLongAttribute(WName name, String value, int vlen) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeName
- Throws:
IOException
-
writeName
- Throws:
IOException
-
writeName
- Throws:
IOException
-
writeAttrNameEqQ
- Throws:
IOExceptionXMLStreamException
-
writeCData
- 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:
IOExceptionXMLStreamException
-
writeCData
- Specified by:
writeCDatain classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeCDataContents
protected int writeCDataContents(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Throws:
IOExceptionXMLStreamException
-
writeCharacters
- Specified by:
writeCharactersin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
longWriteCharacters
- Throws:
IOExceptionXMLStreamException
-
writeCharacters
public final void writeCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Specified by:
writeCharactersin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeSplitCharacters
private final void writeSplitCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException This method is called when it is possible that the output may cross the output buffer boundary. Because of this, code has to add more boundary checks.- Throws:
IOExceptionXMLStreamException
-
writeTypedValue
public void writeTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Specified by:
writeTypedValuein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeAttribute
public final void writeAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc) throws IOException, XMLStreamException - Specified by:
writeAttributein classXmlWriter- 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.- Specified by:
writeCommentin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeCommentContents
protected int writeCommentContents(char[] cbuf, int offset, int len) throws IOException, XMLStreamException Note: the only way to fix comment contents is to inject a space to split up consecutive '--' (or '-' that ends a comment).- Throws:
IOExceptionXMLStreamException
-
writeDTD
Description copied from class:XmlWriterOlder "legacy" output method for outputting DOCTYPE declaration. Assumes that the passed-in String contains a complete DOCTYPE declaration properly quoted.- Specified by:
writeDTDin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeDTD
public void writeDTD(WName rootName, String systemId, String publicId, String internalSubset) throws IOException, XMLStreamException - Specified by:
writeDTDin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writePIData
- Throws:
IOExceptionXMLStreamException
-
writeEntityReference
- Specified by:
writeEntityReferencein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writePI
- Specified by:
writePIin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeSpace
- Specified by:
writeSpacein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeSpace
- Specified by:
writeSpacein classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeXmlDeclaration
public void writeXmlDeclaration(String version, String encoding, String standalone) throws IOException, XMLStreamException - Specified by:
writeXmlDeclarationin classXmlWriter- Throws:
IOExceptionXMLStreamException
-
writeCDataStart
- Throws:
IOException
-
writeCDataEnd
- Throws:
IOException
-
writeCommentStart
- Throws:
IOException
-
writeCommentEnd
- Throws:
IOException
-
writeRaw
- Throws:
IOException
-
writeRaw
- Throws:
IOException
-
writeRaw
- Throws:
IOException
-
writeRaw
- Throws:
IOException
-
throwUnpairedSurrogate
- Throws:
IOException
-
throwUnpairedSurrogate
- Throws:
IOException
-
flushBuffer
- Throws:
IOException
-
writeAsEntity
- Throws:
IOException
-
calcSurrogate
- Throws:
XMLStreamException
-
getAscii
-
getAscii
-
getAscii
-