Package org.apache.axiom.om
Interface OMDataSourceExt
-
- All Superinterfaces:
OMDataSource
- All Known Implementing Classes:
ByteArrayDataSource,CharArrayDataSource,InputStreamDataSource,OMDataSourceExtBase,ParserInputStreamDataSource,WrappedTextNodeOMDataSourceFromDataSource,WrappedTextNodeOMDataSourceFromReader
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,OMSourcedElement
-
-
Field Summary
Fields Modifier and Type Field Description static StringLOSSY_PREFIX
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidclose()Close the DataSource and free its resources.OMDataSourceExtcopy()Create a copy of the OMDataSourceExtObjectgetObject()Returns the backing Object.ObjectgetProperty(String key)Query a property stored on the OMDataSourceXMLStreamReadergetReader()Get parser for element data.byte[]getXMLBytes(String encoding)Returns a byte[] representing the xml dataInputStreamgetXMLInputStream(String encoding)Returns a InputStream representing the xml databooleanhasProperty(String key)Returns true if property is setbooleanisDestructiveRead()Returns true if reading the backing object is destructive.booleanisDestructiveWrite()Returns true if writing the backing object is destructive.voidserialize(OutputStream output, OMOutputFormat format)Serializes element data directly to stream.voidserialize(Writer writer, OMOutputFormat format)Serializes element data directly to writer.voidserialize(XMLStreamWriter xmlWriter)Serializes element data directly to StAX writer.ObjectsetProperty(String key, Object value)Set a property on the OMDataSource
-
-
-
Field Detail
-
LOSSY_PREFIX
static final String LOSSY_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
serialize
void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException
Serializes element data directly to stream. Assumes that the backing object is destroyed during serialization if isDestructiveWrite- Specified by:
serializein interfaceOMDataSource- Parameters:
output- 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- See Also:
OMDataSourceExt
-
serialize
void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException
Serializes element data directly to writer. Assumes that the backing object is destroyed during serialization isDestructiveWrite- 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- See Also:
OMDataSourceExt
-
serialize
void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException
Serializes element data directly to StAX writer. Assumes that the backing object is destroyed during serialization isDestructiveWrite- Specified by:
serializein interfaceOMDataSource- Parameters:
xmlWriter- destination writer- Throws:
XMLStreamException- See Also:
OMDataSourceExt
-
getReader
XMLStreamReader getReader() throws 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:
getReaderin interfaceOMDataSource- Returns:
- element parser
- Throws:
XMLStreamException
-
getObject
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
InputStream getXMLInputStream(String encoding) throws UnsupportedEncodingException
Returns a InputStream representing the xml data- Parameters:
encoding- String encoding of InputStream- Returns:
- InputStream
- Throws:
UnsupportedEncodingException
-
getXMLBytes
byte[] getXMLBytes(String encoding) throws UnsupportedEncodingException
Returns a byte[] representing the xml data- Parameters:
encoding- String encoding of InputStream- Returns:
- byte[]
- Throws:
UnsupportedEncodingException- See Also:
getXMLInputStream(String)
-
close
void close()
Close the DataSource and free its resources.
-
copy
OMDataSourceExt copy()
Create a copy of the OMDataSourceExt- Returns:
- OMDataSourceExt
-
hasProperty
boolean hasProperty(String key)
Returns true if property is set- Parameters:
key-- Returns:
- TODO
-
getProperty
Object getProperty(String key)
Query a property stored on the OMDataSource- Parameters:
key-- Returns:
- value or null
-
-