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

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

public abstract class NodeImpl
extends java.lang.Object
implements org.w3c.dom.Node, org.w3c.dom.NodeList, org.apache.axiom.om.impl.OMNodeEx, java.lang.Cloneable


Field Summary
 org.apache.axiom.om.OMXMLParserWrapper builder
          Field builder
protected  boolean done
          Field done
protected  org.apache.axiom.om.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
           
private  java.util.Map userData
          Holds the user data objects
 
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, org.apache.axiom.om.OMFactory factory)
           
protected NodeImpl(org.apache.axiom.om.OMFactory factory)
           
 
Method Summary
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
           
 void build()
          Builds next element.
 void buildWithAttachments()
          Parses this node and builds the object structure in memory.
private  boolean checkNamedNodeMapEquality(org.w3c.dom.Node node)
           
private  boolean checkStringAttributeEquality(org.w3c.dom.Node node)
           
 org.w3c.dom.Node cloneNode(boolean deep)
           
 void close(boolean build)
           
 short compareDocumentPosition(org.w3c.dom.Node arg0)
           
 org.apache.axiom.om.OMNode detach()
           
 org.w3c.dom.NamedNodeMap getAttributes()
          Returns the collection of attributes associated with this node, or null if none.
 java.lang.String getBaseURI()
           
 org.w3c.dom.NodeList getChildNodes()
           
 java.lang.Object getFeature(java.lang.String arg0, java.lang.String arg1)
           
 org.w3c.dom.Node getFirstChild()
          Gets the first child of this Node, or null if none.
 org.w3c.dom.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.
 java.lang.String getLocalName()
           
 java.lang.String getNamespaceURI()
           
 org.apache.axiom.om.OMNode getNextOMSibling()
          Default behavior returns null, overriden in ChildNode.
 org.w3c.dom.Node getNextSibling()
          Returns the next child of this node's parent, or null if none.
 java.lang.String getNodeValue()
           
 org.apache.axiom.om.OMFactory getOMFactory()
          Returns the OMFactory that created this node
 org.w3c.dom.Document getOwnerDocument()
          Finds the document that this Node belongs to (the document in whose context the Node was created).
 org.apache.axiom.om.OMContainer getParent()
           
 org.w3c.dom.Node getParentNode()
           
 java.lang.String getPrefix()
           
 org.apache.axiom.om.OMNode getPreviousOMSibling()
          Default behavior returns null, overriden in ChildNode.
 org.w3c.dom.Node getPreviousSibling()
          Returns the previous child of this node's parent, or null if none.
 java.lang.String getTextContent()
           
 java.lang.Object getUserData(java.lang.String key)
           
 boolean hasAttributes()
           
 boolean hasChildNodes()
           
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
           
 void insertSiblingAfter(org.apache.axiom.om.OMNode sibling)
           
 void insertSiblingBefore(org.apache.axiom.om.OMNode sibling)
           
 void internalSerializeWithCache(javax.xml.stream.XMLStreamWriter writer)
          There no concept of caching in this OM-DOM implementation.
 boolean isComplete()
           
 boolean isDefaultNamespace(java.lang.String arg0)
           
 boolean isEqualNode(org.w3c.dom.Node node)
          Tests whether two nodes are equal.
(package private)  boolean isFirstChild()
           
(package private)  void isFirstChild(boolean value)
           
(package private)  boolean isNormalized()
           
(package private)  void isNormalized(boolean value)
           
(package private)  boolean isOwned()
           
(package private)  void isOwned(boolean value)
           
(package private)  boolean isReadonly()
           
(package private)  void isReadonly(boolean value)
           
 boolean isSameNode(org.w3c.dom.Node node)
           
(package private)  boolean isSpecified()
           
(package private)  void isSpecified(boolean value)
           
 boolean isSupported(java.lang.String feature, java.lang.String version)
           
 org.w3c.dom.Node item(int index)
          NodeList method: Returns the Nth immediate child of this node, or null if the index is out of bounds.
 java.lang.String lookupNamespaceURI(java.lang.String arg0)
           
 java.lang.String lookupPrefix(java.lang.String arg0)
           
 void normalize()
           
