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

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

public abstract class NodeImpl
extends Object
implements Node, NodeList, OMNodeEx, Cloneable


Field Summary
 OMXMLParserWrapper builder
          Field builder
protected  boolean done
          Field done
protected  OMFactory factory
          Factory that created this node
protected static short FIRSTCHILD
           
protected  short flags
           
protected static short NORMALIZED
           
protected static short OWNED
           
protected  DocumentImpl ownerNode
           
protected static short READONLY
           
protected static short 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 NodeImpl(DocumentImpl ownerDocument, OMFactory factory)
           
protected NodeImpl(OMFactory factory)
           
 
Method Summary
 Node appendChild(Node newChild)
           
 void build()
          Builds next element.
 void buildWithAttachments()
          Parses this node and builds the object structure in memory.
 Node cloneNode(boolean deep)
           
 void close(boolean build)
          If a builder and parser is associated with the node, it is closed.
 short compareDocumentPosition(Node other)
           
 OMNode detach()
          Removes a node (and all of its children) from its containing parent.
 NamedNodeMap getAttributes()
          Returns the collection of attributes associated with this node, or null if none.
 String getBaseURI()
           
 NodeList getChildNodes()
           
 Object getFeature(String arg0, String arg1)
           
 Node getFirstChild()
          Gets the first child of this Node, or null if none.
 Node getLastChild()
          Gets the last child of this Node, or null if none.
 int getLength()
          NodeList method: Returns the number of immediate children of this node.
 String getLocalName()
           
 String getNamespaceURI()
           
 OMNode getNextOMSibling()
          Default behavior returns null, overriden in ChildNode.
 OMNode getNextOMSiblingIfAvailable()
          Get the next sibling if it is available.
 Node getNextSibling()
          Returns the next child of this node's parent, or null if none.
 String getNodeValue()
           
 OMFactory getOMFactory()
          Returns the OMFactory that created this node
 Document getOwnerDocument()
          Finds the document that this Node belongs to (the document in whose context the Node was created).
 OMContainer getParent()
          Returns the parent containing node.
 Node getParentNode()
           
 String getPrefix()
           
 OMNode getPreviousOMSibling()
          Default behavior returns null, overriden in ChildNode.
 Node getPreviousSibling()
          Returns the previous child of this node's parent, or null if none.
 String getTextContent()
           
 Object getUserData(String key)
           
 boolean hasAttributes()
           
 boolean hasChildNodes()
           
 Node insertBefore(Node newChild, Node refChild)
           
 void insertSiblingAfter(OMNode sibling)
          Inserts a new sibling after the current node.
 void insertSiblingBefore(OMNode sibling)
          Inserts a sibling just before the current node.
 void internalSerialize(XMLStreamWriter writer)
           
 void internalSerializeAndConsume(XMLStreamWriter writer)
           
 boolean isComplete()
          Indicates whether parser has parsed this information item completely or not.
 boolean isDefaultNamespace(String arg0)
           
 boolean isEqualNode(Node node)
          Tests whether two nodes are equal.
 boolean isSameNode(Node node)
           
 boolean isSupported(String feature, String version)
           
 Node item(int index)
          NodeList method: Returns the Nth immediate child of this node, or null if the index is out of bounds.
 String lookupNamespaceURI(String arg0)
           
 String lookupPrefix(String arg0)
           
 void normalize()
           
 Node removeChild(Node oldChild)
           
 Node replaceChild(Node newChild, Node oldChild)
           
 void serialize(OutputStream output)
           
 void serialize(OutputStream output, OMOutputFormat format)
           
 void serialize(Writer writer)
           
 void serialize(Writer writer2, OMOutputFormat format)
           
 void serialize(XMLStreamWriter xmlWriter)
          Serializes the information item with caching.
 void serialize(XMLStreamWriter xmlWriter, boolean cache)
          Serializes the information item.
 void serializeAndConsume(OutputStream output)
           
 void serializeAndConsume(OutputStream output, OMOutputFormat format)
           
 void serializeAndConsume(Writer writer)
           
 void serializeAndConsume(Writer writer2, OMOutputFormat format)
           
 void serializeAndConsume(XMLStreamWriter xmlWriter)
          Serializes the information item without caching.
 void setComplete(boolean state)
           
 void setNextOMSibling(OMNode previousSibling)
           
 void setNodeValue(String arg0)
           
