org.ozoneDB.xml.dom
Class NodeImpl

java.lang.Object
  extended byorg.ozoneDB.OzoneObject
      extended byorg.ozoneDB.xml.dom.NodeImpl
All Implemented Interfaces:
java.io.Externalizable, org.w3c.dom.Node, NodeProxy, org.ozoneDB.OzoneCompatible, org.ozoneDB.OzoneCompatibleOrProxy, org.ozoneDB.OzoneRemote, java.io.Serializable
Direct Known Subclasses:
AttrImpl, CharacterDataImpl, DocumentFragmentImpl, DocumentImpl, ElementDeclImpl, ElementImpl, EntityImpl, EntityReferenceImpl, NotationImpl, ParamEntity, ProcessingInstructionImpl

public abstract class NodeImpl
extends org.ozoneDB.OzoneObject
implements NodeProxy, java.io.Externalizable

See Also:
Serialized Form

Field Summary
static short ATTLIST_DECL_NODE
          Attributes list declaration node.
static short ELEMENT_DECL_NODE
          Element declaration node.
static short PARAM_ENTITY_NODE
          Parameter entity declaration node.
 
Fields inherited from interface org.w3c.dom.Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE
 
Constructor Summary
protected NodeImpl()
           
protected NodeImpl(DocumentImpl owner, java.lang.String name, java.lang.String value, boolean checkName)
          Hidden constructor creates a new node.
 
Method Summary
 org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
          Insert newChild as the last child of this parent.
protected  org.w3c.dom.Node castNewChild(org.w3c.dom.Node newChild)
          Checks whether newChild can be added to this node as a child, and if so, performs a necessary cast.
protected  org.w3c.dom.Node castOldChild(org.w3c.dom.Node oldChild)
          Checks whether oldChild is a direct child of this node, and if so, performs a necessary cast.
 void cloneInto(NodeProxy into, boolean deep)
          This clone method is called after a new node has been constructed to copy the contents of this node into the new one.
 org.w3c.dom.NamedNodeMap getAttributes()
          Return attributes of node.
 org.w3c.dom.Node getChild(int index)
          Returns the index-th child of this node.
 int getChildCount()
          Returns the number of children in this node.
 org.w3c.dom.NodeList getChildNodes()
          Returns a NodeList object that can be used to traverse this node's children.
 org.w3c.dom.Node getFirstChild()
          Returns the first child of the node.
 org.w3c.dom.Node getLastChild()
          Returns the last child of the node.
 java.lang.String getLocalName()
           
 java.lang.String getNamespaceURI()
           
 org.w3c.dom.Node getNextSibling()
          Returns the next sibling of this node.
 java.lang.String getNodeName()
          Returns the name of the node, set from the constructor.
abstract  short getNodeType()
          Abstract method must be implemented by each node class.
 java.lang.String getNodeValue()
          Returns the value of the node.
 org.w3c.dom.Document getOwnerDocument()
           
 org.w3c.dom.Node getParentNode()
          Returns the parent node of this node.
 java.lang.String getPrefix()
           
 org.w3c.dom.Node getPreviousSibling()
          Returns the previous sibling of this node.
 boolean hasAttributes()
           
 boolean hasChildNodes()
          Return true if there are any childern to this node.
 void init(DocumentProxy owner, java.lang.String name, java.lang.String value, boolean checkName)
           
 org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild, org.w3c.dom.Node refChild)
          Insert newChild in this parent, before the existing child refChild.
 boolean isReadOnly()
          Returns true if node is read-only and cannot be modified, or if node belongs to a read-only document.
 boolean isSupported(java.lang.String s, java.lang.String s1)
           
 void normalize()
           