(package private)  NodeImpl parentNode()
           
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
           
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
           
 void serialize(java.io.OutputStream output)
           
 void serialize(java.io.OutputStream output, org.apache.axiom.om.OMOutputFormat format)
           
 void serialize(java.io.Writer writer)
           
 void serialize(java.io.Writer writer2, org.apache.axiom.om.OMOutputFormat format)
           
 void serialize(javax.xml.stream.XMLStreamWriter xmlWriter)
           
 void serializeAndConsume(java.io.OutputStream output)
           
 void serializeAndConsume(java.io.OutputStream output, org.apache.axiom.om.OMOutputFormat format)
           
 void serializeAndConsume(java.io.Writer writer)
           
 void serializeAndConsume(java.io.Writer writer2, org.apache.axiom.om.OMOutputFormat format)
           
 void serializeAndConsume(javax.xml.stream.XMLStreamWriter xmlWriter)
           
 void setComplete(boolean state)
           
 void setNextOMSibling(org.apache.axiom.om.OMNode previousSibling)
           
 void setNodeValue(java.lang.String arg0)
           
protected  void setOwnerDocument(DocumentImpl document)
          Sets the owner document.
 void setPrefix(java.lang.String prefix)
           
 void setPreviousOMSibling(org.apache.axiom.om.OMNode previousSibling)
           
 void setTextContent(java.lang.String arg0)
           
 java.lang.Object setUserData(java.lang.String key, java.lang.Object value, org.w3c.dom.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, internalSerializeAndConsume, setParent, setType
 
Methods inherited from interface org.apache.axiom.om.OMNode
discard, getType
 

Field Detail

userData

private java.util.Map userData
Holds the user data objects


builder

public org.apache.axiom.om.OMXMLParserWrapper builder
Field builder


done

protected boolean done
Field done


ownerNode

protected DocumentImpl ownerNode

factory

protected org.apache.axiom.om.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,
                   org.apache.axiom.om.OMFactory factory)

NodeImpl

protected NodeImpl(org.apache.axiom.om.OMFactory factory)
Method Detail

normalize

public void normalize()
Specified by:
normalize in interface org.w3c.dom.Node

hasAttributes

public boolean hasAttributes()
Specified by:
hasAttributes in interface org.w3c.dom.Node

hasChildNodes

public boolean hasChildNodes()
Specified by:
hasChildNodes in interface org.w3c.dom.Node

getLocalName

public java.lang.String getLocalName()
Specified by:
getLocalName in interface org.w3c.dom.Node

getNamespaceURI

public java.lang.String getNamespaceURI()
Specified by:
getNamespaceURI in interface org.w3c.dom.Node

getNodeValue

public java.lang.String getNodeValue()
                              throws org.w3c.dom.DOMException
Specified by:
getNodeValue in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getPrefix

public java.lang.String getPrefix()
Specified by:
getPrefix in interface org.w3c.dom.Node

setNodeValue

public void setNodeValue(java.lang.String arg0)
                  throws org.w3c.dom.DOMException
Specified by:
setNodeValue in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

setPrefix

public void setPrefix(java.lang.String prefix)
               throws org.w3c.dom.DOMException
Specified by:
setPrefix in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getOwnerDocument

public org.w3c.dom.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 org.w3c.dom.Node

getAttributes

public org.w3c.dom.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 org.w3c.dom.Node
See Also:
ElementImpl

getFirstChild

public org.w3c.dom.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 org.w3c.dom.Node
See Also:
ParentNode

getLastChild

public org.w3c.dom.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 org.w3c.dom.Node
See Also:
ParentNode

getNextSibling

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

Specified by:
getNextSibling in interface org.w3c.dom.Node

getParentNode

public org.w3c.dom.Node getParentNode()
Specified by:
getParentNode in interface org.w3c.dom.Node

parentNode

NodeImpl parentNode()

getPreviousSibling

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

Specified by:
getPreviousSibling in interface org.w3c.dom.Node

cloneNode

public org.w3c.dom.Node cloneNode(boolean deep)
Specified by:
cloneNode in interface org.w3c.dom.Node

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Specified by:
getChildNodes in interface org.w3c.dom.Node

isSupported

public boolean isSupported(java.lang.String feature,
                           java.lang.String version)
