Package org.apache.axiom.om.ds

## Class AbstractOMDataSource

- java.lang.Object
- - org.apache.axiom.om.ds.AbstractOMDataSource

- All Implemented Interfaces:
    `OMDataSource`, `OMDataSourceExt`
  Direct Known Subclasses:
    `AbstractPullOMDataSource`, `AbstractPushOMDataSource`

      public abstract class AbstractOMDataSource
      extends Object
      implements OMDataSourceExt

  Base class for `OMDataSourceExt` implementations. This class should only be used by data sources that can equally well produce an `XMLStreamReader` and have a meaningful implementation of `OMDataSource.serialize(XMLStreamWriter)`. Most implementations should actually use `AbstractPullOMDataSource` or `AbstractPushOMDataSource`.

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `AbstractOMDataSource()` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Close the DataSource and free its resources.
    `OMDataSourceExt` | `copy()` | Create a copy of the data source.
    `Object` | `getObject()` | Get the object that backs this data source.
    `Object` | `getProperty​(String key)` | Get the value of a property stored on this instance.
    `byte[]` | `getXMLBytes​(String encoding)` | Returns a byte[] representing the xml data
    `InputStream` | `getXMLInputStream​(String encoding)` | Returns a InputStream representing the xml data
    `boolean` | `hasProperty​(String key)` | Check if a property with the given name is set on this instance.
    `void` | `serialize​(OutputStream out, OMOutputFormat format)` | Serializes element data directly to stream.
    `void` | `serialize​(Writer writer, OMOutputFormat format)` | Serializes element data directly to writer.
    `Object` | `setProperty​(String key, Object value)` | Set a property on this instance.

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

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

    - ### Methods inherited from interface org.apache.axiom.om.OMDataSource

      `getReader, serialize`

    - ### Methods inherited from interface org.apache.axiom.om.OMDataSourceExt

      `isDestructiveRead, isDestructiveWrite`

- - ### Constructor Detail

    - #### AbstractOMDataSource

          public AbstractOMDataSource()

  - ### Method Detail

    - #### getProperty

          public final Object getProperty​(String key)

      Description copied from interface: `OMDataSourceExt`
      Get the value of a property stored on this instance.
      Specified by:
        `getProperty` in interface `OMDataSourceExt`
      Parameters:
        `key` - the property name
      Returns:
        the property value or `null`

    - #### hasProperty

          public final boolean hasProperty​(String key)

      Description copied from interface: `OMDataSourceExt`
      Check if a property with the given name is set on this instance.
      Specified by:
        `hasProperty` in interface `OMDataSourceExt`
      Parameters:
        `key` - the property name
      Returns:
        `true` if the property is set

    - #### setProperty

          public final Object setProperty​(String key,
                                          Object value)

      Description copied from interface: `OMDataSourceExt`
      Set a property on this instance.
      Specified by:
        `setProperty` in interface `OMDataSourceExt`
      Parameters:
        `key` - the property name
        `value` - the property value
      Returns:
        the old property value or `null`

    - #### serialize

          public final void serialize​(OutputStream out,
                                      OMOutputFormat format)
                               throws XMLStreamException

      Description copied from interface: `OMDataSource`
      Serializes element data directly to stream.

      It is assumed that this method consumes the content (i.e. destroys the backing object) unless the data source also implements `OMDataSourceExt` and `OMDataSourceExt.isDestructiveWrite()` returns `false`.

      Specified by:
        `serialize` in interface `OMDataSource`
      Parameters:
        `out` - destination stream for element XML text
        `format` - Output format information. The implementation must use this information to choose the correct character set encoding when writing to the output stream. This parameter must not be null.
      Throws:
        `XMLStreamException`

    - #### serialize

          public final void serialize​(Writer writer,
                                      OMOutputFormat format)
                               throws XMLStreamException

      Description copied from interface: `OMDataSource`
      Serializes element data directly to writer.

      It is assumed that this method consumes the content (i.e. destroys the backing object) unless the data source also implements `OMDataSourceExt` and `OMDataSourceExt.isDestructiveWrite()` returns `false`.

      Specified by:
        `serialize` in interface `OMDataSource`
      Parameters:
        `writer` - destination writer for element XML text
        `format` - output format information (`null` if none; may be ignored if not supported by data binding even if supplied)
      Throws:
        `XMLStreamException`

    - #### getXMLBytes

          public final byte[] getXMLBytes​(String encoding)
                                   throws UnsupportedEncodingException

      Description copied from interface: `OMDataSourceExt`
      Returns a byte[] representing the xml data
      Specified by:
        `getXMLBytes` in interface `OMDataSourceExt`
      Parameters:
        `encoding` - String encoding of InputStream
      Returns:
        byte[]
      Throws:
        `UnsupportedEncodingException`
      See Also:
        `OMDataSourceExt.getXMLInputStream(String)`

    - #### getXMLInputStream

          public final InputStream getXMLInputStream​(String encoding)
                                              throws UnsupportedEncodingException

      Description copied from interface: `OMDataSourceExt`
      Returns a InputStream representing the xml data
      Specified by:
        `getXMLInputStream` in interface `OMDataSourceExt`
      Parameters:
        `encoding` - String encoding of InputStream
      Returns:
        InputStream
      Throws:
        `UnsupportedEncodingException`

    - #### getObject

          public Object getObject()

      Description copied from interface: `OMDataSourceExt`
      Get the object that backs this data source. Application code should in general not call this method directly, but use `OMSourcedElement.getObject(Class)` instead.

      Data sources that support non destructive read/write should return the object from which the XML is produced. Data sources with destructive read/write should return a non null value only if the backing object has not been consumed yet (even partially).

      Specified by:
        `getObject` in interface `OMDataSourceExt`
      Returns:
        the backing object, or `null` if the data source has no backing object or if the backing object can't be accessed in a safe way

    - #### close

          public void close()

      Description copied from interface: `OMDataSourceExt`
      Close the DataSource and free its resources.
      Specified by:
        `close` in interface `OMDataSourceExt`

    - #### copy

          public OMDataSourceExt copy()

      Description copied from interface: `OMDataSourceExt`
      Create a copy of the data source. This method is used by `OMInformationItem.clone(OMCloneOptions)` when the `OMCloneOptions.isCopyOMDataSources()` option is enabled. If the data source is immutable and stateless, then it may return a reference to itself instead of creating a new data source instance.
      Specified by:
        `copy` in interface `OMDataSourceExt`
      Returns:
        the copy of the data source, or `null` if the data source can't be copied (e.g. because it is destructive)