Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## 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

    public abstract class ByteXmlWriter

extends XmlWriter

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
`protected OutputStream` | `_out` Actual Writer to use for outputting buffered data as appropriate.
`protected byte[]` | `_outputBuffer`
`protected int` | `_outputBufferLen`
`protected int` | `_outputPtr`
`protected XmlCharTypes` | `mCharTypes` Validation tables used for verifying validity (and need for quoting)
`protected char[]` | `mCopyBuffer` Temporary copy buffer, in which character content from Strings can be copied to first (since `String.getChars(char[], int)` can be drastically faster than `String.charAt(int)`!), to be converted
`protected int` | `mCopyBufferLen`
`protected int` | `mSurrogate` In 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 com.fasterxml.aalto.out.XmlWriter
`ATTR_MIN_ARRAYCOPY, DEFAULT_COPYBUFFER_LEN, mCfgNsAware, mCheckContent, mCheckNames, MIN_ARRAYCOPY, mLocPastChars, mLocRowNr, mLocRowStartOffset, mXml11, SURR1_FIRST, SURR1_LAST, SURR2_FIRST, SURR2_LAST`

Constructor Summary
`protected` | `ByteXmlWriter(WriterConfig cfg, OutputStream out, XmlCharTypes charTypes)`

Method Summary
`void` | `_closeTarget(boolean doClose)`
`void` | `_releaseBuffers()`
`protected int` | `calcSurrogate(int surr1, int surr2, String context)`
`WName` | `constructName(String localName)`
`WName` | `constructName(String prefix, String localName)`
`protected abstract WName` | `doConstructName(String localName)`
`protected abstract WName` | `doConstructName(String prefix, String localName)`
`protected int` | `fastWriteAttrValue(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 checks
`void` | `flush()`
`protected void` | `flushBuffer()`
`protected static byte[]` | `getAscii(String str)`
`protected static void` | `getAscii(String str, byte[] result)`
`protected static void` | `getAscii(String str, byte[] result, int offset)`
`protected int` | `getOutputPtr()`
`protected abstract void` | `output2ByteChar(int ch)`
`protected abstract int` | `outputMultiByteChar(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 necessary
`protected abstract int` | `outputStrictMultiByteChar(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 entities
`protected abstract void` | `outputSurrogates(int surr1, int surr2)` Method called to output a composite character, result of combining 2 surrogate characters.
`protected void` | `throwUnpairedSurrogate()`
`protected void` | `throwUnpairedSurrogate(int code)`
`protected void` | `verifyNameComponent(String part)` Method used to verify that a name component (prefix, local name) is a legal as per xml 1.0 specification.
`protected void` | `writeAsEntity(int c)`
`void` | `writeAttribute(WName name, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)`
`void` | `writeAttribute(WName name, char[] vbuf, int offset, int vlen)`
`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)
`protected void` | `writeAttrValue(char[] vbuf, int offset, int len)`
`int` | `writeCData(char[] cbuf, int offset, int len)`
`int` | `writeCData(String data)`
`protected int` | `writeCDataContents(char[] cbuf, int offset, int len)`
`protected void` | `writeCDataEnd()`
`protected void` | `writeCDataStart()`
`void` | `writeCharacters(char[] cbuf, int offset, int len)`
`void` | `writeCharacters(String text)`
`int` | `writeComment(String data)` Method that will try to output the content as specified.
`protected int` | `writeCommentContents(char[] cbuf, int offset, int len)` Note: the only way to fix comment contents is to inject a space to split up consequtive '--' (or '-' that ends a comment).
`protected void` | `writeCommentEnd()`
`protected void` | `writeCommentStart()`
`void` | `writeDTD(String data)` Older "legacy" output method for outputting DOCTYPE declaration.
`void` | `writeDTD(WName rootName, String systemId, String publicId, String internalSubset)`
`void` | `writeEndTag(WName name)`
`void` | `writeEntityReference(WName name)`
`protected void` | `writeLongAttribute(WName name, String value, int vlen)`
`protected void` | `writeName(byte preChar, WName name)`
`protected void` | `writeName(WName name)`
`protected void` | `writeName(WName name, byte postChar)`
`int` | `writePI(WName target, String data)`
`protected int` | `writePIData(char[] cbuf, int offset, int len)`
`protected void` | `writeRaw(byte b)`
`protected void` | `writeRaw(byte[] buf)`
`protected void` | `writeRaw(byte[] buf, int offset, int len)`
`protected void` | `writeRaw(byte b1, byte b2)`
`abstract void` | `writeRaw(char[] cbuf, int offset, int len)` This method is heavily encoding-dependant, so it needs to be deferred to sub-classes
`void` | `writeRaw(String text, int offset, int len)`
`void` | `writeSpace(char[] cbuf, int offset, int len)`
`void` | `writeSpace(String data)`
`void` | `writeStartTagEmptyEnd()`
`void` | `writeStartTagEnd()`
`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)
`void` | `writeTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)`
`void` | `writeXmlDeclaration(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`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _out

    protected OutputStream _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

### mSurrogate

    protected int mSurrogate

  In 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.

### mCopyBuffer

    protected char[] mCopyBuffer

  Temporary copy buffer, in which character content from Strings can be copied to first (since `String.getChars(char[], int)` can be drastically faster than `String.charAt(int)`!), to be converted

### mCopyBufferLen

    protected final int mCopyBufferLen

### mCharTypes

    protected final XmlCharTypes mCharTypes

  Validation tables used for verifying validity (and need for quoting)

Constructor Detail

### ByteXmlWriter

    protected ByteXmlWriter(WriterConfig cfg,
                            OutputStream out,
                            XmlCharTypes charTypes)

Method Detail

### getOutputPtr

    protected final int getOutputPtr()

  Specified by:
    `getOutputPtr` in class `XmlWriter`

### constructName

    public final WName constructName(String localName)
                              throws XMLStreamException

  Specified by:
    `constructName` in class `XmlWriter`
  Throws:
    `XMLStreamException`

### constructName

    public WName constructName(String prefix,
                               String localName)
                        throws XMLStreamException

  Specified by:
    `constructName` in class `XmlWriter`
  Throws:
    `XMLStreamException`

### doConstructName

    protected abstract WName doConstructName(String localName)
                                      throws XMLStreamException

  Throws:
    `XMLStreamException`

### doConstructName

    protected abstract WName doConstructName(String prefix,
                                             String localName)
                                      throws XMLStreamException

  Throws:
    `XMLStreamException`

### verifyNameComponent

    protected void verifyNameComponent(String part)
                                throws XMLStreamException

  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:
    `IOException`
    `XMLStreamException`

### output2ByteChar

    protected abstract void output2ByteChar(int ch)
                                     throws IOException,
                                            XMLStreamException

  Throws:
    `IOException`
    `XMLStreamException`

### 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:
    `IOException`
    `XMLStreamException`

### 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:
    `IOException`
    `XMLStreamException`

### _releaseBuffers

    public void _releaseBuffers()

  Overrides:
    `_releaseBuffers` in class `XmlWriter`

### _closeTarget

    public void _closeTarget(boolean doClose)
                      throws IOException

  Specified by:
    `_closeTarget` in class `XmlWriter`
  Throws:
    `IOException`

### flush

    public final void flush()
                     throws IOException

  Specified by:
    `flush` in class `XmlWriter`
  Throws:
    `IOException`

### writeRaw

    public final void writeRaw(String text,
                               int offset,
                               int len)
                        throws IOException,
                               XMLStreamException

  Specified by:
    `writeRaw` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### 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:
    `writeRaw` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeStartTagStart

    public final void writeStartTagStart(WName name)
                                  throws IOException,
                                         XMLStreamException

  Description copied from class: `XmlWriter`

  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)

  Specified by:
    `writeStartTagStart` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeStartTagEnd

    public final void writeStartTagEnd()
                                throws IOException,
                                       XMLStreamException

  Specified by:
    `writeStartTagEnd` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeStartTagEmptyEnd

    public void writeStartTagEmptyEnd()
                               throws IOException

  Specified by:
    `writeStartTagEmptyEnd` in class `XmlWriter`
  Throws:
    `IOException`

### writeEndTag

    public final void writeEndTag(WName name)
                           throws IOException,
                                  XMLStreamException

  Specified by:
    `writeEndTag` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeAttribute

    public final void writeAttribute(WName name,
                                     String value)
                              throws IOException,
                                     XMLStreamException

  Description copied from class: `XmlWriter`

  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)

  Specified by:
    `writeAttribute` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeAttribute

    public final void writeAttribute(WName name,
                                     char[] vbuf,
                                     int offset,
                                     int vlen)
                              throws IOException,
                                     XMLStreamException

  Specified by:
    `writeAttribute` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### 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:
    `IOException`
    `XMLStreamException`

### writeAttrValue

    protected final void writeAttrValue(char[] vbuf,
                                        int offset,
                                        int len)
                                 throws IOException,
                                        XMLStreamException

  Throws:
    `IOException`
    `XMLStreamException`

### writeLongAttribute

    protected final void writeLongAttribute(WName name,
                                            String value,
                                            int vlen)
                                     throws IOException,
                                            XMLStreamException

  Throws:
    `IOException`
    `XMLStreamException`

### writeName

    protected final void writeName(WName name)
                            throws IOException

  Throws:
    `IOException`

### writeName

    protected final void writeName(byte preChar,
                                   WName name)
                            throws IOException

  Throws:
    `IOException`

### writeName

    protected final void writeName(WName name,
                                   byte postChar)
                            throws IOException

  Throws:
    `IOException`

### writeCData

    public int writeCData(String data)
                   throws IOException,
                          XMLStreamException

  Specified by:
    `writeCData` in class `XmlWriter`
  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:
    `IOException`
    `XMLStreamException`

### writeCData

    public int writeCData(char[] cbuf,
                          int offset,
                          int len)
                   throws IOException,
                          XMLStreamException

  Specified by:
    `writeCData` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeCDataContents

    protected int writeCDataContents(char[] cbuf,
                                     int offset,
                                     int len)
                              throws IOException,
                                     XMLStreamException

  Throws:
    `IOException`
    `XMLStreamException`

### writeCharacters

    public final void writeCharacters(String text)
                               throws IOException,
                                      XMLStreamException

  Specified by:
    `writeCharacters` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeCharacters

    public final void writeCharacters(char[] cbuf,
                                      int offset,
                                      int len)
                               throws IOException,
                                      XMLStreamException

  Specified by:
    `writeCharacters` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeTypedValue

    public void writeTypedValue(org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)
                         throws IOException,
                                XMLStreamException

  Specified by:
    `writeTypedValue` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeAttribute

    public final void writeAttribute(WName name,
                                     org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)
                              throws IOException,
                                     XMLStreamException

  Specified by:
    `writeAttribute` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeComment

    public 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.

  Specified by:
    `writeComment` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### 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 consequtive '--' (or '-' that ends a comment).

  Throws:
    `IOException`
    `XMLStreamException`

### writeDTD

    public void writeDTD(String data)
                  throws IOException,
                         XMLStreamException

  Description copied from class: `XmlWriter`
  Older "legacy" output method for outputting DOCTYPE declaration. Assumes that the passed-in String contains a complete DOCTYPE declaration properly quoted.

  Specified by:
    `writeDTD` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeDTD

    public void writeDTD(WName rootName,
                         String systemId,
                         String publicId,
                         String internalSubset)
                  throws IOException,
                         XMLStreamException

  Specified by:
    `writeDTD` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writePIData

    protected int writePIData(char[] cbuf,
                              int offset,
                              int len)
                       throws IOException,
                              XMLStreamException

  Throws:
    `IOException`
    `XMLStreamException`

### writeEntityReference

    public void writeEntityReference(WName name)
                              throws IOException,
                                     XMLStreamException

  Specified by:
    `writeEntityReference` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writePI

    public int writePI(WName target,
                       String data)
                throws IOException,
                       XMLStreamException

  Specified by:
    `writePI` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeSpace

    public final void writeSpace(String data)
                          throws IOException,
                                 XMLStreamException

  Specified by:
    `writeSpace` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeSpace

    public void writeSpace(char[] cbuf,
                           int offset,
                           int len)
                    throws IOException,
                           XMLStreamException

  Specified by:
    `writeSpace` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeXmlDeclaration

    public void writeXmlDeclaration(String version,
                                    String encoding,
                                    String standalone)
                             throws IOException,
                                    XMLStreamException

  Specified by:
    `writeXmlDeclaration` in class `XmlWriter`
  Throws:
    `IOException`
    `XMLStreamException`

### writeCDataStart

    protected final void writeCDataStart()
                                  throws IOException

  Throws:
    `IOException`

### writeCDataEnd

    protected final void writeCDataEnd()
                                throws IOException

  Throws:
    `IOException`

### writeCommentStart

    protected final void writeCommentStart()
                                    throws IOException

  Throws:
    `IOException`

### writeCommentEnd

    protected final void writeCommentEnd()
                                  throws IOException

  Throws:
    `IOException`

### writeRaw

    protected final void writeRaw(byte b)
                           throws IOException

  Throws:
    `IOException`

### writeRaw

    protected final void writeRaw(byte b1,
                                  byte b2)
                           throws IOException

  Throws:
    `IOException`

### writeRaw

    protected final void writeRaw(byte[] buf)
                           throws IOException

  Throws:
    `IOException`

### writeRaw

    protected final void writeRaw(byte[] buf,
                                  int offset,
                                  int len)
                           throws IOException

  Throws:
    `IOException`

### throwUnpairedSurrogate

    protected final void throwUnpairedSurrogate()
                                         throws IOException

  Throws:
    `IOException`

### throwUnpairedSurrogate

    protected final void throwUnpairedSurrogate(int code)
                                         throws IOException

  Throws:
    `IOException`

### flushBuffer

    protected final void flushBuffer()
                              throws IOException

  Throws:
    `IOException`

### writeAsEntity

    protected final void writeAsEntity(int c)
                                throws IOException

  Throws:
    `IOException`

### calcSurrogate

    protected final int calcSurrogate(int surr1,
                                      int surr2,
                                      String context)
                               throws XMLStreamException

  Throws:
    `XMLStreamException`

### getAscii

    protected static final byte[] getAscii(String str)

### getAscii

    protected static final void getAscii(String str,
                                         byte[] result)

### getAscii

    protected static final void getAscii(String str,
                                         byte[] result,
                                         int offset)

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2012 Fasterxml.com. All Rights Reserved.