Specified by:
isSupported in interface org.w3c.dom.Node

appendChild

public org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
                             throws org.w3c.dom.DOMException
Specified by:
appendChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

removeChild

public org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                             throws org.w3c.dom.DOMException
Specified by:
removeChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

insertBefore

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

replaceChild

public org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                     org.w3c.dom.Node oldChild)
                              throws org.w3c.dom.DOMException
Specified by:
replaceChild in interface org.w3c.dom.Node
Throws:
org.w3c.dom.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 org.w3c.dom.NodeList
Returns:
Returns int.
See Also:
ParentNode

item

public org.w3c.dom.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 org.w3c.dom.NodeList
Parameters:
index -
Returns:
Returns org.w3c.dom.Node
See Also:
ParentNode

isOwned

final boolean isOwned()

isOwned

final void isOwned(boolean value)

isFirstChild

final boolean isFirstChild()

isFirstChild

final void isFirstChild(boolean value)

isReadonly

final boolean isReadonly()

isReadonly

final void isReadonly(boolean value)

isSpecified

final boolean isSpecified()

isSpecified

final void isSpecified(boolean value)

isNormalized

final boolean isNormalized()

isNormalized

final void isNormalized(boolean value)

getParent

public org.apache.axiom.om.OMContainer getParent()
                                          throws org.apache.axiom.om.OMException
Specified by:
getParent in interface org.apache.axiom.om.OMNode
Throws:
org.apache.axiom.om.OMException

isComplete

public boolean isComplete()
Specified by:
isComplete in interface org.apache.axiom.om.OMNode

setComplete

public void setComplete(boolean state)
Specified by:
setComplete in interface org.apache.axiom.om.impl.OMNodeEx

internalSerializeWithCache

public void internalSerializeWithCache(javax.xml.stream.XMLStreamWriter writer)
                                throws javax.xml.stream.XMLStreamException
There no concept of caching in this OM-DOM implementation.

Throws:
javax.xml.stream.XMLStreamException

insertSiblingAfter

public void insertSiblingAfter(org.apache.axiom.om.OMNode sibling)
                        throws org.apache.axiom.om.OMException
Specified by:
insertSiblingAfter in interface org.apache.axiom.om.OMNode
Throws:
org.apache.axiom.om.OMException

insertSiblingBefore

public void insertSiblingBefore(org.apache.axiom.om.OMNode sibling)
                         throws org.apache.axiom.om.OMException
Specified by:
insertSiblingBefore in interface org.apache.axiom.om.OMNode
Throws:
org.apache.axiom.om.OMException

getPreviousOMSibling

public org.apache.axiom.om.OMNode getPreviousOMSibling()
Default behavior returns null, overriden in ChildNode.

Specified by:
getPreviousOMSibling in interface org.apache.axiom.om.OMNode

getNextOMSibling

public org.apache.axiom.om.OMNode getNextOMSibling()
Default behavior returns null, overriden in ChildNode.

Specified by:
getNextOMSibling in interface org.apache.axiom.om.OMNode

setPreviousOMSibling

public void setPreviousOMSibling(org.apache.axiom.om.OMNode previousSibling)
Specified by:
setPreviousOMSibling in interface org.apache.axiom.om.impl.OMNodeEx

setNextOMSibling

public void setNextOMSibling(org.apache.axiom.om.OMNode previousSibling)
Specified by:
setNextOMSibling in interface org.apache.axiom.om.impl.OMNodeEx

build

public void build()
Builds next element.

Specified by:
build in interface org.apache.axiom.om.OMNode

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 org.apache.axiom.om.OMNode

close

public void close(boolean build)
Specified by:
close in interface org.apache.axiom.om.OMNode

setOwnerDocument

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

Parameters:
document -

serialize

public void serialize(javax.xml.stream.XMLStreamWriter xmlWriter)
               throws javax.xml.stream.XMLStreamException
Specified by:
serialize in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

serializeAndConsume

public void serializeAndConsume(javax.xml.stream.XMLStreamWriter xmlWriter)
                         throws javax.xml.stream.XMLStreamException
Specified by:
serializeAndConsume in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

detach