protected  void notifyIterators(org.w3c.dom.Node removedChild)
          Called to notify all the iterators created from this node that a child of this node has been removed.
 void readExternal(java.io.ObjectInput in)
           
 org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
          Remove oldChild from this parent.
 org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild, org.w3c.dom.Node oldChild)
          Replace oldChild with newChild, adding the new child and removing the old one.
 void setNextSibling(org.w3c.dom.Node nextNode)
           
 void setNodeName(java.lang.String nodeName)
           
 void setNodeValue(java.lang.String value)
          Changes the value of the node.
 void setOwnerDocument(org.w3c.dom.Document owner)
           
 void setParentNode(org.w3c.dom.Node newParent)
           
 void setPrefix(java.lang.String prefix)
           
 void setPreviousSibling(org.w3c.dom.Node prevNode)
           
 void setReadOnly()
          Renders this node read only, preventing it's contents from being modified.
 boolean supports(java.lang.String feature, java.lang.String version)
           
 void writeExternal(java.io.ObjectOutput out)
           
 
Methods inherited from class org.ozoneDB.OzoneObject
container, database, deleteRecursive, equals, getHandle, getObjectID, handle, hashCode, onActivate, onCreate, onDelete, onPassivate, requireWriteLocking, self, setContainer, toString, toXML
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ozoneDB.OzoneCompatibleOrProxy
getObjectID
 
Methods inherited from interface org.w3c.dom.Node
cloneNode
 

Field Detail

ELEMENT_DECL_NODE

public static final short ELEMENT_DECL_NODE
Element declaration node. Not part of the DOM, identifies an element declaration node appearing in the DTD.

See Also:
Constant Field Values

ATTLIST_DECL_NODE

public static final short ATTLIST_DECL_NODE
Attributes list declaration node. Not part of the DOM, identifies an attributes list declaration node appearing in the DTD..

See Also:
Constant Field Values

PARAM_ENTITY_NODE

public static final short PARAM_ENTITY_NODE
Parameter entity declaration node. Not part of the DOM, identifies an internal or external parameter entity declaration node appearing in the DTD (see ParamEntity).

See Also:
Constant Field Values
Constructor Detail

NodeImpl

protected NodeImpl(DocumentImpl owner,
                   java.lang.String name,
                   java.lang.String value,
                   boolean checkName)
            throws org.w3c.dom.DOMException
Hidden constructor creates a new node. Only one constructor is supported, although cloning is also supported. Owner document must be supplied except for DocumentImpl in which case the document itself becomes its owner. Name must be supplied, either dynamic or static (e.g. "#document#").

If checkName is true, the supplied named is assumed to be a valid XML name token, one that can contain any Unicode letter and digit, must start with a letter, and may also contain hyphen, underscore, digit or colon.

Parameters:
owner - Document owner of this node, or null
name - Name of node
value - Initial value of node or null
checkName - True if name is an XML name token
Throws:
org.w3c.dom.DOMException - INVALID_CHARACTER_ERR Node name cannot contain whitespaces or non-printable characters

NodeImpl

protected NodeImpl()
Method Detail

supports

public boolean supports(java.lang.String feature,
                        java.lang.String version)

normalize

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

getNamespaceURI

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

getPrefix

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

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

getLocalName

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

getNodeType

public abstract short getNodeType()
Abstract method must be implemented by each node class.

Specified by:
getNodeType in interface org.w3c.dom.Node
See Also:
Node.getNodeType()

getNodeName

public final java.lang.String getNodeName()
Returns the name of the node, set from the constructor. Some derived classes do not have the notion of a name, and will return the same name each time. They should do so by setting the default name (e.g. "#comment") in the constructor. This value is never null.

Specified by:
getNodeName in interface org.w3c.dom.Node
See Also:
Node.getNodeName()

setNodeName

public final void setNodeName(java.lang.String nodeName)
Specified by:
setNodeName in interface NodeProxy

getNodeValue

public final java.lang.String getNodeValue()
Returns the value of the node. Depending on the node type, this value is either the node value (e.g. the text in Text), or always null is node has no notion of a value (e.g. Element). For complete list of which node types will return what, see setNodeValue(java.lang.String).

