org.apache.axiom.om.impl.dom
Class ParentNode

java.lang.Object
  extended by org.apache.axiom.om.impl.dom.NodeImpl
      extended by org.apache.axiom.om.impl.dom.ChildNode
          extended by org.apache.axiom.om.impl.dom.ParentNode
All Implemented Interfaces:
Cloneable, OMContainerEx, OMNodeEx, OMContainer, OMNode, OMSerializable, Node, NodeList
Direct Known Subclasses:
DocumentFragmentImpl, DocumentImpl, ElementImpl

public abstract class ParentNode
extends ChildNode
implements OMContainerEx


Field Summary
protected  ChildNode firstChild
           
protected  ChildNode lastChild
           
 
Fields inherited from class org.apache.axiom.om.impl.dom.ChildNode
nextSibling, parentNode, previousSibling
 
Fields inherited from class org.apache.axiom.om.impl.dom.NodeImpl
builder, done, factory, FIRSTCHILD, flags, NORMALIZED, OWNED, ownerNode, READONLY, SPECIFIED
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Fields inherited from interface org.apache.axiom.om.OMNode
DTD_NODE, PI_NODE, SPACE_NODE
 
Constructor Summary
protected ParentNode(DocumentImpl ownerDocument, OMFactory factory)
           
protected ParentNode(OMFactory factory)
           
 
Method Summary
 void addChild(OMNode omNode)
          Adds the given node as the last child.
 void buildNext()
           
 Node cloneNode(boolean deep)
           
 OMXMLParserWrapper getBuilder()
          Returns the builder object.
 NodeList getChildNodes()
           
 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 of child nodes having a given qname.
 Iterator getChildrenWithNamespaceURI(String uri)
          Returns an iterator for child nodes matching the namespace uri.
 Node getFirstChild()
          Gets the first child of this Node, or null if none.
 OMElement getFirstChildWithName(QName elementQName)
          Returns the first OMElement child node.
 OMNode getFirstOMChild()
          Gets the first child.
 OMNode getFirstOMChildIfAvailable()
          Get the first child if it is available.
 Node getLastChild()
          Gets the last child of this Node, or null if none.
 String getTextContent()
           
 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.
 boolean hasChildNodes()
           
protected  OMNode importNode(OMNode child)
          This method is intended only to be used by Axiom intenals when merging Objects from different Axiom implementations to the DOOM implementation.
 Node insertBefore(Node newChild, Node refChild)
          Inserts newChild before the refChild.
 Node removeChild(Node oldChild)
          Removes the given child from the DOM Tree.
 Node replaceChild(Node newChild, Node oldChild)
          Replaces the oldChild with the newChild.
 void setFirstChild(OMNode omNode)
          forcefully set the first element in this parent element
 void setLastChild(OMNode omNode)
          Forcefully set the last child
 void setTextContent(String textContent)
           
 
Methods inherited from class org.apache.axiom.om.impl.dom.ChildNode
detach, discard, getNextOMSibling, getNextOMSiblingIfAvailable, getNextSibling, getParent, getParentNode, getPreviousOMSibling, getPreviousSibling, insertSiblingAfter, insertSiblingBefore, setNextOMSibling, setParent, setPreviousOMSibling
 
Methods inherited from class org.apache.axiom.om.impl.dom.NodeImpl
appendChild, build, buildWithAttachments, close, compareDocumentPosition, getAttributes, getBaseURI, getFeature, getLength, getLocalName, getNamespaceURI, getNodeValue, getOMFactory, getOwnerDocument, getPrefix, getUserData, hasAttributes, internalSerialize, internalSerializeAndConsume, isComplete, isDefaultNamespace, isEqualNode, isSameNode, isSupported, item, lookupNamespaceURI, lookupPrefix, normalize, serialize, serialize, serialize, serialize, serialize, serialize, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, serializeAndConsume, setComplete, setNodeValue, setOwnerDocument, setPrefix, setUserData
 
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.impl.OMContainerEx
setComplete
 
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
 
Methods inherited from interface org.w3c.dom.Node
getNodeName, getNodeType
 
Methods inherited from interface org.apache.axiom.om.impl.OMNodeEx
internalSerialize, setType
 
Methods inherited from interface org.apache.axiom.om.OMNode
getType
 

Field Detail

firstChild

protected ChildNode firstChild

lastChild

