Package org.apache.axiom.om
Interface OMSerializable
-
- All Superinterfaces:
OMInformationItem
- All Known Subinterfaces:
OMComment
,OMContainer
,OMDocType
,OMDocument
,OMElement
,OMEntityReference
,OMNode
,OMProcessingInstruction
,OMSourcedElement
,OMText
,SOAPBody
,SOAPEnvelope
,SOAPFault
,SOAPFaultClassifier
,SOAPFaultCode
,SOAPFaultDetail
,SOAPFaultNode
,SOAPFaultReason
,SOAPFaultRole
,SOAPFaultSubCode
,SOAPFaultText
,SOAPFaultValue
,SOAPHeader
,SOAPHeaderBlock
,SOAPMessage
public interface OMSerializable extends OMInformationItem
Information item that can be serialized (written to an XML stream writer) and deserialized (retrieved from an XML parser) as a unit. This is the common super-interface forOMDocument
andOMNode
. Note thatOMAttribute
andOMNamespace
are information items that don't match the definition of this interface because they can only be read from the parser as part of a larger unit, namely an element.In accordance with the definition given above, this interface declares two sets of methods:
- Methods allowing to control whether the information item has been completely built, i.e. whether all events corresponding to the information item have been retrieved from the parser.
- Methods to write the StAX events corresponding to the information item to an
XMLStreamWriter
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
build()
Builds itself.void
close(boolean build)
If a builder and parser is associated with the node, it is closed.boolean
isComplete()
Indicates whether parser has parsed this information item completely or not.void
serialize(XMLStreamWriter xmlWriter)
Serializes the information item with caching.void
serialize(XMLStreamWriter writer, boolean cache)
Serializes the information item to the givenXMLStreamWriter
.void
serializeAndConsume(XMLStreamWriter xmlWriter)
Serializes the information item without caching.-
Methods inherited from interface org.apache.axiom.om.OMInformationItem
clone, getOMFactory
-
-
-
-
Method Detail
-
isComplete
boolean isComplete()
Indicates whether parser has parsed this information item completely or not. If some info are not available in the item, one has to check this attribute to make sure that, this item has been parsed completely or not.- Returns:
- Returns boolean.
-
build
void build()
Builds itself.
-
close
void close(boolean build)
If a builder and parser is associated with the node, it is closed.- Parameters:
build
- if true, the object is built first before closing the builder/parser
-
serialize
void serialize(XMLStreamWriter xmlWriter) throws XMLStreamException
Serializes the information item with caching. This method has the same effect asserialize(XMLStreamWriter, boolean)
withcache
set totrue
.- Parameters:
xmlWriter
-- Throws:
XMLStreamException
-
serializeAndConsume
void serializeAndConsume(XMLStreamWriter xmlWriter) throws XMLStreamException
Serializes the information item without caching. This method has the same effect asserialize(XMLStreamWriter, boolean)
withcache
set tofalse
.- Parameters:
xmlWriter
-- Throws:
XMLStreamException
-
serialize
void serialize(XMLStreamWriter writer, boolean cache) throws XMLStreamException
Serializes the information item to the givenXMLStreamWriter
.The implementation of this method must satisfy the following requirements:
- If the writer exposes the
DataHandlerWriter
extension, then base64 binary data MUST be written using one of the methods defined by that extension. This will occur if the information item is anOMText
node for whichOMText.isBinary()
returnstrue
or if it is anOMContainer
that has such anOMText
node as descendant. If the writer doesn't expose theDataHandlerWriter
extension, then the implementation MUST useXMLStreamWriter.writeCharacters(String)
orXMLStreamWriter.writeCharacters(char[], int, int)
to write the base64 encoded data to the stream. - The implementation MUST ensure that the produced XML is well formed with respect to
namespaces, i.e. it MUST generate the required namespace declarations using
XMLStreamWriter.writeNamespace(String, String)
andXMLStreamWriter.writeDefaultNamespace(String)
. This requirement is always applicable, even if the method is used to serialize a subtree or if the object model is not well formed with respect to namespaces. This means that the implementation is expected to implement namespace repairing and that the implementation MUST NOT assume that theXMLStreamWriter
supplied by the caller performs any kind of namespace repairing. - The implementation MUST take into account the pre-existing namespace context, so that the
caller can use this method to serialize the information item as part of a larger document.
The implementation uses
XMLStreamWriter.getPrefix(String)
and/orXMLStreamWriter.getNamespaceContext()
to query the pre-existing namespace context.
On the other hand, the caller of this method must ensure that the following requirements are satisfied:
- The namespace context information provided by
XMLStreamWriter.getPrefix(String)
andXMLStreamWriter.getNamespaceContext()
MUST accurately reflect the actual namespace context at the location in the output document where the information item is serialized. In practice this requirement means that if the caller writes content to theXMLStreamWriter
before calling this method, then it must useXMLStreamWriter.setPrefix(String, String)
andXMLStreamWriter.setDefaultNamespace(String)
to update the namespace context. Note that this requirement may be relaxed if the caller implements some form of namespace repairing.
- Parameters:
writer
-cache
- indicates if caching should be enabled- Throws:
XMLStreamException
- if an exception was thrown bywriter
- If the writer exposes the
-
-