Specified by:
getNodeValue in interface org.w3c.dom.Node
Returns:
Value of node, null if node has no value

setNodeValue

public void setNodeValue(java.lang.String value)
Changes the value of the node. Not all node types support the notion of a value. If the value is not supported by a particular node type, it will throw an exception when calling this method. The following table specifies which node types support values:
 Element                  Not supported
 Attr                     Value supported
 Text                     Value supported
 CDATASection             Value supported
 EntityReference          Not supported
 Entity                   Not supported
 ProcessingInstruction    Value supported
 Comment                  Value supported
 Document                 Not supported
 DocumentType             Not supported
 DocumentFragment         Not supported
 Notation                 Not supported
 
For most node types, if the value is set to null, getNodeValue() will return an empty string instead.

Specified by:
setNodeValue in interface org.w3c.dom.Node
Parameters:
value - New value of node
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR Node is read-only and cannot be modified
org.w3c.dom.DOMException - NO_DATA_ALLOWED_ERR This node does not support a value

getParentNode

public org.w3c.dom.Node getParentNode()
Returns the parent node of this node. Node may not necessarily have a parent node. If node has been created but not added to any other node, it will be parentless. The Document node is always parentless.

Specified by:
getParentNode in interface org.w3c.dom.Node
Returns:
Parent node of this node

setParentNode

public void setParentNode(org.w3c.dom.Node newParent)
Specified by:
setParentNode in interface NodeProxy

notifyIterators

protected void notifyIterators(org.w3c.dom.Node removedChild)
Called to notify all the iterators created from this node that a child of this node has been removed. Iterators that point at this child might choose to select another child to point to. This method is called before the child is removed.

The removed node is a direct child of this node. Affected iterators are those that point at the document tree directly below this node, or the tree below one of its parents. Other iterators are not affected by the change. This method also performs a notification on all the parents of this node.

Parameters:
removedChild - The child node being removed

getChildNodes

public org.w3c.dom.NodeList getChildNodes()
Returns a NodeList object that can be used to traverse this node's children. The node list is live, so every change to this node is reflected in it.

If children are not supported by the derived class, an exception is thrown.

Specified by:
getChildNodes in interface NodeProxy
Returns:
NodeList on this node
Throws:
org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR Childern not supported by this node type
See Also:
NodeList, NodeListImpl

getFirstChild

public final org.w3c.dom.Node getFirstChild()
Returns the first child of the node. If node has no children, returns null.

Specified by:
getFirstChild in interface org.w3c.dom.Node
Returns:
First child or null

getLastChild

public final org.w3c.dom.Node getLastChild()
Returns the last child of the node. If node has no children, returns null.

Specified by:
getLastChild in interface org.w3c.dom.Node
Returns:
Last child or null

getPreviousSibling

public org.w3c.dom.Node getPreviousSibling()
Returns the previous sibling of this node. If node has no previous siblings, returns null.

Specified by:
getPreviousSibling in interface org.w3c.dom.Node
Returns:
Previous sibling or null

setPreviousSibling

public void setPreviousSibling(org.w3c.dom.Node prevNode)
Specified by:
setPreviousSibling in interface NodeProxy

getNextSibling

public org.w3c.dom.Node getNextSibling()
Returns the next sibling of this node. If node has no next siblings, returns null.

Specified by:
getNextSibling in interface org.w3c.dom.Node
Returns:
Next sibling or null

setNextSibling

public void setNextSibling(org.w3c.dom.Node nextNode)
Specified by:
setNextSibling in interface NodeProxy

getAttributes

public org.w3c.dom.NamedNodeMap getAttributes()
Return attributes of node. Returns null unless node is of type Element, in which case the returned NamedNodeMap will provide access to all the element's attributes.

Specified by:
getAttributes in interface org.w3c.dom.Node
Returns:
Attributes of node or null

hasAttributes

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

getOwnerDocument