protected ChildNode lastChild
Constructor Detail

ParentNode

protected ParentNode(DocumentImpl ownerDocument,
                     OMFactory factory)
Parameters:
ownerDocument -

ParentNode

protected ParentNode(OMFactory 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.

addChild

public void addChild(OMNode omNode)
Description copied from interface: OMContainer
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.

Specified by:
addChild in interface OMContainer

buildNext

public void buildNext()
Specified by:
buildNext in interface OMContainer

getChildren

public Iterator getChildren()
Description copied from interface: OMContainer
Returns an iterator for the children of the container.

Specified by:
getChildren in interface OMContainer
Returns:
Returns a Iterator of children, all of which implement OMNode.
See Also:
OMContainer.getFirstChildWithName(javax.xml.namespace.QName), OMContainer.getChildrenWithName(javax.xml.namespace.QName)

getChildrenWithName

public Iterator getChildrenWithName(QName elementQName)
                             throws OMException
Returns an iterator of child nodes having a given qname.

Specified by:
getChildrenWithName in interface OMContainer
Parameters:
elementQName - The QName specifying namespace and local name to match.
Returns:
Returns an iterator of OMElement items that match the given QName
Throws:
OMException
See Also:
(javax.xml.namespace.QName)

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

getFirstChildWithName

public OMElement getFirstChildWithName(QName elementQName)
                                throws OMException
Returns the first OMElement child node.

Specified by:
getFirstChildWithName in interface OMContainer
Parameters:
elementQName - The QName to use for matching.
Returns:
The first child element in document order that matches the qname criteria, or null if none is found.
Throws:
OMException - If an error occurs during deferred parsing.
See Also:
(javax.xml.namespace.QName)

getFirstOMChild

public OMNode getFirstOMChild()
Description copied from interface: OMContainer
Gets the first child.

Specified by:
getFirstOMChild in interface OMContainer
Returns:
Returns the first child. May return null if the container has no children.

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

setFirstChild

public void setFirstChild(OMNode omNode)
Description copied from interface: OMContainerEx
forcefully set the first element in this parent element

Specified by:
setFirstChild in interface OMContainerEx

setLastChild

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

Specified by:
setLastChild in interface OMContainerEx
Parameters:
omNode -

getChildNodes

public NodeList getChildNodes()
Specified by:
getChildNodes in interface Node
Overrides:
getChildNodes in class NodeImpl

getFirstChild

public Node getFirstChild()
Description copied from class: NodeImpl
Gets the first child of this Node, or null if none.

By default we do not have any children, ParentNode overrides this.

Specified by:
getFirstChild in interface Node
Overrides:
getFirstChild in class NodeImpl
See Also:
ParentNode

getLastChild

public Node getLastChild()
Description copied from class: NodeImpl
Gets the last child of this Node, or null if none.

By default we do not have any children, ParentNode overrides this.

Specified by:
getLastChild in interface Node
Overrides:
getLastChild in class NodeImpl
See Also:
ParentNode

hasChildNodes

public boolean hasChildNodes()
Specified by:
hasChildNodes in interface Node
Overrides:
hasChildNodes in class NodeImpl

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Inserts newChild before the refChild. If the refChild is null then the newChild is made the last child.

Specified by:
insertBefore in interface Node
Overrides:
insertBefore in class NodeImpl
Throws:
DOMException

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
Replaces the oldChild with the newChild.

Specified by:
replaceChild in interface Node
Overrides:
replaceChild in class NodeImpl
Throws:
DOMException

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
Removes the given child from the DOM Tree.

Specified by:
removeChild in interface Node
Overrides:
removeChild in class NodeImpl
Throws:
DOMException

cloneNode

public Node cloneNode(boolean deep)
Specified by:
cloneNode in interface Node
Overrides:
cloneNode in class ChildNode

importNode

protected OMNode importNode(OMNode child)
This method is intended only to be used by Axiom intenals when merging Objects from different Axiom implementations to the DOOM implementation.

Parameters:
child -

getTextContent

public String getTextContent()
                      throws DOMException
Specified by:
getTextContent in interface Node
Overrides:
getTextContent in class NodeImpl
Throws:
DOMException

setTextContent

public void setTextContent(String textContent)
                    throws DOMException
Specified by:
setTextContent in interface Node
Overrides:
setTextContent in class NodeImpl
Throws:
DOMException

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()
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

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.