public class OMDocumentImpl extends OMSerializableImpl implements OMDocument, OMContainerEx
Modifier and Type | Field and Description |
---|---|
protected String |
charSetEncoding
Field charSetEncoding Default : UTF-8
|
protected OMElement |
documentElement
Field documentElement
|
protected OMNode |
firstChild
Field firstChild
|
protected String |
isStandalone |
protected OMNode |
lastChild
Field lastChild
|
protected String |
xmlEncoding |
protected String |
xmlVersion
Field xmlVersion
|
builder, done, factory
XML_10, XML_11
Constructor and Description |
---|
OMDocumentImpl(OMElement documentElement,
OMXMLParserWrapper parserWrapper,
OMFactory factory)
Create the
OMDoucment with the factory and set the given OMElement
as the document element |
OMDocumentImpl(OMFactory factory)
Create a
OMDocument given the OMFactory |
OMDocumentImpl(OMXMLParserWrapper parserWrapper,
OMFactory factory)
Create the
OMDocument with the factory |
Modifier and Type | Method and Description |
---|---|
void |
addChild(OMNode child)
Adds child to the element.
|
void |
buildNext()
Forces the parser to proceed, if parser has not yet finished with the XML input.
|
OMXMLParserWrapper |
getBuilder()
Returns the builder object.
|
String |
getCharsetEncoding()
Get the character set encoding scheme.
|
Iterator |
getChildren()
Returns a collection of this element.
|
Iterator |
getChildrenWithLocalName(String localName)
Returns an iterator for child nodes matching the local name.
|
Iterator |
getChildrenWithName(QName elementQName)
Searches for children with a given QName and returns an iterator to traverse through the
OMNodes.
|
Iterator |
getChildrenWithNamespaceURI(String uri)
Returns an iterator for child nodes matching the namespace uri.
|
OMElement |
getFirstChildWithName(QName elementQName)
Method getFirstChildWithName.
|
OMNode |
getFirstOMChild()
Method getFirstOMChild.
|
OMNode |
getFirstOMChildIfAvailable()
Get the first child if it is available.
|
OMElement |
getOMDocumentElement()
Method getDocumentElement.
|
String |
getXMLEncoding()
Get the charset encoding of this document as specified in the XML declaration.
|
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.
|
String |
getXMLVersion()
Returns the XML version.
|
void |
internalSerialize(javax.xml.stream.XMLStreamWriter writer)
Serializes the document with cache.
|
void |
internalSerialize(javax.xml.stream.XMLStreamWriter writer,
boolean cache)
Serializes the node.
|
protected void |
internalSerialize(javax.xml.stream.XMLStreamWriter writer,
boolean cache,
boolean includeXMLDeclaration) |
void |
internalSerializeAndConsume(javax.xml.stream.XMLStreamWriter writer)
Serializes the document with the XML declaration.
|
String |
isStandalone()
XML standalone value.
|
void |
setCharsetEncoding(String charEncoding)
Sets the character set encoding scheme to be used.
|
void |
setComplete(boolean state)
Method setComplete.
|
void |
setFirstChild(OMNode firstChild)
Method setFirstChild.
|
void |
setLastChild(OMNode omNode)
Forcefully set the last child
|
void |
setOMDocumentElement(OMElement documentElement)
Method setDocumentElement.
|
void |
setStandalone(String isStandalone) |
void |
setXMLEncoding(String encoding)
Set the charset encoding for the XML declaration of this document.
|
void |
setXMLVersion(String xmlVersion)
Sets the XML version.
|
build, close, getOMFactory, isComplete, serialize, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
build, close, getOMFactory, isComplete, serialize, serialize, serializeAndConsume
protected OMElement documentElement
protected OMNode firstChild
protected OMNode lastChild
protected String charSetEncoding
protected String xmlVersion
protected String xmlEncoding
protected String isStandalone
public OMDocumentImpl(OMFactory factory)
OMDocument
given the OMFactory
factory
- The OMFactory
that created this instacepublic OMDocumentImpl(OMXMLParserWrapper parserWrapper, OMFactory factory)
OMDocument
with the factoryparserWrapper
- factory
- public OMDocumentImpl(OMElement documentElement, OMXMLParserWrapper parserWrapper, OMFactory factory)
OMDoucment
with the factory and set the given OMElement
as the document elementdocumentElement
- parserWrapper
- factory
- public OMXMLParserWrapper getBuilder()
OMContainer
getBuilder
in interface OMContainer
public OMElement getOMDocumentElement()
getOMDocumentElement
in interface OMDocument
public void setOMDocumentElement(OMElement documentElement)
setOMDocumentElement
in interface OMDocument
documentElement
- public void setComplete(boolean state)
setComplete
in interface OMContainerEx
setComplete
in class OMSerializableImpl
state
- public void buildNext()
buildNext
in interface OMContainer
public void addChild(OMNode child)
addChild
in interface OMContainer
child
- public Iterator getChildren()
getChildren
in interface OMContainer
OMContainer.getFirstChildWithName(javax.xml.namespace.QName)
,
OMContainer.getChildrenWithName(javax.xml.namespace.QName)
public Iterator getChildrenWithName(QName elementQName)
getChildrenWithName
in interface OMContainer
elementQName
- OMException
public Iterator getChildrenWithLocalName(String localName)
OMContainer
getChildrenWithLocalName
in interface OMContainer
OMElement
items that match the given localNamepublic Iterator getChildrenWithNamespaceURI(String uri)
OMContainer
getChildrenWithNamespaceURI
in interface OMContainer
OMElement
items that match the given uripublic OMNode getFirstOMChild()
getFirstOMChild
in interface OMContainer
public OMNode getFirstOMChildIfAvailable()
OMContainerEx
OMSerializable.isComplete()
may return false
when called on the child.
In contrast to OMContainer.getFirstOMChild()
, this method will never modify
the state of the underlying parser.getFirstOMChildIfAvailable
in interface OMContainerEx
null
if the container has no children or
the builder has not yet started to build the first childpublic OMElement getFirstChildWithName(QName elementQName) throws OMException
getFirstChildWithName
in interface OMContainer
elementQName
- OMException
OMContainer.getChildrenWithName(QName)
public void setFirstChild(OMNode firstChild)
setFirstChild
in interface OMContainerEx
firstChild
- public void setLastChild(OMNode omNode)
setLastChild
in interface OMContainerEx
omNode
- public String getCharsetEncoding()
OMDocument
null
when it is not known, such as
when the document was created in memory or from a character stream.getCharsetEncoding
in interface OMDocument
null
if the encoding is not
knownpublic void setCharsetEncoding(String charEncoding)
OMDocument
setCharsetEncoding
in interface OMDocument
public String isStandalone()
OMDocument
isStandalone
in interface OMDocument
public void setStandalone(String isStandalone)
setStandalone
in interface OMDocument
public String getXMLVersion()
OMDocument
getXMLVersion
in interface OMDocument
public void setXMLVersion(String xmlVersion)
OMDocument
setXMLVersion
in interface OMDocument
XML 1.0
,
XML 1.1
public String getXMLEncoding()
OMDocument
getXMLEncoding
in interface OMDocument
null
if the
document didn't have an XML declaration or if the encoding
attribute was
not specified in the XML declarationpublic void setXMLEncoding(String encoding)
OMDocument
setXMLEncoding
in interface OMDocument
encoding
- the value of the encoding
attribute of the XML declarationpublic void internalSerialize(javax.xml.stream.XMLStreamWriter writer, boolean cache) throws javax.xml.stream.XMLStreamException
OMSerializableImpl
internalSerialize
in class OMSerializableImpl
javax.xml.stream.XMLStreamException
protected void internalSerialize(javax.xml.stream.XMLStreamWriter writer, boolean cache, boolean includeXMLDeclaration) throws javax.xml.stream.XMLStreamException
public void internalSerializeAndConsume(javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
public void internalSerialize(javax.xml.stream.XMLStreamWriter writer) throws javax.xml.stream.XMLStreamException
public javax.xml.stream.XMLStreamReader getXMLStreamReader()
OMContainer
OMContainer.getXMLStreamReader(boolean)
with cache
set to
true
.getXMLStreamReader
in interface OMContainer
XMLStreamReader
representation of this elementpublic javax.xml.stream.XMLStreamReader getXMLStreamReaderWithoutCaching()
OMContainer
OMContainer.getXMLStreamReader(boolean)
with cache
set to
false
.getXMLStreamReaderWithoutCaching
in interface OMContainer
XMLStreamReader
representation of this elementpublic javax.xml.stream.XMLStreamReader getXMLStreamReader(boolean cache)
OMContainer
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
).
getXMLStreamReader
in interface OMContainer
cache
- indicates if caching should be enabledXMLStreamReader
representation of this elementCopyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.