public org.apache.axiom.om.OMNode detach()
Specified by:
detach in interface org.apache.axiom.om.OMNode

getBaseURI

public java.lang.String getBaseURI()
Specified by:
getBaseURI in interface org.w3c.dom.Node

compareDocumentPosition

public short compareDocumentPosition(org.w3c.dom.Node arg0)
                              throws org.w3c.dom.DOMException
Specified by:
compareDocumentPosition in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

getTextContent

public java.lang.String getTextContent()
                                throws org.w3c.dom.DOMException
Specified by:
getTextContent in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

setTextContent

public void setTextContent(java.lang.String arg0)
                    throws org.w3c.dom.DOMException
Specified by:
setTextContent in interface org.w3c.dom.Node
Throws:
org.w3c.dom.DOMException

isSameNode

public boolean isSameNode(org.w3c.dom.Node node)
Specified by:
isSameNode in interface org.w3c.dom.Node

lookupPrefix

public java.lang.String lookupPrefix(java.lang.String arg0)
Specified by:
lookupPrefix in interface org.w3c.dom.Node

isDefaultNamespace

public boolean isDefaultNamespace(java.lang.String arg0)
Specified by:
isDefaultNamespace in interface org.w3c.dom.Node

lookupNamespaceURI

public java.lang.String lookupNamespaceURI(java.lang.String arg0)
Specified by:
lookupNamespaceURI in interface org.w3c.dom.Node

isEqualNode

public boolean isEqualNode(org.w3c.dom.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 org.w3c.dom.Node
Parameters:
arg - The node to compare equality with.
Returns:
Returns true if the nodes are equal, false otherwise.
Since:
DOM Level 3

checkStringAttributeEquality

private boolean checkStringAttributeEquality(org.w3c.dom.Node node)

checkNamedNodeMapEquality

private boolean checkNamedNodeMapEquality(org.w3c.dom.Node node)

getFeature

public java.lang.Object getFeature(java.lang.String arg0,
                                   java.lang.String arg1)
Specified by:
getFeature in interface org.w3c.dom.Node

setUserData

public java.lang.Object setUserData(java.lang.String key,
                                    java.lang.Object value,
                                    org.w3c.dom.UserDataHandler userDataHandler)
Specified by:
setUserData in interface org.w3c.dom.Node

getUserData

public java.lang.Object getUserData(java.lang.String key)
Specified by:
getUserData in interface org.w3c.dom.Node

serialize

public void serialize(java.io.OutputStream output)
               throws javax.xml.stream.XMLStreamException
Specified by:
serialize in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

serialize

public void serialize(java.io.Writer writer)
               throws javax.xml.stream.XMLStreamException
Specified by:
serialize in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

serializeAndConsume

public void serializeAndConsume(java.io.OutputStream output)
                         throws javax.xml.stream.XMLStreamException
Specified by:
serializeAndConsume in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

serializeAndConsume

public void serializeAndConsume(java.io.Writer writer)
                         throws javax.xml.stream.XMLStreamException
Specified by:
serializeAndConsume in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

serialize

public void serialize(java.io.OutputStream output,
                      org.apache.axiom.om.OMOutputFormat format)
               throws javax.xml.stream.XMLStreamException
Specified by:
serialize in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

serialize

public void serialize(java.io.Writer writer2,
                      org.apache.axiom.om.OMOutputFormat format)
               throws javax.xml.stream.XMLStreamException
Specified by:
serialize in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

serializeAndConsume

public void serializeAndConsume(java.io.OutputStream output,
                                org.apache.axiom.om.OMOutputFormat format)
                         throws javax.xml.stream.XMLStreamException
Specified by:
serializeAndConsume in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

serializeAndConsume

public void serializeAndConsume(java.io.Writer writer2,
                                org.apache.axiom.om.OMOutputFormat format)
                         throws javax.xml.stream.XMLStreamException
Specified by:
serializeAndConsume in interface org.apache.axiom.om.OMNode
Throws:
javax.xml.stream.XMLStreamException

getOMFactory

public org.apache.axiom.om.OMFactory getOMFactory()
Returns the OMFactory that created this node

Specified by:
getOMFactory in interface org.apache.axiom.om.OMNode