org.apache.axiom.util.stax.xop

## Class XOPEncodingStreamWriter

- java.lang.Object
- - org.apache.axiom.util.stax.xop.XOPEncodingStreamWrapper
  - - org.apache.axiom.util.stax.xop.XOPEncodingStreamWriter

- All Implemented Interfaces:
    javax.xml.stream.XMLStreamWriter, DataHandlerWriter, MimePartProvider

      public class XOPEncodingStreamWriter
      extends XOPEncodingStreamWrapper
      implements javax.xml.stream.XMLStreamWriter, DataHandlerWriter

  `XMLStreamWriter` wrapper that encodes XOP. It implements the extension defined by `DataHandlerWriter`. The `DataHandler` objects for the parts referenced by `xop:Include` element information items produced by an instance of this class can be retrieved using the `XOPEncodingStreamWrapper.getDataHandler(String)` method.

- - ### Field Summary

    - ### Fields inherited from interface org.apache.axiom.ext.stax.datahandler.DataHandlerWriter

      `PROPERTY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `XOPEncodingStreamWriter(javax.xml.stream.XMLStreamWriter parent, ContentIDGenerator contentIDGenerator, OptimizationPolicy optimizationPolicy)` Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()`
    `void` | `flush()`
    `NamespaceContext` | `getNamespaceContext()`
    `String` | `getPrefix(String uri)`
    `Object` | `getProperty(String name)`
    `void` | `setDefaultNamespace(String uri)`
    `void` | `setNamespaceContext(NamespaceContext context)`
    `void` | `setPrefix(String prefix, String uri)`
    `void` | `writeAttribute(String localName, String value)`
    `void` | `writeAttribute(String namespaceURI, String localName, String value)`
    `void` | `writeAttribute(String prefix, String namespaceURI, String localName, String value)`
    `void` | `writeCData(String data)`
    `void` | `writeCharacters(char[] text, int start, int len)`
    `void` | `writeCharacters(String text)`
    `void` | `writeComment(String data)`
    `void` | `writeDataHandler(DataHandlerProvider dataHandlerProvider, String contentID, boolean optimize)` Write binary content to the stream.
    `void` | `writeDataHandler(javax.activation.DataHandler dataHandler, String contentID, boolean optimize)` Write binary content to the stream.
    `void` | `writeDefaultNamespace(String namespaceURI)`
    `void` | `writeDTD(String dtd)`
    `void` | `writeEmptyElement(String localName)`
    `void` | `writeEmptyElement(String namespaceURI, String localName)`
    `void` | `writeEmptyElement(String prefix, String localName, String namespaceURI)`
    `void` | `writeEndDocument()`
    `void` | `writeEndElement()`
    `void` | `writeEntityRef(String name)`
    `void` | `writeNamespace(String prefix, String namespaceURI)`
    `void` | `writeProcessingInstruction(String target)`
    `void` | `writeProcessingInstruction(String target, String data)`
    `void` | `writeStartDocument()`
    `void` | `writeStartDocument(String version)`
    `void` | `writeStartDocument(String encoding, String version)`
    `void` | `writeStartElement(String localName)`
    `void` | `writeStartElement(String namespaceURI, String localName)`
    `void` | `writeStartElement(String prefix, String localName, String namespaceURI)`

    - ### Methods inherited from class org.apache.axiom.util.stax.xop.XOPEncodingStreamWrapper

      `getContentIDs, getDataHandler, isLoaded, processDataHandler, processDataHandler`

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

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

