org.apache.axiom.om.impl.llom
Class OMDocumentImpl

java.lang.Object
  extended by org.apache.axiom.om.impl.llom.OMSerializableImpl
      extended by org.apache.axiom.om.impl.llom.OMDocumentImpl
All Implemented Interfaces:
OMContainerEx, OMContainer, OMDocument, OMSerializable
Direct Known Subclasses:
SOAPMessageImpl

public class OMDocumentImpl
extends OMSerializableImpl
implements OMDocument, OMContainerEx

Class OMDocumentImpl


Field Summary
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
 
Fields inherited from class org.apache.axiom.om.impl.llom.OMSerializableImpl
builder, done, factory
 
Fields inherited from interface org.apache.axiom.om.OMDocument
XML_10, XML_11
 
Constructor Summary
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
 
Method Summary
 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.
 XMLStreamReader getXMLStreamReader()
          Get a pull parser representation of this element with caching enabled.
 XMLStreamReader getXMLStreamReader(boolean cache)
          Get a pull parser representation of this element.
 XMLStreamReader getXMLStreamReaderWithoutCaching()
          Get a pull parser representation of this element with caching disabled.
 String getXMLVersion()
          Returns the XML version.
 void internalSerialize(XMLStreamWriter writer)
          Serializes the document with cache.
 void internalSerialize(XMLStreamWriter writer, boolean cache)
          Serializes the node.