protected  void setOwnerDocument(DocumentImpl document)
          Sets the owner document.
 void setPrefix(String prefix)
           
 void setPreviousOMSibling(OMNode previousSibling)
           
 void setTextContent(String textContent)
           
 Object setUserData(String key, Object value, UserDataHandler userDataHandler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.w3c.dom.Node
getNodeName, getNodeType
 
Methods inherited from interface org.apache.axiom.om.impl.OMNodeEx
internalSerialize, setParent, setType
 
Methods inherited from interface org.apache.axiom.om.OMNode
discard, getType
 

Field Detail

builder

public OMXMLParserWrapper builder
Field builder


done

protected boolean done
Field done


ownerNode

protected DocumentImpl ownerNode

factory

protected final OMFactory factory
Factory that created this node


flags

protected short flags

OWNED

protected static final short OWNED
See Also:
Constant Field Values

FIRSTCHILD

protected static final short FIRSTCHILD
See Also:
Constant Field Values

READONLY

protected static final short READONLY
See Also:
Constant Field Values

SPECIFIED

protected static final short SPECIFIED
See Also:
Constant Field Values

NORMALIZED

protected static final short NORMALIZED
See Also:
Constant Field Values
Constructor Detail

NodeImpl

protected NodeImpl(DocumentImpl ownerDocument,
                   OMFactory factory)

NodeImpl

protected NodeImpl(OMFactory factory)
Method Detail

normalize

public void normalize()
Specified by:
normalize in interface Node

hasAttributes

public boolean hasAttributes()
Specified by:
hasAttributes in interface Node

hasChildNodes

public boolean hasChildNodes()
Specified by:
hasChildNodes in interface Node

getLocalName

public String getLocalName()
Specified by:
getLocalName in interface Node

getNamespaceURI

public String getNamespaceURI()
Specified by:
getNamespaceURI in interface Node

getNodeValue

public String getNodeValue()
                    throws DOMException
Specified by:
getNodeValue in interface Node
Throws:
DOMException

getPrefix

public String getPrefix()
Specified by:
getPrefix in interface Node

setNodeValue

public void setNodeValue(String arg0)
                  throws DOMException
Specified by:
setNodeValue in interface Node
Throws:
DOMException

setPrefix

public void setPrefix(String prefix)
               throws DOMException
Specified by:
setPrefix in interface Node
Throws:
DOMException

getOwnerDocument

public Document getOwnerDocument()
Finds the document that this Node belongs to (the document in whose context the Node was created). The Node may or may not

Specified by:
getOwnerDocument in interface Node

getAttributes

public NamedNodeMap getAttributes()
Returns the collection of attributes associated with this node, or null if none. At this writing, Element is the only type of node which will ever have attributes.

Specified by:
getAttributes in interface Node
See Also:
ElementImpl

getFirstChild

public Node getFirstChild()
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
See Also:
ParentNode

getLastChild

public Node getLastChild()
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
See Also:
ParentNode

getNextSibling

public Node getNextSibling()
Returns the next child of this node's parent, or null if none.

Specified by:
getNextSibling in interface Node

getParentNode

public Node getParentNode()
Specified by:
getParentNode in interface Node

getPreviousSibling

public Node getPreviousSibling()
Returns the previous child of this node's parent, or null if none.

Specified by:
getPreviousSibling in interface Node

cloneNode

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

getChildNodes

public NodeList getChildNodes()
Specified by:
getChildNodes in interface Node

isSupported

public boolean isSupported(String feature,
                           String version)
Specified by:
isSupported in interface Node

appendChild

public Node appendChild(Node newChild)
                 throws DOMException
Specified by:
appendChild in interface Node
Throws:
DOMException

removeChild

public Node removeChild(Node oldChild)
                 throws DOMException
Specified by:
removeChild in interface Node
Throws:
DOMException

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Specified by:
insertBefore in interface Node
Throws:
DOMException

replaceChild

public Node replaceChild(Node newChild,
                         Node oldChild)
                  throws DOMException
Specified by:
replaceChild in interface Node
Throws:
DOMException

getLength

public int getLength()
NodeList method: Returns the number of immediate children of this node.

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

Specified by:
getLength in interface NodeList
Returns:
Returns int.
See Also:
ParentNode

item

public Node item(int index)
NodeList method: Returns the Nth immediate child of this node, or null if the index is out of bounds.

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

Specified by:
item in interface NodeList
Parameters:
index -
Returns:
Returns org.w3c.dom.Node
See Also:
ParentNode

getParent

public OMContainer getParent()
                      throws OMException
Description copied from interface: OMNode
Returns the parent containing node.

Returns the parent container, which may be either an OMDocument or OMElement.

Specified by:
getParent in interface OMNode
Returns:
The OMContainer of the node.
Throws:
OMException

isComplete

public boolean isComplete()
Description copied from interface: OMSerializable
Indicates whether parser has parsed this information item completely or not. If some info are not available in the item, one has to check this attribute to make sure that, this item has been parsed completely or not.

Specified by:
isComplete in interface OMSerializable
Returns:
Returns boolean.

setComplete

public void setComplete(boolean state)
Specified by:
setComplete in interface OMNodeEx

insertSiblingAfter

public void insertSiblingAfter(OMNode sibling)
                        throws OMException
Description copied from interface: OMNode
Inserts a new sibling after the current node. The current node must have a parent for this operation to succeed. If the node to be inserted has a parent, then it will first be detached.

Specified by:
insertSiblingAfter in interface OMNode
Parameters:
sibling - The node that will be added after the current node.
Throws:
OMException - if the current node has no parent

insertSiblingBefore

public void insertSiblingBefore(OMNode sibling)
                         throws OMException
Description copied from interface: OMNode
Inserts a sibling just before the current node. The current node must have a parent for this operation to succeed. If the node to be inserted has a parent, then it will first be detached.

Specified by:
insertSiblingBefore in interface OMNode
Parameters:
sibling - The node that will be added before the current node.
Throws:
OMException - if the current node has no parent

getPreviousOMSibling

public OMNode getPreviousOMSibling()
Default behavior returns null, overriden in ChildNode.

Specified by:
getPreviousOMSibling in interface OMNode
Returns:
Returns node.

getNextOMSibling

public OMNode getNextOMSibling()
Default behavior returns null, overriden in ChildNode.

Specified by:
getNextOMSibling in interface OMNode
Returns:
Returns the next sibling in document order.

getNextOMSiblingIfAvailable

public OMNode getNextOMSiblingIfAvailable()
Description copied from interface: OMNodeEx
Get the next sibling if it is available. The sibling 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 sibling. In contrast to OMNode.getNextOMSibling(), this method will never modify the state of the underlying parser.

Specified by:
getNextOMSiblingIfAvailable in interface OMNodeEx
Returns:
the next sibling or null if the node has no next sibling or the builder has not yet started to build the next sibling

setPreviousOMSibling

public void setPreviousOMSibling(OMNode previousSibling)
Specified by:
setPreviousOMSibling in interface OMNodeEx

setNextOMSibling

public void setNextOMSibling(OMNode previousSibling)
Specified by:
setNextOMSibling in interface OMNodeEx

build

public void build()
Builds next element.

Specified by:
build in interface OMSerializable

buildWithAttachments

public void buildWithAttachments()
Parses this node and builds the object structure in memory. AXIOM supports two levels of deffered building. First is deffered building of AXIOM using StAX. Second level is the deffered building of attachments. AXIOM reads in the attachements from the stream only when user asks by calling getDataHandler(). build() method builds the OM without the attachments. buildAll() builds the OM together with attachement data. This becomes handy when user wants to free the input stream.

Specified by:
buildWithAttachments in interface OMNode

close

public void close(boolean build)
Description copied from interface: OMSerializable
If a builder and parser is associated with the node, it is closed.

Specified by:
close in interface OMSerializable
Parameters:
build - if true, the object is built first before closing the builder/parser

setOwnerDocument

protected void setOwnerDocument(DocumentImpl document)
Sets the owner document.

Parameters:
document -

serialize

public void serialize(XMLStreamWriter xmlWriter)
               throws XMLStreamException
Description copied from interface: OMSerializable
Serializes the information item with caching. This method has the same effect as OMSerializable.serialize(XMLStreamWriter, boolean) with cache set to true.

Specified by:
serialize in interface OMSerializable
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(XMLStreamWriter xmlWriter)
                         throws XMLStreamException
Description copied from interface: OMSerializable
Serializes the information item without caching. This method has the same effect as OMSerializable.serialize(XMLStreamWriter, boolean) with cache set to false.

Specified by:
serializeAndConsume in interface OMSerializable
Throws:
XMLStreamException

serialize

public void serialize(XMLStreamWriter xmlWriter,
                      boolean cache)
               throws XMLStreamException
Description copied from interface: OMSerializable
Serializes the information item.

Specified by:
serialize in interface OMSerializable
cache - indicates if caching should be enabled
Throws:
XMLStreamException

detach

public OMNode detach()
Description copied from interface: OMNode
Removes a node (and all of its children) from its containing parent.

Removes a node from its parent. Partially complete nodes will be completed before they are detached from the model. A node cannot be detached until its next sibling has been identified, so that the next sibling and parent can be updated appropriately. Please note that this will not handle the namespaces. For example, if there you have used a namespace within the detaching node and which is defined outside the detaching node, user has to handle it manually.

Specified by:
detach in interface OMNode
Returns:
The detached node. This is always the instance on which this method is invoked.

getBaseURI

public String getBaseURI()
Specified by:
getBaseURI in interface Node

compareDocumentPosition

public short compareDocumentPosition(Node other)
                              throws DOMException
Specified by:
compareDocumentPosition in interface Node
Throws:
DOMException

getTextContent

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

setTextContent

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

isSameNode

public boolean isSameNode(Node node)
Specified by:
isSameNode in interface Node

lookupPrefix

public String lookupPrefix(String arg0)
Specified by:
lookupPrefix in interface Node

isDefaultNamespace

public boolean isDefaultNamespace(String arg0)
Specified by:
isDefaultNamespace in interface Node

lookupNamespaceURI

public String lookupNamespaceURI(String arg0)
Specified by:
lookupNamespaceURI in interface Node

isEqualNode

public boolean isEqualNode(Node node)
Tests whether two nodes are equal.
This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested with Node.isSameNode(). All nodes that are the same will also be equal, though the reverse may not be true.
Two nodes are equal if and only if the following conditions are satisfied:
For two DocumentType nodes to be equal, the following conditions must also be satisfied:
On the other hand, the following do not affect equality: the ownerDocument, baseURI, and parentNode attributes, the specified attribute for Attr nodes, the schemaTypeInfo attribute for Attr and Element nodes, the Text.isElementContentWhitespace attribute for Text nodes, as well as any user data or event listeners registered on the nodes.

Note: As a general rule, anything not mentioned in the description above is not significant in consideration of equality checking. Note that future versions of this specification may take into account more attributes and implementations conform to this specification are expected to be updated accordingly.

Specified by:
isEqualNode in interface Node
Parameters:
node - The node to compare equality with.
Returns:
Returns true if the nodes are equal, false otherwise.
Since:
DOM Level 3

getFeature

public Object getFeature(String arg0,
                         String arg1)
Specified by:
getFeature in interface Node

setUserData

public Object setUserData(String key,
                          Object value,
                          UserDataHandler userDataHandler)
Specified by:
setUserData in interface Node

getUserData

public Object getUserData(String key)
Specified by:
getUserData in interface Node

serialize

public void serialize(OutputStream output)
               throws XMLStreamException
Specified by:
serialize in interface OMNode
Throws:
XMLStreamException

serialize

public void serialize(Writer writer)
               throws XMLStreamException
Specified by:
serialize in interface OMNode
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(OutputStream output)
                         throws XMLStreamException
Specified by:
serializeAndConsume in interface OMNode
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(Writer writer)
                         throws XMLStreamException
Specified by:
serializeAndConsume in interface OMNode
Throws:
XMLStreamException

serialize

public void serialize(OutputStream output,
                      OMOutputFormat format)
               throws XMLStreamException
Specified by:
serialize in interface OMNode
Throws:
XMLStreamException

serialize

public void serialize(Writer writer2,
                      OMOutputFormat format)
               throws XMLStreamException
Specified by:
serialize in interface OMNode
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(OutputStream output,
                                OMOutputFormat format)
                         throws XMLStreamException
Specified by:
serializeAndConsume in interface OMNode
Throws:
XMLStreamException

serializeAndConsume

public void serializeAndConsume(Writer writer2,
                                OMOutputFormat format)
                         throws XMLStreamException
Specified by:
serializeAndConsume in interface OMNode
Throws:
XMLStreamException

getOMFactory

public OMFactory getOMFactory()
Returns the OMFactory that created this node

Specified by:
getOMFactory in interface OMSerializable

internalSerialize

public void internalSerialize(XMLStreamWriter writer)
                       throws XMLStreamException
Specified by:
internalSerialize in interface OMNodeEx
Throws:
XMLStreamException

internalSerializeAndConsume

public void internalSerializeAndConsume(XMLStreamWriter writer)
                                 throws XMLStreamException
Specified by:
internalSerializeAndConsume in interface OMNodeEx
Throws:
XMLStreamException


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