Class ParserInputStreamDataSource

java.lang.Object
org.apache.axiom.om.ds.OMDataSourceExtBase
org.apache.axiom.om.ds.ParserInputStreamDataSource
All Implemented Interfaces:
OMDataSource, OMDataSourceExt

public class ParserInputStreamDataSource extends OMDataSourceExtBase
A DataSource that is backed by an InputStream (read from a parser). The Data in this Data source owns the payload inputStream.
  • Constructor Details

    • ParserInputStreamDataSource

      public ParserInputStreamDataSource(InputStream payload, String encoding)
      This is the constructor that is normally called. Note that the ParserInputStreamDataSource takes ownership of the payload InputStream. It may copy, mark or reset the stream. Callers should not access the stream after this constructor is called
      Parameters:
      payload - InputStream
      encoding -
    • ParserInputStreamDataSource

      public ParserInputStreamDataSource(InputStream payload, String encoding, int behavior)
      This constructor is used to test the different Behavior settings. Note that the ParserInputStreamDataSource takes ownership of the payload InputStream. It may copy, mark or reset the stream. Callers should not access the stream after this constructor is called.
      Parameters:
      payload -
      encoding -
      behavior -
  • Method Details

    • serialize

      public void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException
      Description copied from interface: OMDataSourceExt
      Serializes element data directly to stream. Assumes that the backing object is destroyed during serialization if isDestructiveWrite
      Specified by:
      serialize in interface OMDataSource
      Specified by:
      serialize in interface OMDataSourceExt
      Overrides:
      serialize in class OMDataSourceExtBase
      Parameters:
      output - 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
      See Also:
    • serialize

      public void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException
      Description copied from interface: OMDataSourceExt
      Serializes element data directly to StAX writer. Assumes that the backing object is destroyed during serialization isDestructiveWrite
      Specified by:
      serialize in interface OMDataSource
      Specified by:
      serialize in interface OMDataSourceExt
      Overrides:
      serialize in class OMDataSourceExtBase
      Parameters:
      xmlWriter - destination writer
      Throws:
      XMLStreamException
      See Also:
    • getReader

      public XMLStreamReader getReader() throws XMLStreamException
      Description copied from interface: OMDataSourceExt
      Get parser for element data. In the general case this may require the data source to serialize data as XML text and then parse that text.
      Returns:
      element parser
      Throws:
      XMLStreamException
    • getXMLInputStream

      public InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException
      Description copied from interface: OMDataSourceExt
      Returns a InputStream representing the xml data
      Specified by:
      getXMLInputStream in interface OMDataSourceExt
      Overrides:
      getXMLInputStream in class OMDataSourceExtBase
      Parameters:
      encoding - String encoding of InputStream
      Returns:
      InputStream
      Throws:
      UnsupportedEncodingException
    • numReads

      public int numReads()
    • getObject

      public Object getObject()
      Description copied from interface: OMDataSourceExt
      Returns the backing Object.
      Returns:
      Object
    • isDestructiveRead

      public boolean isDestructiveRead()
      Description copied from interface: OMDataSourceExt
      Returns true if reading the backing object is destructive. An example of an object with a destructive read is an InputSteam. The owning OMSourcedElement uses this information to detemine if OM tree expansion is needed when reading the OMDataSourceExt.
      Returns:
      boolean
    • isDestructiveWrite

      public boolean isDestructiveWrite()
      Description copied from interface: OMDataSourceExt
      Returns true if writing the backing object is destructive. An example of an object with a destructive write is an InputStream. The owning OMSourcedElement uses this information to detemine if OM tree expansion is needed when writing the OMDataSourceExt.
      Returns:
      boolean
    • getXMLBytes

      public byte[] getXMLBytes(String encoding)
      Description copied from interface: OMDataSourceExt
      Returns a byte[] representing the xml data
      Parameters:
      encoding - String encoding of InputStream
      Returns:
      byte[]
      See Also:
    • close

      public void close()
      Description copied from interface: OMDataSourceExt
      Close the DataSource and free its resources.
    • copy

      public OMDataSourceExt copy()
      Return a InputStreamDataSource backed by a ByteArrayInputStream
      Returns:
      OMDataSourceExt