protected  void internalSerialize(XMLStreamWriter writer, boolean cache, boolean includeXMLDeclaration)
           
 void internalSerializeAndConsume(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.
 
Methods inherited from class org.apache.axiom.om.impl.llom.OMSerializableImpl
build, close, getOMFactory, isComplete, serialize, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.axiom.om.OMContainer
serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume
 
Methods inherited from interface org.apache.axiom.om.OMSerializable
build, close, getOMFactory, isComplete, serialize, serialize, serializeAndConsume
 

Field Detail

documentElement

protected OMElement documentElement
Field documentElement


firstChild

protected OMNode firstChild
Field firstChild


lastChild

protected OMNode lastChild
Field lastChild


charSetEncoding

protected String charSetEncoding
Field charSetEncoding Default : UTF-8


xmlVersion

protected String xmlVersion
Field xmlVersion


xmlEncoding

protected String xmlEncoding

isStandalone

protected String isStandalone
Constructor Detail

OMDocumentImpl

public OMDocumentImpl(OMFactory factory)
Create a OMDocument given the OMFactory

Parameters:
factory - The OMFactory that created this instace

OMDocumentImpl

public OMDocumentImpl(OMXMLParserWrapper parserWrapper,
                      OMFactory factory)
Create the OMDocument with the factory

Parameters:
parserWrapper -
factory -

OMDocumentImpl

public OMDocumentImpl(OMElement documentElement,
                      OMXMLParserWrapper parserWrapper,
                      OMFactory factory)
Create the OMDoucment with the factory and set the given OMElement as the document element

Parameters:
documentElement -
parserWrapper -
factory -
Method Detail

getBuilder

public OMXMLParserWrapper getBuilder()
Description copied from interface: OMContainer
Returns the builder object.

Specified by:
getBuilder in interface OMContainer
Returns:
Returns the builder object used to construct the underlying XML infoset on the fly.

getOMDocumentElement

public OMElement getOMDocumentElement()
Method getDocumentElement.

Specified by:
getOMDocumentElement in interface OMDocument
Returns:
Returns OMElement.

setOMDocumentElement

public void setOMDocumentElement(OMElement documentElement)
Method setDocumentElement.

Specified by:
setOMDocumentElement in interface OMDocument
Parameters:
documentElement -

setComplete

public void setComplete(boolean state)
Method setComplete.

Specified by:
setComplete in interface OMContainerEx
Specified by:
setComplete in class OMSerializableImpl
Parameters:
state -

buildNext

public void buildNext()
Forces the parser to proceed, if parser has not yet finished with the XML input.

Specified by:
buildNext in interface OMContainer

addChild

public void addChild(OMNode child)
Adds child to the element. One can decide whether to append the child or to add to the front of the children list.

Specified by:
addChild in interface OMContainer
Parameters:
child -

getChildren

public Iterator getChildren()
Returns a collection of this element. Children can be of types OMElement, OMText.

Specified by:
getChildren in interface OMContainer
Returns:
Returns iterator.
See Also:
OMContainer.getFirstChildWithName(javax.xml.namespace.QName), OMContainer.getChildrenWithName(javax.xml.namespace.QName)

getChildrenWithName

public Iterator getChildrenWithName(QName elementQName)
Searches for children with a given QName and returns an iterator to traverse through the OMNodes. The QName can contain any combination of prefix, localname and URI.

Specified by:
getChildrenWithName in interface OMContainer
Parameters:
elementQName -
Returns:
Returns Iterator.
Throws:
OMException

getChildrenWithLocalName

public Iterator getChildrenWithLocalName(String localName)
Description copied from interface: OMContainer
Returns an iterator for child nodes matching the local name.

Specified by:
getChildrenWithLocalName in interface OMContainer
Returns:
Returns an iterator of OMElement items that match the given localName

getChildrenWithNamespaceURI

public Iterator getChildrenWithNamespaceURI(String uri)
Description copied from interface: OMContainer
Returns an iterator for child nodes matching the namespace uri.

Specified by:
getChildrenWithNamespaceURI in interface OMContainer
Returns:
Returns an iterator of OMElement items that match the given uri

getFirstOMChild

public OMNode getFirstOMChild()
Method getFirstOMChild.

Specified by:
getFirstOMChild in interface OMContainer
Returns:
Returns first om child.

getFirstOMChildIfAvailable

public OMNode getFirstOMChildIfAvailable()
Description copied from interface: OMContainerEx
Get the first child if it is available. The child is available if it is complete or if the builder has started building the node. In the latter case, 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.

Specified by:
getFirstOMChildIfAvailable in interface OMContainerEx
Returns:
the first child or null if the container has no children or the builder has not yet started to build the first child

getFirstChildWithName

public OMElement getFirstChildWithName(QName elementQName)
                                throws OMException
Method getFirstChildWithName.

Specified by:
getFirstChildWithName in interface OMContainer
Parameters:
elementQName -
Returns:
Returns OMElement.
Throws:
OMException
See Also:
OMContainer.getChildrenWithName(QName)

setFirstChild

public void setFirstChild(OMNode firstChild)
Method setFirstChild.

Specified by:
setFirstChild in interface OMContainerEx
Parameters:
firstChild -

setLastChild

public void setLastChild(OMNode omNode)
Forcefully set the last child

Specified by:
setLastChild in interface OMContainerEx
Parameters:
omNode -

getCharsetEncoding

public String getCharsetEncoding()
Description copied from interface: OMDocument
Get the character set encoding scheme. This is the encoding that was used used for this document at the time of the parsing. This is null when it is not known, such as when the document was created in memory or from a character stream.

Specified by:
getCharsetEncoding in interface OMDocument
Returns:
the charset encoding for this document, or null if the encoding is not known

setCharsetEncoding

public void setCharsetEncoding(String charEncoding)
Description copied from interface: OMDocument
Sets the character set encoding scheme to be used.

Specified by:
setCharsetEncoding in interface OMDocument

isStandalone

public String isStandalone()
Description copied from interface: OMDocument
XML standalone value. This will be yes, no or null (if not available)

Specified by:
isStandalone in interface OMDocument
Returns:
Returns boolean.

setStandalone

public void setStandalone(String isStandalone)
Specified by:
setStandalone in interface OMDocument

getXMLVersion

public String getXMLVersion()
Description copied from interface: OMDocument
Returns the XML version.

Specified by:
getXMLVersion in interface OMDocument
Returns:
Returns String.

setXMLVersion

public void setXMLVersion(String xmlVersion)
Description copied from interface: OMDocument
Sets the XML version.

Specified by:
setXMLVersion in interface OMDocument
See Also:
XML 1.0, XML 1.1

getXMLEncoding

public String getXMLEncoding()
Description copied from interface: OMDocument
Get the charset encoding of this document as specified in the XML declaration.

Specified by:
getXMLEncoding in interface OMDocument
Returns:
the charset encoding specified in the XML declaration, or null if the document didn't have an XML declaration or if the encoding attribute was not specified in the XML declaration

setXMLEncoding

public void setXMLEncoding(String encoding)
Description copied from interface: OMDocument
Set the charset encoding for the XML declaration of this document.

Specified by:
setXMLEncoding in interface OMDocument
Parameters:
encoding - the value of the encoding attribute of the XML declaration

internalSerialize

public void internalSerialize(XMLStreamWriter writer,
                              boolean cache)
                       throws XMLStreamException
Description copied from class: OMSerializableImpl
Serializes the node.

Specified by:
internalSerialize in class OMSerializableImpl
Throws:
XMLStreamException

internalSerialize

protected void internalSerialize(XMLStreamWriter writer,
                                 boolean cache,
                                 boolean includeXMLDeclaration)
                          throws XMLStreamException
Throws:
XMLStreamException

internalSerializeAndConsume

public void internalSerializeAndConsume(XMLStreamWriter writer)
                                 throws XMLStreamException
Serializes the document with the XML declaration.

Throws:
XMLStreamException

internalSerialize

public void internalSerialize(XMLStreamWriter writer)
                       throws XMLStreamException
Serializes the document with cache.

Throws:
XMLStreamException

getXMLStreamReader

public XMLStreamReader getXMLStreamReader()
Description copied from interface: OMContainer
Get a pull parser representation of this element with caching enabled. This method has the same effect as OMContainer.getXMLStreamReader(boolean) with cache set to true.

Specified by:
getXMLStreamReader in interface OMContainer
Returns:
an XMLStreamReader representation of this element

getXMLStreamReaderWithoutCaching

public XMLStreamReader getXMLStreamReaderWithoutCaching()
Description copied from interface: OMContainer
Get a pull parser representation of this element with caching disabled. This method has the same effect as OMContainer.getXMLStreamReader(boolean) with cache set to false.

Specified by:
getXMLStreamReaderWithoutCaching in interface OMContainer
Returns:
an XMLStreamReader representation of this element

getXMLStreamReader

public XMLStreamReader getXMLStreamReader(boolean cache)
Description copied from interface: OMContainer
Get a pull parser representation of this element. This methods creates an 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:

Code making any of these assumptions should be fixed, so that only XMLStreamReader and DataHandlerReader are used (and if necessary, XOPEncodingStreamReader).

Specified by:
getXMLStreamReader in interface OMContainer
Parameters:
cache - indicates if caching should be enabled
Returns:
an XMLStreamReader representation of this element


Copyright © 2004-2013 The Apache Software Foundation. All Rights Reserved.