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.Fields inherited from class 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 intprotected 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) 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) 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 XmlWriter
close, enableXml11, getAbsOffset, getColumn, getHighestEncodable, getRow, guessEncodingBitSize, reportFailedEscaping, reportInvalidChar, reportInvalidEmptyName, reportNwfContent, reportNwfContent, reportNwfName, reportNwfName, throwOutputError, throwOutputError
-
Field Details
-
_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
-
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
-
writeCharacters
public final void writeCharacters(char[] cbuf, int offset, int len) throws IOException, XMLStreamException - Specified by:
writeCharactersin classXmlWriter- 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
-