Package org.apache.axiom.om
Interface OMDataSourceExt
- All Superinterfaces:
OMDataSource
- All Known Implementing Classes:
AbstractOMDataSource
,AbstractPullOMDataSource
,AbstractPushOMDataSource
,BlobOMDataSource
,JAXBOMDataSource
,StringOMDataSource
,WrappedTextNodeOMDataSource
,WrappedTextNodeOMDataSourceFromBlob
,WrappedTextNodeOMDataSourceFromDataSource
,WrappedTextNodeOMDataSourceFromReader
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:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the DataSource and free its resources.copy()
Create a copy of the data source.Get the object that backs this data source.getProperty
(String name) Get the value of a property stored on this instance.byte[]
getXMLBytes
(String encoding) Deprecated.getXMLInputStream
(String encoding) Deprecated.boolean
hasProperty
(String name) Check if a property with the given name is set on this instance.boolean
Returns true if reading the backing object is destructive.boolean
Returns true if writing the backing object is destructive.setProperty
(String name, Object value) Set a property on this instance.Methods inherited from interface org.apache.axiom.om.OMDataSource
getReader, serialize, serialize, serialize
-
Method Details
-
getObject
Object getObject()Get the object that backs this data source. Application code should in general not call this method directly, but useOMSourcedElement.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).
- 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
-
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
Deprecated.Returns a InputStream representing the xml data- Parameters:
encoding
- String encoding of InputStream- Returns:
- InputStream
- Throws:
UnsupportedEncodingException
-
getXMLBytes
Deprecated.Returns a byte[] representing the xml data- Parameters:
encoding
- String encoding of InputStream- Returns:
- byte[]
- Throws:
UnsupportedEncodingException
- See Also:
-
close
void close()Close the DataSource and free its resources. -
copy
OMDataSourceExt copy()Create a copy of the data source. This method is used byOMInformationItem.clone(OMCloneOptions)
when theOMCloneOptions.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.- Returns:
- the copy of the data source, or
null
if the data source can't be copied (e.g. because it is destructive)
-
hasProperty
Check if a property with the given name is set on this instance.- Parameters:
name
- the property name- Returns:
true
if the property is set
-
getProperty
Get the value of a property stored on this instance.- Parameters:
name
- the property name- Returns:
- the property value or
null
-
setProperty
Set a property on this instance.- Parameters:
name
- the property namevalue
- the property value- Returns:
- the old property value or
null
-