public interface OMContainer extends OMSerializable
Exposes the ability to add, find, and iterate over the children of a document or element.
Modifier and Type | Method and Description |
---|---|
void |
addChild(OMNode omNode)
Adds the given node as the last child.
|
void |
buildNext() |
OMXMLParserWrapper |
getBuilder()
Returns the builder object.
|
Iterator |
getChildren()
Returns an iterator for the children of the container.
|
Iterator |
getChildrenWithLocalName(String localName)
Returns an iterator for child nodes matching the local name.
|
Iterator |
getChildrenWithName(QName elementQName)
Returns an iterator for child nodes matching the given QName.
|
Iterator |
getChildrenWithNamespaceURI(String uri)
Returns an iterator for child nodes matching the namespace uri.
|
OMElement |
getFirstChildWithName(QName qname)
Returns the first child in document order that matches the given QName.
|
OMNode |
getFirstOMChild()
Gets the first child.
|
javax.xml.stream.XMLStreamReader |
getXMLStreamReader()
Get a pull parser representation of this element with caching enabled.
|
javax.xml.stream.XMLStreamReader |
getXMLStreamReader(boolean cache)
Get a pull parser representation of this element.
|
javax.xml.stream.XMLStreamReader |
getXMLStreamReaderWithoutCaching()
Get a pull parser representation of this element with caching disabled.
|
void |
serialize(OutputStream output)
Serializes the node with caching.
|
void |
serialize(OutputStream output,
OMOutputFormat format)
Serializes the node with caching.
|
void |
serialize(Writer writer)
Serializes the node with caching.
|
void |
serialize(Writer writer,
OMOutputFormat format)
Serializes the node with caching.
|
void |
serializeAndConsume(OutputStream output)
Serializes the node without caching.
|
void |
serializeAndConsume(OutputStream output,
OMOutputFormat format)
Serializes the node without caching.
|
void |
serializeAndConsume(Writer writer)
Serializes the node without caching.
|
void |
serializeAndConsume(Writer writer,
OMOutputFormat format)
Serializes the node without caching.
|
build, close, getOMFactory, isComplete, serialize, serialize, serializeAndConsume
OMXMLParserWrapper getBuilder()
void addChild(OMNode omNode)
omNode
- Iterator getChildrenWithName(QName elementQName)
elementQName
- The QName specifying namespace and local name to match.OMElement
items that match the given QNameIterator getChildrenWithLocalName(String localName)
localName
- OMElement
items that match the given localNameIterator getChildrenWithNamespaceURI(String uri)
uri
- OMElement
items that match the given uriOMElement getFirstChildWithName(QName qname) throws OMException
getChildrenWithName(QName)
method.qname
- The QName to use for matching.qname
criteria, or null
if none is found.OMException
- If an error occurs during deferred parsing.getChildrenWithName(QName)
Iterator getChildren()
Iterator
of children, all of which implement OMNode
.getFirstChildWithName(javax.xml.namespace.QName)
,
getChildrenWithName(javax.xml.namespace.QName)
OMNode getFirstOMChild()
void serialize(OutputStream output) throws javax.xml.stream.XMLStreamException
output
- javax.xml.stream.XMLStreamException
void serialize(Writer writer) throws javax.xml.stream.XMLStreamException
writer
- javax.xml.stream.XMLStreamException
void serialize(OutputStream output, OMOutputFormat format) throws javax.xml.stream.XMLStreamException
output
- format
- javax.xml.stream.XMLStreamException
void serialize(Writer writer, OMOutputFormat format) throws javax.xml.stream.XMLStreamException
writer
- format
- javax.xml.stream.XMLStreamException
void serializeAndConsume(OutputStream output) throws javax.xml.stream.XMLStreamException
output
- javax.xml.stream.XMLStreamException
void serializeAndConsume(Writer writer) throws javax.xml.stream.XMLStreamException
writer
- javax.xml.stream.XMLStreamException
void serializeAndConsume(OutputStream output, OMOutputFormat format) throws javax.xml.stream.XMLStreamException
output
- format
- javax.xml.stream.XMLStreamException
void serializeAndConsume(Writer writer, OMOutputFormat format) throws javax.xml.stream.XMLStreamException
writer
- format
- javax.xml.stream.XMLStreamException
void buildNext()
javax.xml.stream.XMLStreamReader getXMLStreamReader()
getXMLStreamReader(boolean)
with cache
set to
true
.XMLStreamReader
representation of this elementjavax.xml.stream.XMLStreamReader getXMLStreamReaderWithoutCaching()
getXMLStreamReader(boolean)
with cache
set to
false
.XMLStreamReader
representation of this elementjavax.xml.stream.XMLStreamReader getXMLStreamReader(boolean cache)
XMLStreamReader
instance 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 the cache
parameter, but the side effects of calling this method and
consuming the reader are different:
State | cache |
Side effects |
---|---|---|
The element is fully built (or was created programmatically). | true |
No side effects. The reader will synthesize StAX events from the object model. |
false |
||
The element is partially built, i.e. deferred parsing is taking place. | true |
When 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. |
false |
The 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
DataHandlerReader
and any binary content will
be reported using this extension. More precisely, if the object model contains an
OMText
instance with OMText.isBinary()
returning true
(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:
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 using
OMXMLStreamReaderValidator
. This was already the case in
Axiom versions prior to 1.2.9. It should also be noted that instances of
OMSourcedElement
(which extends the present interface) may return a reader that is
not implemented using OMStAXWrapper
.OMXMLStreamReader
interface of the returned reader to switch
off MTOM inlining using OMXMLStreamReader.setInlineMTOM(boolean)
. This has now been
deprecated and it is recommended to use
XOPEncodingStreamReader
instead.OMAttachmentAccessor
interface of the returned
reader to fetch attachments using OMAttachmentAccessor.getDataHandler(String)
. There
is no reason anymore to do so: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.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 the cache
parameter, and all binary content is reported through the
DataHandlerReader
extension.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 XMLStreamReader
and DataHandlerReader
are used (and if
necessary, XOPEncodingStreamReader
).
cache
- indicates if caching should be enabledXMLStreamReader
representation of this elementCopyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.