com.fasterxml.aalto.out

## Class XmlWriter

- java.lang.Object
- - com.fasterxml.aalto.out.WNameFactory
  - - com.fasterxml.aalto.out.XmlWriter

- Direct Known Subclasses:
    ByteXmlWriter, CharXmlWriter

      public abstract class XmlWriter
      extends WNameFactory

  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

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected WriterConfig` | `_config`
    `protected char[]` | `_copyBuffer` Intermediate buffer, in which content (esp.
    `protected boolean` | `_xml11` Indicates whether output is to be compliant; if false, is to be xml 1.0 compliant, if true, xml 1.1 compliant.
    `protected static int` | `ATTR_MIN_ARRAYCOPY`
    `protected static int` | `DEFAULT_COPYBUFFER_LEN`
    `protected boolean` | `mCfgNsAware`
    `protected boolean` | `mCheckContent`
    `protected boolean` | `mCheckNames`
    `protected static int` | `MIN_ARRAYCOPY`
    `protected int` | `mLocPastChars` Number of characters output prior to currently buffered output
    `protected int` | `mLocRowNr`
    `protected int` | `mLocRowStartOffset` Offset of the first character on this line.
    `protected static int` | `SURR1_FIRST`
    `protected static int` | `SURR1_LAST`
    `protected static int` | `SURR2_FIRST`
    `protected static int` | `SURR2_LAST`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `XmlWriter(WriterConfig cfg)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract void` | `_closeTarget(boolean doClose)`
    `void` | `_releaseBuffers()`
    `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` | `enableXml11()`
    `abstract void` | `flush()`
    `int` | `getAbsOffset()`
    `int` | `getColumn()`
    `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.
    `protected abstract int` | `getOutputPtr()`
    `int` | `getRow()`
    `static int` | `guessEncodingBitSize(WriterConfig cfg)` 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` | `reportInvalidEmptyName()`
    `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, org.codehaus.stax2.ri.typed.AsciiValueEncoder enc)`
    `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 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` | `writeDTD(String data)` Older "legacy" output method for outputting DOCTYPE declaration.
    `abstract void` | `writeDTD(WName rootName, String systemId, String publicId, String internalSubset)`
    `abstract void` | `writeEndTag(WName name)`
    `abstract void` | `writeEntityReference(WName name)`
    `abstract int` | `writePI(WName target, String data)`
    `abstract void` | `writeRaw(char[] cbuf, int offset, int len)`
    `abstract void` | `writeRaw(String str, int offset, int len)`
    `abstract void` | `writeSpace(char[] cbuf, int offset, int len)`
    `abstract void` | `writeSpace(String data)`
    `abstract void` | `writeStartTagEmptyEnd()`
    `abstract void` | `writeStartTagEnd()`
    `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)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### SURR1_FIRST

          protected static final int SURR1_FIRST

      See Also:
        Constant Field Values

    - #### SURR1_LAST

          protected static final int SURR1_LAST

      See Also:
        Constant Field Values

    - #### SURR2_FIRST

          protected static final int SURR2_FIRST

      See Also:
        Constant Field Values

    - #### SURR2_LAST

          protected static final int SURR2_LAST

      See Also:
        Constant Field Values

    - #### MIN_ARRAYCOPY

          protected static final int MIN_ARRAYCOPY

      See Also:
        Constant Field Values

    - #### ATTR_MIN_ARRAYCOPY

          protected static final int ATTR_MIN_ARRAYCOPY

      See Also:
        Constant Field Values

    - #### DEFAULT_COPYBUFFER_LEN

          protected static final int DEFAULT_COPYBUFFER_LEN

      See Also:
        Constant Field Values

    - #### _config

          protected final WriterConfig _config

    - #### _copyBuffer

          protected char[] _copyBuffer

      Intermediate buffer, in which content (esp. Strings) can be copied to, before being output.

    - #### _xml11

          protected boolean _xml11

      Indicates whether output is to be compliant; if false, is to be xml 1.0 compliant, if true, xml 1.1 compliant.

    - #### mCfgNsAware

          protected final boolean mCfgNsAware

    - #### mLocPastChars

          protected int mLocPastChars

      Number of characters output prior to currently buffered output

    - #### mLocRowNr

          protected int mLocRowNr

    - #### mLocRowStartOffset

          protected int mLocRowStartOffset

      Offset of the first character on this line. May be negative, if the offset was in a buffer that has been flushed out.

    - #### mCheckContent

          protected final boolean mCheckContent

    - #### mCheckNames

          protected final boolean mCheckNames

  - ### Constructor Detail

    - #### XmlWriter

          protected XmlWriter(WriterConfig cfg)

  - ### Method Detail

    - #### constructName

          public abstract WName constructName(String localName)
                                       throws XMLStreamException

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

    - #### constructName

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

      Specified by:
        `constructName` in class `WNameFactory`
      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

          public final void close(boolean forceTargetClose)
                           throws IOException

      Method called to flush the buffer(s), and close the output sink (stream or writer).
      Throws:
        `IOException`

    - #### _releaseBuffers

          public void _releaseBuffers()

    - #### _closeTarget

          public abstract void _closeTarget(boolean doClose)
                                     throws IOException

      Throws:
        `IOException`

    - #### flush

          public abstract void flush()
                              throws IOException

      Throws:
        `IOException`

    - #### writeCData

          public abstract int writeCData(String data)
                                  throws IOException,
                                         XMLStreamException

      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

          public abstract void writeCharacters(String data)
                                        throws IOException,
                                               XMLStreamException

      Throws:
        `IOException`
        `XMLStreamException`

    - #### writeCharacters

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

      Throws:
        `IOException`
        `XMLStreamException`

    - #### writeSpace

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

      Throws:
        `IOException`
        `XMLStreamException`

    - #### writeSpace

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

      Throws:
        `IOException`
        `XMLStreamException`

    - #### writeComment

          public abstract 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.
      Throws:
        `IOException`
        `XMLStreamException`

    - #### writeDTD

          public abstract void writeDTD(String data)
                                 throws IOException,
                                        XMLStreamException

      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

          public abstract void writeEntityReference(WName name)
                                             throws IOException,
                                                    XMLStreamException

      Throws:
        `IOException`
        `XMLStreamException`

    - #### writePI

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

      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

          public abstract void writeStartTagStart(WName name)
                                           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`

    - #### writeStartTagEnd

          public abstract void writeStartTagEnd()
                                         throws IOException,
                                                XMLStreamException

      Throws:
        `IOException`
        `XMLStreamException`

    - #### writeStartTagEmptyEnd

          public abstract void writeStartTagEmptyEnd()
                                              throws IOException,
                                                     XMLStreamException

      Throws:
        `IOException`
        `XMLStreamException`

    - #### writeEndTag

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

      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

          public static final int guessEncodingBitSize(WriterConfig cfg)

      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

          protected void reportNwfName(String msg)
                                throws XMLStreamException

      This is the method called when an output method call violates name well-formedness checks and name validation is enabled.
      Throws:
        `XMLStreamException`

    - #### reportNwfName

          protected void reportNwfName(String msg,
                           Object arg)
                                throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### reportNwfContent

          protected void reportNwfContent(String msg)
                                   throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### reportNwfContent

          protected void reportNwfContent(String format,
                              Object arg1,
                              Object arg2)
                                   throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### reportFailedEscaping

          protected void reportFailedEscaping(String type,
                                  int ch)
                                       throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### reportInvalidEmptyName

          protected void reportInvalidEmptyName()
                                         throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### reportInvalidChar

          protected void reportInvalidChar(int c)
                                    throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### throwOutputError

          protected void throwOutputError(String msg)
                                   throws XMLStreamException

      Throws:
        `XMLStreamException`

    - #### throwOutputError

          protected void throwOutputError(String format,
                              Object arg)
                                   throws XMLStreamException

      Throws:
        `XMLStreamException`

Copyright © 2012-2015 FasterXML. All Rights Reserved.