public final org.w3c.dom.Document getOwnerDocument()
Specified by:
getOwnerDocument in interface org.w3c.dom.Node

hasChildNodes

public final boolean hasChildNodes()
Return true if there are any childern to this node. Less intensive than calling {#link getChildNodes}.

Specified by:
hasChildNodes in interface org.w3c.dom.Node
Returns:
True if node has any children

appendChild

public final org.w3c.dom.Node appendChild(org.w3c.dom.Node newChild)
Insert newChild as the last child of this parent.

If newChild is null, newChild does not belong to this DOM, or childern are not supported by this node type, an exception is thrown.

newChild is removed from its original parent before adding to this parent. If newChild is a DocumentFragment, all its children are inserted one by one into this parent.

Specified by:
appendChild in interface org.w3c.dom.Node
Parameters:
newChild - The new child to add
Returns:
The newly inserted child
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR Node is read-only and cannot be modified
org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR Children are not supported by this node type, or newChild is not a compatible type for this node
See Also:
castNewChild(org.w3c.dom.Node), castOldChild(org.w3c.dom.Node)

removeChild

public final org.w3c.dom.Node removeChild(org.w3c.dom.Node oldChild)
                                   throws org.w3c.dom.DOMException
Remove oldChild from this parent. If oldChild is not a direct child of this parent, or childern are not supported by this node type, an exception is thrown.

Specified by:
removeChild in interface org.w3c.dom.Node
Parameters:
oldChild - The child to remove
Returns:
The removed child
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR Node is read-only and cannot be modified
org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR Children are not supported by this node type
org.w3c.dom.DOMException - NOT_FOUND_ERR oldChild is not a direct child of this node
See Also:
castOldChild(org.w3c.dom.Node)

replaceChild

public final org.w3c.dom.Node replaceChild(org.w3c.dom.Node newChild,
                                           org.w3c.dom.Node oldChild)
                                    throws org.w3c.dom.DOMException
Replace oldChild with newChild, adding the new child and removing the old one.

If newChild does not belong to this DOM, oldChild is not a direct child of this parent, or childern are not supported by this node type, an exception is thrown.

newChild is removed from its original parent before adding to this parent. If newChild is a DocumentFragment, all its children are inserted one by one into this parent.

Specified by:
replaceChild in interface org.w3c.dom.Node
Parameters:
newChild - The new child to add
oldChild - The old child to take away
Returns:
The old child
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR Node is read-only and cannot be modified
org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR Children are not supported by this node type, or newChild is not a compatible type for this node
org.w3c.dom.DOMException - NOT_FOUND_ERR oldChild is not a direct child of this node
See Also:
castNewChild(org.w3c.dom.Node), castOldChild(org.w3c.dom.Node)

insertBefore

public final org.w3c.dom.Node insertBefore(org.w3c.dom.Node newChild,
                                           org.w3c.dom.Node refChild)
                                    throws org.w3c.dom.DOMException
Insert newChild in this parent, before the existing child refChild. If refChild is null, insert newChild as the last child of this parent, akin to calling appendChild(org.w3c.dom.Node).

If newChild is null, newChild does not belong to this DOM, refChild is not a direct child of this node, or childern are not supported by this node type, an exception is thrown.

newChild is removed from its original parent before adding to this parent. If newChild is a DocumentFragment, all its children are inserted one by one into this parent.

Specified by:
insertBefore in interface org.w3c.dom.Node
Parameters:
newChild - The new child to add
refChild - Insert new child before this child, or insert at the end if this child is null
Returns:
The newly inserted child
Throws:
org.w3c.dom.DOMException - NO_MODIFICATION_ALLOWED_ERR Node is read-only and cannot be modified
org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR Children are not supported by this node type, or newChild is not a compatible type for this node
org.w3c.dom.DOMException - NOT_FOUND_ERR oldChild is not null and not a direct child of this node
See Also:
castNewChild(org.w3c.dom.Node), castOldChild(org.w3c.dom.Node)

castNewChild

protected org.w3c.dom.Node castNewChild(org.w3c.dom.Node newChild)
                                 throws org.w3c.dom.DOMException
Checks whether newChild can be added to this node as a child, and if so, performs a necessary cast. newChild cannot be null and must belong to this DOM. It is impossible to transfer nodes between different DOM implementations.

The following rules govern the allowed newChild types:

Any deviation will throw an exception.

Parameters:
newChild - New child node
Returns:
newChild cast to type NodeImpl
Throws:
org.w3c.dom.DOMException - HIERARCHY_REQUEST_ERR newChild is null, does not belong to this DOM, or its node type is not supported for this parent

castOldChild

protected final org.w3c.dom.Node castOldChild(org.w3c.dom.Node oldChild)
                                       throws org.w3c.dom.DOMException
Checks whether oldChild is a direct child of this node, and if so, performs a necessary cast. oldChild cannot be null.

Parameters:
oldChild - Old child node
Returns:
oldChild cast to type NodeImpl
Throws:
org.w3c.dom.DOMException - NOT_FOUND_ERR oldChild is null, or not a direct child of this node

cloneInto

public void cloneInto(NodeProxy into,
                      boolean deep)
This clone method is called after a new node has been constructed to copy the contents of this node into the new one. It clones in contents but not in context, and guarantees that the cloned node will pass the equality test (see OzoneObject.equals(java.lang.Object)).

into must be a valid node of the exact same class as this one. deep is true if deep cloning (includes all children nodes) is to be performed. If deep is false, the clone might not pass the equality test.

Derived classes override and call this method to add per-class variable copying. This method is called by Node.cloneNode(boolean) and the default Object.clone() method.

Contents cloning duplicates the node's name and value, and its children. It does not duplicate it's context, that is, the node's parent or sibling. Initially a clone node has no parents or siblings. However, the node does belong to the same document, since all nodes must belong to some document. The cloned node is never read-only.

Specified by:
cloneInto in interface NodeProxy
Parameters:
into - A node into which to duplicate this one
deep - True if deep cloning is required

setOwnerDocument

public void setOwnerDocument(org.w3c.dom.Document owner)
Specified by:
setOwnerDocument in interface NodeProxy

setReadOnly

public final void setReadOnly()
Renders this node read only, preventing it's contents from being modified. Attempts to modify the node's contents will throw an exception. The node's children are also made read-only.

Specified by:
setReadOnly in interface NodeProxy

isReadOnly

public final boolean isReadOnly()
Returns true if node is read-only and cannot be modified, or if node belongs to a read-only document.

Specified by:
isReadOnly in interface NodeProxy
Returns:
True if node is read-only and cannot be modified
See Also:
setReadOnly()

getChild

public final org.w3c.dom.Node getChild(int index)
Returns the index-th child of this node. This method is used exclusively by NodeListImpl.

Specified by:
getChild in interface NodeProxy
Parameters:
index - Index of child to retrieve
Returns:
The child node or null
See Also:
NodeListImpl.item(int)

getChildCount

public final int getChildCount()
Returns the number of children in this node. This method is used exclusively by NodeListImpl.

Specified by:
getChildCount in interface NodeProxy
Returns:
Number of childern in this node
See Also:
NodeListImpl.getLength()

init

public final void init(DocumentProxy owner,
                       java.lang.String name,
                       java.lang.String value,
                       boolean checkName)
                throws org.w3c.dom.DOMException
Specified by:
init in interface NodeProxy
Throws:
org.w3c.dom.DOMException

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Specified by:
writeExternal in interface java.io.Externalizable
Throws:
java.io.IOException

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Specified by:
readExternal in interface java.io.Externalizable
Throws:
java.io.IOException
java.lang.ClassNotFoundException

isSupported

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


Copyright © 2004 The Ozone Database Project - www.ozone-db.org. All Rights Reserved.