- - ### Constructor Detail

    - #### XOPEncodingStreamWriter

          public XOPEncodingStreamWriter(javax.xml.stream.XMLStreamWriter parent,
                                         ContentIDGenerator contentIDGenerator,
                                         OptimizationPolicy optimizationPolicy)

      Constructor.
      Parameters:
        `parent` - the XML stream to write the encoded infoset to
        `contentIDGenerator` - used to generate content IDs for the binary content encoded as `xop:Include` element information items
        `optimizationPolicy` - the policy to apply to decide which binary content to optimize

  - ### Method Detail

    - #### getProperty

          public Object getProperty(String name)
                             throws IllegalArgumentException

      Specified by:
        `getProperty` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `IllegalArgumentException`

    - #### writeDataHandler

          public void writeDataHandler(javax.activation.DataHandler dataHandler,
                                       String contentID,
                                       boolean optimize)
                                throws IOException,
                                       javax.xml.stream.XMLStreamException

      Description copied from interface: `DataHandlerWriter`
      Write binary content to the stream. The implementation may choose to write the data as base64 encoded character data or using an optimization protocol such as XOP/MTOM.
      Specified by:
        `writeDataHandler` in interface `DataHandlerWriter`
      Parameters:
        `dataHandler` - the binary content to write
        `contentID` - an existing content ID for the binary data (see above)
        `optimize` - indicates whether the content is eligible for optimization (see above)
      Throws:
        `IOException` - if an error occurs while reading from the data handler
        `javax.xml.stream.XMLStreamException` - if an error occurs while writing to the underlying stream

    - #### writeDataHandler

          public void writeDataHandler(DataHandlerProvider dataHandlerProvider,
                                       String contentID,
                                       boolean optimize)
                                throws IOException,
                                       javax.xml.stream.XMLStreamException

      Description copied from interface: `DataHandlerWriter`
      Write binary content to the stream. This method allows the implementation to defer loading of the content. More precisely, if the implementation decides to use an optimization scheme such as XOP, then the content will not be written immediately to the underlying stream, but only after the XML infoset is complete. If the caller uses this method, the implementation can defer the actual loading of the binary content.
      Specified by:
        `writeDataHandler` in interface `DataHandlerWriter`
      Parameters:
        `dataHandlerProvider` - the binary content to write
        `contentID` - an existing content ID for the binary data (see above)
        `optimize` - indicates whether the content is eligible for optimization (see above)
      Throws:
        `IOException` - If an error occurs while reading from the data handler. Since the implementation is free to override the supplied `optimize` argument, it may attempt to load the binary data immediately. Because this operation may fail, the method must declare this exception.
        `javax.xml.stream.XMLStreamException` - if an error occurs while writing to the underlying stream

    - #### close

          public void close()
                     throws javax.xml.stream.XMLStreamException

      Specified by:
        `close` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### flush

          public void flush()
                     throws javax.xml.stream.XMLStreamException

      Specified by:
        `flush` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### getNamespaceContext

          public NamespaceContext getNamespaceContext()

      Specified by:
        `getNamespaceContext` in interface `javax.xml.stream.XMLStreamWriter`

    - #### getPrefix

          public String getPrefix(String uri)
                           throws javax.xml.stream.XMLStreamException

      Specified by:
        `getPrefix` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### setDefaultNamespace

          public void setDefaultNamespace(String uri)
                                   throws javax.xml.stream.XMLStreamException

      Specified by:
        `setDefaultNamespace` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### setNamespaceContext

          public void setNamespaceContext(NamespaceContext context)
                                   throws javax.xml.stream.XMLStreamException

      Specified by:
        `setNamespaceContext` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### setPrefix

          public void setPrefix(String prefix,
                                String uri)
                         throws javax.xml.stream.XMLStreamException

      Specified by:
        `setPrefix` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeAttribute

          public void writeAttribute(String prefix,
                                     String namespaceURI,
                                     String localName,
                                     String value)
                              throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeAttribute` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeAttribute

          public void writeAttribute(String namespaceURI,
                                     String localName,
                                     String value)
                              throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeAttribute` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeAttribute

          public void writeAttribute(String localName,
                                     String value)
                              throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeAttribute` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeCData

          public void writeCData(String data)
                          throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeCData` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeCharacters

          public void writeCharacters(char[] text,
                                      int start,
                                      int len)
                               throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeCharacters` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeCharacters

          public void writeCharacters(String text)
                               throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeCharacters` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeComment

          public void writeComment(String data)
                            throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeComment` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeDefaultNamespace

          public void writeDefaultNamespace(String namespaceURI)
                                     throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeDefaultNamespace` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeDTD

          public void writeDTD(String dtd)
                        throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeDTD` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeEmptyElement

          public void writeEmptyElement(String prefix,
                                        String localName,
                                        String namespaceURI)
                                 throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeEmptyElement` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeEmptyElement

          public void writeEmptyElement(String namespaceURI,
                                        String localName)
                                 throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeEmptyElement` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeEmptyElement

          public void writeEmptyElement(String localName)
                                 throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeEmptyElement` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeEndDocument

          public void writeEndDocument()
                                throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeEndDocument` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeEndElement

          public void writeEndElement()
                               throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeEndElement` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeEntityRef

          public void writeEntityRef(String name)
                              throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeEntityRef` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeNamespace

          public void writeNamespace(String prefix,
                                     String namespaceURI)
                              throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeNamespace` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeProcessingInstruction

          public void writeProcessingInstruction(String target,
                                                 String data)
                                          throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeProcessingInstruction` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeProcessingInstruction

          public void writeProcessingInstruction(String target)
                                          throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeProcessingInstruction` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeStartDocument

          public void writeStartDocument()
                                  throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeStartDocument` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeStartDocument

          public void writeStartDocument(String encoding,
                                         String version)
                                  throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeStartDocument` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeStartDocument

          public void writeStartDocument(String version)
                                  throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeStartDocument` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeStartElement

          public void writeStartElement(String prefix,
                                        String localName,
                                        String namespaceURI)
                                 throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeStartElement` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeStartElement

          public void writeStartElement(String namespaceURI,
                                        String localName)
                                 throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeStartElement` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

    - #### writeStartElement

          public void writeStartElement(String localName)
                                 throws javax.xml.stream.XMLStreamException

      Specified by:
        `writeStartElement` in interface `javax.xml.stream.XMLStreamWriter`
      Throws:
        `javax.xml.stream.XMLStreamException`

Copyright © The Apache Software Foundation. All Rights Reserved.