Interface OMContainer
-
- All Superinterfaces:
OMSerializable
- All Known Subinterfaces:
OMContainerEx,OMDocument,OMElement,OMSourcedElement,SOAPBody,SOAPEnvelope,SOAPFault,SOAPFaultClassifier,SOAPFaultCode,SOAPFaultDetail,SOAPFaultNode,SOAPFaultReason,SOAPFaultRole,SOAPFaultSubCode,SOAPFaultText,SOAPFaultValue,SOAPHeader,SOAPHeaderBlock,SOAPMessage
public interface OMContainer extends OMSerializable
Captures the operations related to containment shared by both a document and an element.Exposes the ability to add, find, and iterate over the children of a document or element.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddChild(OMNode omNode)Adds the given node as the last child.voidbuildNext()OMXMLParserWrappergetBuilder()Returns the builder object.IteratorgetChildren()Returns an iterator for the children of the container.IteratorgetChildrenWithLocalName(String localName)Returns an iterator for child nodes matching the local name.IteratorgetChildrenWithName(QName elementQName)Returns an iterator for child nodes matching the given QName.IteratorgetChildrenWithNamespaceURI(String uri)Returns an iterator for child nodes matching the namespace uri.OMElementgetFirstChildWithName(QName qname)Returns the first child in document order that matches the given QName.OMNodegetFirstOMChild()Gets the first child.XMLStreamReadergetXMLStreamReader()Get a pull parser representation of this element with caching enabled.XMLStreamReadergetXMLStreamReader(boolean cache)Get a pull parser representation of this element.XMLStreamReadergetXMLStreamReaderWithoutCaching()Get a pull parser representation of this element with caching disabled.voidserialize(OutputStream output)Serializes the node with caching.voidserialize(OutputStream output, OMOutputFormat format)Serializes the node with caching.voidserialize(Writer writer)Serializes the node with caching.voidserialize(Writer writer, OMOutputFormat format)Serializes the node with caching.voidserializeAndConsume(OutputStream output)Serializes the node without caching.voidserializeAndConsume(OutputStream output, OMOutputFormat format)Serializes the node without caching.voidserializeAndConsume(Writer writer)Serializes the node without caching.voidserializeAndConsume(Writer writer, OMOutputFormat format)Serializes the node without caching.-
Methods inherited from interface org.apache.axiom.om.OMSerializable
build, close, getOMFactory, isComplete, serialize, serialize, serializeAndConsume
-
-
-
-
Method Detail
-
getBuilder
OMXMLParserWrapper getBuilder()
Returns the builder object.- Returns:
- Returns the builder object used to construct the underlying XML infoset on the fly.
-
addChild
void addChild(OMNode omNode)
Adds the given node as the last child. One must preserve the order of children, in this operation. Tip : appending the new child is preferred.- Parameters:
omNode-
-
getChildrenWithName
Iterator getChildrenWithName(QName elementQName)
Returns an iterator for child nodes matching the given QName.- Parameters:
elementQName- The QName specifying namespace and local name to match.- Returns:
- Returns an iterator of
OMElementitems that match the given QName
-
getChildrenWithLocalName
Iterator getChildrenWithLocalName(String localName)
Returns an iterator for child nodes matching the local name.- Parameters:
localName-- Returns:
- Returns an iterator of
OMElementitems that match the given localName
-
getChildrenWithNamespaceURI
Iterator getChildrenWithNamespaceURI(String uri)
Returns an iterator for child nodes matching the namespace uri.- Parameters:
uri-- Returns:
- Returns an iterator of
OMElementitems that match the given uri
-
getFirstChildWithName
OMElement getFirstChildWithName(QName qname) throws OMException
Returns the first child in document order that matches the given QName. The QName filter is applied in the same way as by thegetChildrenWithName(QName)method.- Parameters:
qname- The QName to use for matching.- Returns:
- The first child element in document order that matches the
qnamecriteria, ornullif none is found. - Throws:
OMException- If an error occurs during deferred parsing.- See Also:
getChildrenWithName(QName)
-
getChildren
Iterator getChildren()
Returns an iterator for the children of the container.- Returns:
- Returns a
Iteratorof children, all of which implementOMNode. - See Also:
getFirstChildWithName(javax.xml.namespace.QName),getChildrenWithName(javax.xml.namespace.QName)
-
getFirstOMChild
OMNode getFirstOMChild()
Gets the first child.- Returns:
- Returns the first child. May return null if the container has no children.
-
serialize
void serialize(OutputStream output) throws XMLStreamException
Serializes the node with caching.- Parameters:
output-- Throws:
XMLStreamException
-
serialize
void serialize(Writer writer) throws XMLStreamException
Serializes the node with caching.- Parameters:
writer-- Throws:
XMLStreamException
-
serialize
void serialize(OutputStream output, OMOutputFormat format) throws XMLStreamException
Serializes the node with caching.- Parameters:
output-format-- Throws:
XMLStreamException
-
serialize
void serialize(Writer writer, OMOutputFormat format) throws XMLStreamException
Serializes the node with caching.- Parameters:
writer-format-- Throws:
XMLStreamException
-
serializeAndConsume
void serializeAndConsume(OutputStream output) throws XMLStreamException
Serializes the node without caching.- Parameters:
output-- Throws:
XMLStreamException
-
serializeAndConsume
void serializeAndConsume(Writer writer) throws XMLStreamException
Serializes the node without caching.- Parameters:
writer-- Throws:
XMLStreamException
-
serializeAndConsume
void serializeAndConsume(OutputStream output, OMOutputFormat format) throws XMLStreamException
Serializes the node without caching.- Parameters:
output-format-- Throws:
XMLStreamException
-
serializeAndConsume
void serializeAndConsume(Writer writer, OMOutputFormat format) throws XMLStreamException
Serializes the node without caching.- Parameters:
writer-format-- Throws:
XMLStreamException
-
buildNext
void buildNext()
-
getXMLStreamReader
XMLStreamReader getXMLStreamReader()
Get a pull parser representation of this element with caching enabled. This method has the same effect asgetXMLStreamReader(boolean)withcacheset totrue.- Returns:
- an
XMLStreamReaderrepresentation of this element
-
getXMLStreamReaderWithoutCaching
XMLStreamReader getXMLStreamReaderWithoutCaching()
Get a pull parser representation of this element with caching disabled. This method has the same effect asgetXMLStreamReader(boolean)withcacheset tofalse.- Returns:
- an
XMLStreamReaderrepresentation of this element
-
getXMLStreamReader
XMLStreamReader getXMLStreamReader(boolean cache)
Get a pull parser representation of this element. This methods creates anXMLStreamReaderinstance that produces a sequence of StAX events for this element and its content. The sequence of events is independent of the state of this element and the value of thecacheparameter, but the side effects of calling this method and consuming the reader are different:State cacheSide effects The element is fully built (or was created programmatically). trueNo side effects. The reader will synthesize StAX events from the object model. falseThe element is partially built, i.e. deferred parsing is taking place. trueWhen a StAX event is requested from the reader, it will built the information item (if necessary) and synthesize the StAX event. If the caller completely consumes the reader, the element will be completely built. Otherwise it will be partially built. falseThe reader will delegate to the underlying parser starting from the event corresponding to the last information item that has been built. In other words, after synthesizing a number of events, the reader will switch to delegation mode. An attempt to access the object model afterwards will result in an error. To free any resources associated with the returned reader, the caller MUST invoke the
XMLStreamReader.close()method.The returned reader MAY implement the extension defined by
DataHandlerReaderand any binary content will be reported using this extension. More precisely, if the object model contains anOMTextinstance withOMText.isBinary()returningtrue(or would contain such an instance after it has been fully built), then its data will always be exposed through this extension.The caller MUST NOT make any other assumption about the returned reader, in particular about its runtime type.
Note (non normative): For various reasons, existing code based on Axiom versions prior to 1.2.9 makes assumptions on the returned reader that should no longer be considered valid:
- Some code assumes that the returned reader is an instance of
OMStAXWrapper. While it is true that Axiom internally uses this class to synthesize StAX events, it may wrap this instance in another reader implementation. E.g. depending on the log level, the reader will be wrapped usingOMXMLStreamReaderValidator. This was already the case in Axiom versions prior to 1.2.9. It should also be noted that instances ofOMSourcedElement(which extends the present interface) may return a reader that is not implemented usingOMStAXWrapper. - Some code uses the
OMXMLStreamReaderinterface of the returned reader to switch off MTOM inlining usingOMXMLStreamReader.setInlineMTOM(boolean). This has now been deprecated and it is recommended to useXOPEncodingStreamReaderinstead. - Some existing code uses the
OMAttachmentAccessorinterface of the returned reader to fetch attachments usingOMAttachmentAccessor.getDataHandler(String). There is no reason anymore to do so: - When
OMXMLStreamReader.setInlineMTOM(boolean)is used to disable MTOM inlining,OMAttachmentAccessor.getDataHandler(String)must be used to retrieve the binary content. The fact that this method is deprecated removes the need for this. - In Axiom versions prior to 1.2.9, the sequence of events was inconsistent if the
underlying stream is XOP encoded and caching is disabled (see WSCOMMONS-485). This made it
necessary for the caller to (partially) handle the XOP processing and to use
OMAttachmentAccessor.getDataHandler(String)to retrieve the binary content. Starting with 1.2.9 this is no longer be the case: as specified above, the sequence of events is independent of the state of the object model and the value of thecacheparameter, and all binary content is reported through theDataHandlerReaderextension. - Finally, it should be noted that
OMAttachmentAccessor.getDataHandler(String)doesn't give access to the attachments in the SwA case (neither in 1.2.9 nor in previous versions).
Code making any of these assumptions should be fixed, so that only
XMLStreamReaderandDataHandlerReaderare used (and if necessary,XOPEncodingStreamReader).- Parameters:
cache- indicates if caching should be enabled- Returns:
- an
XMLStreamReaderrepresentation of this element
- Some code assumes that the returned reader is an instance of
-
-