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
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 -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the DataSource and free its resources.copy()Create a copy of the data source.Get the object that backs this data source.final ObjectgetProperty(String key) Get the value of a property stored on this instance.final byte[]getXMLBytes(String encoding) Returns a byte[] representing the xml datafinal InputStreamgetXMLInputStream(String encoding) Returns a InputStream representing the xml datafinal booleanhasProperty(String key) Check if a property with the given name is set on this instance.final voidserialize(OutputStream out, OMOutputFormat format) Serializes element data directly to stream.final voidserialize(Writer writer, OMOutputFormat format) Serializes element data directly to writer.final ObjectsetProperty(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, waitMethods inherited from interface org.apache.axiom.om.OMDataSource
getReader, serializeMethods inherited from interface org.apache.axiom.om.OMDataSourceExt
isDestructiveRead, isDestructiveWrite
-
Constructor Details
-
AbstractOMDataSource
public AbstractOMDataSource()
-
-
Method Details
-
getProperty
Description copied from interface:OMDataSourceExtGet the value of a property stored on this instance.- Specified by:
getPropertyin interfaceOMDataSourceExt- Parameters:
key- the property name- Returns:
- the property value or
null
-
hasProperty
Description copied from interface:OMDataSourceExtCheck if a property with the given name is set on this instance.- Specified by:
hasPropertyin interfaceOMDataSourceExt- Parameters:
key- the property name- Returns:
trueif the property is set
-
setProperty
Description copied from interface:OMDataSourceExtSet a property on this instance.- Specified by:
setPropertyin interfaceOMDataSourceExt- Parameters:
key- the property namevalue- the property value- Returns:
- the old property value or
null
-
serialize
Description copied from interface:OMDataSourceSerializes 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
OMDataSourceExtandOMDataSourceExt.isDestructiveWrite()returnsfalse.- Specified by:
serializein interfaceOMDataSource- Parameters:
out- destination stream for element XML textformat- 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
Description copied from interface:OMDataSourceSerializes 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
OMDataSourceExtandOMDataSourceExt.isDestructiveWrite()returnsfalse.- Specified by:
serializein interfaceOMDataSource- Parameters:
writer- destination writer for element XML textformat- output format information (nullif none; may be ignored if not supported by data binding even if supplied)- Throws:
XMLStreamException
-
getXMLBytes
Description copied from interface:OMDataSourceExtReturns a byte[] representing the xml data- Specified by:
getXMLBytesin interfaceOMDataSourceExt- Parameters:
encoding- String encoding of InputStream- Returns:
- byte[]
- Throws:
UnsupportedEncodingException- See Also:
-
getXMLInputStream
Description copied from interface:OMDataSourceExtReturns a InputStream representing the xml data- Specified by:
getXMLInputStreamin interfaceOMDataSourceExt- Parameters:
encoding- String encoding of InputStream- Returns:
- InputStream
- Throws:
UnsupportedEncodingException
-
getObject
Description copied from interface:OMDataSourceExtGet 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).
- Specified by:
getObjectin interfaceOMDataSourceExt- Returns:
- the backing object, or
nullif 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:OMDataSourceExtClose the DataSource and free its resources.- Specified by:
closein interfaceOMDataSourceExt
-
copy
Description copied from interface:OMDataSourceExtCreate 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.- Specified by:
copyin interfaceOMDataSourceExt- Returns:
- the copy of the data source, or
nullif the data source can't be copied (e.g. because it is destructive)
-