org.apache.axiom.om
Interface OMDataSourceExt

All Superinterfaces:
OMDataSource
All Known Implementing Classes:
ByteArrayDataSource, CharArrayDataSource, InputStreamDataSource, OMDataSourceExtBase

public interface OMDataSourceExt
extends OMDataSource

Interface to a backing object that can can be read and written as XML. To plug an arbitrary object into an OM tree. Follow these steps 1) Provide a class that implements OMDataSourceExt. 2) Use OMFactory.createOMElement(OMDataSource, String, OMNamespace) to build an OMSourcedElement. 3) Add the OMSourcedElement to the OM tree. OMDataSourceExt provides additional methods that are not available on the original OMDataSource.

See Also:
OMDataSource, OMSourceElementImpl

Method Summary
 void close()
          Close the DataSource and free its resources.
 OMDataSourceExt copy()
          Create a copy of the OMDataSourceExt
 java.lang.Object getObject()
          Returns the backing Object.
 java.lang.Object getProperty(java.lang.String key)
          Query a property stored on the OMDataSource
 javax.xml.stream.XMLStreamReader getReader()
          Get parser for element data.
 byte[] getXMLBytes(java.lang.String encoding)
          Returns a byte[] representing the xml data
 java.io.InputStream getXMLInputStream(java.lang.String encoding)
          Returns a InputStream representing the xml data
 boolean hasProperty(java.lang.String key)
          Returns true if property is set
 boolean isDestructiveRead()
          Returns true if reading the backing object is destructive.
 boolean isDestructiveWrite()
          Returns true if writing the backing object is destructive.
 void serialize(java.io.OutputStream output, OMOutputFormat format)
          Serializes element data directly to stream.
 void serialize(java.io.Writer writer, OMOutputFormat format)
          Serializes element data directly to writer.
 void serialize(javax.xml.stream.XMLStreamWriter xmlWriter)
          Serializes element data directly to StAX writer.
 java.lang.Object setProperty(java.lang.String key, java.lang.Object value)
          Set a property on the OMDataSource
 

Method Detail

serialize

void serialize(java.io.OutputStream output,
               OMOutputFormat format)
               throws javax.xml.stream.XMLStreamException
Serializes element data directly to stream. Assumes that the backing object is destroyed during serialization if isDestructiveWrite

Specified by:
serialize in interface OMDataSource
Parameters:
output - destination stream for element XML text
format - output format information (null if none; may be ignored if not supported by data binding even if supplied)
Throws:
javax.xml.stream.XMLStreamException
See Also:
OMDataSourceExt

serialize

void serialize(java.io.Writer writer,
               OMOutputFormat format)
               throws javax.xml.stream.XMLStreamException
Serializes element data directly to writer. Assumes that the backing object is destroyed during serialization isDestructiveWrite

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:
javax.xml.stream.XMLStreamException
See Also:
OMDataSourceExt

serialize

void serialize(javax.xml.stream.XMLStreamWriter xmlWriter)
               throws javax.xml.stream.XMLStreamException
Serializes element data directly to StAX writer. Assumes that the backing object is destroyed during serialization isDestructiveWrite

Specified by:
serialize in interface OMDataSource
Parameters:
xmlWriter - destination writer
Throws:
javax.xml.stream.XMLStreamException
See Also:
OMDataSourceExt

getReader

javax.xml.stream.XMLStreamReader getReader()
                                           throws javax.xml.stream.XMLStreamException
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.

Specified by:
getReader in interface OMDataSource
Returns:
element parser
Throws:
javax.xml.stream.XMLStreamException

getObject

java.lang.Object getObject()
Returns the backing Object.

Returns:
Object

isDestructiveRead

boolean isDestructiveRead()
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

boolean isDestructiveWrite()
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

getXMLInputStream

java.io.InputStream getXMLInputStream(java.lang.String encoding)
                                      throws java.io.UnsupportedEncodingException
Returns a InputStream representing the xml data

Parameters:
encoding - String encoding of InputStream
Returns:
InputStream
Throws:
java.io.UnsupportedEncodingException

getXMLBytes

byte[] getXMLBytes(java.lang.String encoding)
                   throws java.io.UnsupportedEncodingException
Returns a byte[] representing the xml data

Parameters:
encoding - String encoding of InputStream
Returns:
byte[]
Throws:
java.io.UnsupportedEncodingException
See Also:
getXMLInputStream

close

void close()
Close the DataSource and free its resources.


copy

OMDataSourceExt copy()
Create a copy of the OMDataSourceExt

Returns:
OMDataSourceExt

hasProperty

boolean hasProperty(java.lang.String key)
Returns true if property is set

Parameters:
key -
Returns:

getProperty

java.lang.Object getProperty(java.lang.String key)
Query a property stored on the OMDataSource

Parameters:
key -
Returns:
value or null

setProperty

java.lang.Object setProperty(java.lang.String key,
                             java.lang.Object value)
Set a property on the OMDataSource

Parameters:
key -
value -
Returns:
old property object or null