org.netbeans.modules.xml.xdm/1 1.19.0 1

org.netbeans.modules.xml.xdm.nodes
Class NodeImpl

java.lang.Object
  extended by org.netbeans.modules.xml.xdm.nodes.NodeImpl
All Implemented Interfaces:
Cloneable, Node
Direct Known Subclasses:
Attribute, Document, Element, Text

public abstract class NodeImpl
extends Object
implements Node, Cloneable

This class provides base implementation of Node Interface.


Field Summary
static String XMLNS
           
 
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
 
Method Summary
 void addedToTree(XDMModel model)
          Marks the node and all its children added to a tree.
 Node appendChild(Node node)
          Adds the node newChild to the end of the list of children of this node.
 void assignNodeId(int id)
           
 void assignNodeIdRecursively()
          Recursively assigns node id's.
 Node clone(boolean cloneContent, boolean cloneAttributes, boolean cloneChildren)
          This api clones the node object and returns the clone.
protected  void cloneNamespacePrefixes(Map<Integer,String> allNS, Map<String,String> prefixes)
           
 Node cloneNode(boolean deep)
          Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
 Node cloneNode(boolean deep, boolean cloneNamespacePrefix)
           
 Node cloneNode(boolean deep, Map<Integer,String> allNS, Map<String,String> clonePrefixes)
           
 Node cloneShallowWithModelContext()
           
 short compareDocumentPosition(Node a)
           
 Node copy()
          Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.
 void copyTokens(Node newNode)
           
 NamedNodeMap getAttributes()
          A NamedNodeMap that contains all attributes of this node.
protected  List<Attribute> getAttributesForRead()
          Returns a readonly List of all attributes of this node.
protected  List<Attribute> getAttributesForWrite()
          Returns a modifiable List of all attributes of this node for updates.
 String getBaseURI()
           
 NodeList getChildNodes()
          A NodeList that contains all children of this node.
 Object getFeature(String a, String b)
           
 Node getFirstChild()
          The first child of this node.
 int getId()
          Returns the id of this node
 int getIndexOfChild(Node n)
          Lookup child index of given child based on node ID.
 Node getLastChild()
          The last child of this node.
 String getLocalName()
           
protected  XDMModel getModel()
           
 String getNamespaceURI()
           
 String getNamespaceURI(Document document)
          Returns namespace of this node in the given Document tree.
 Node getNextSibling()
           
abstract  String getNodeName()
           
abstract  short getNodeType()
           
 String getNodeValue()
           
 Document getOwnerDocument()
          The Document object associated with this node.
 Node getParentNode()
           
 String getPrefix()
           
 Node getPreviousSibling()
           
 String getTextContent()
           
 List<Token> getTokens()
          Returns the readonly lexical tokens associated with this node.
 Object getUserData(String a)
           
 boolean hasAttributes()
          Returns whether this node has any attributes.
 boolean hasChildNodes()
          Returns whether this node has any children.
 int hashCode()
           
 Node insertBefore(Node newChild, Node refChild)
          Inserts the node newChild before the existing child node refChild.
 boolean isDefaultNamespace(String a)
           
 boolean isEqualNode(Node a)
           
 boolean isEquivalentNode(Node node)
           
 boolean isInTree()
          Determines if the node is any tree
 boolean isSameNode(Node a)
           
 boolean isSupported(String feature, String version)
           
static String lookupNamespace(Node current, List<Node> ancestors)
           
static String lookupNamespace(String prefix, List<Node> path)
           
 String lookupNamespaceURI(String prefix)
           
 String lookupPrefix(String uri)
           
static String lookupPrefix(String uri, List<Node> path)
           
 void normalize()
           
 Node removeChild(Node node)
          Removes the node from children list.
 Node reorderChild(Node child, int index)
          Moves child node to new position.
 void reorderChildren(int[] permutation)
          Rearranges children list to the given permutaion.
 Node replaceChild(Node newNode, Node oldNode)
          Repalces the node oldNode with newNode.
 void setNodeValue(String str)
           
 void setPrefix(String str)
           
 void setTextContent(String a)
           
 Object setUserData(String a, Object b, UserDataHandler c)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.netbeans.modules.xml.xdm.nodes.Node
accept
 

Field Detail

XMLNS

public static final String XMLNS
See Also:
Constant Field Values
Method Detail

getId

public final int getId()
Returns the id of this node

Returns:
id - the id of this node

hashCode

public int hashCode()
Overrides:
hashCode in class Object

isInTree

public final boolean isInTree()
Determines if the node is any tree

Returns:
Returns true is in tree, false otherwise
See Also:
#addedToTree()

addedToTree

public void addedToTree(XDMModel model)
Marks the node and all its children added to a tree.


assignNodeIdRecursively

public void assignNodeIdRecursively()
Recursively assigns node id's.


assignNodeId

public void assignNodeId(int id)

getModel

protected XDMModel getModel()

isEquivalentNode

public boolean isEquivalentNode(Node node)
Parameters:
node - Node to compare
Returns:
true the passed node has same id and belongs to same model.

isSupported

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

clone

public Node clone(boolean cloneContent,
                  boolean cloneAttributes,
                  boolean cloneChildren)
This api clones the node object and returns the clone. A node object has content, attributes and children. The api will allow or disallow modification of this underlying data based on the input.

Parameters:
cloneContent - If true the content of clone can be modified.
cloneAttributes - If true the attributes of the clone can be modified.
cloneChildren - If true the children of the clone can be modified.
Returns:
returns the clone of this node

cloneNode

public Node cloneNode(boolean deep)
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes.

Specified by:
cloneNode in interface Node
Parameters:
deep - - If true, recursively clone the subtree under the specified node; if false, clone only the node itself
Returns:
the clone

cloneNode

public Node cloneNode(boolean deep,
                      boolean cloneNamespacePrefix)

cloneNode

public Node cloneNode(boolean deep,
                      Map<Integer,String> allNS,
                      Map<String,String> clonePrefixes)

cloneNamespacePrefixes

protected void cloneNamespacePrefixes(Map<Integer,String> allNS,
                                      Map<String,String> prefixes)

cloneShallowWithModelContext

public Node cloneShallowWithModelContext()

hasChildNodes

public boolean hasChildNodes()
Returns whether this node has any children.

Specified by:
hasChildNodes in interface Node
Returns:
Returns true if this node has any children, false otherwise.

getChildNodes

public NodeList getChildNodes()
A NodeList that contains all children of this node.

Specified by:
getChildNodes in interface Node
Returns:
Returns nodelist containing children

getFirstChild

public Node getFirstChild()
The first child of this node. If there is no such node, this returns null.

Specified by:
getFirstChild in interface Node
Returns:
first child

getLastChild

public Node getLastChild()
The last child of this node. If there is no such node, this returns null.

Specified by:
getLastChild in interface Node
Returns:
last child

getIndexOfChild

public int getIndexOfChild(Node n)
Description copied from interface: Node
Lookup child index of given child based on node ID.

Returns:
child index of given child or -1 if not a child.

appendChild

public Node appendChild(Node node)
Adds the node newChild to the end of the list of children of this node. Since the model is immutable checks if current node and node being added are not already in tree.

Specified by:
appendChild in interface Node
Parameters:
newChild - - The node to add.
Returns:
The node added.

replaceChild

public Node replaceChild(Node newNode,
                         Node oldNode)
Repalces the node oldNode with newNode. Since the model is immutable checks if current node and the node being put, are not already in tree.

Specified by:
replaceChild in interface Node
Parameters:
newChild - - The new node to put in the child list.
oldChild - - The node being replaced in the list.
Returns:
The node replaced.

reorderChild

public Node reorderChild(Node child,
                         int index)
Moves child node to new position.

Parameters:
child - - The node being reordered in the list.
Returns:
The node moved.

reorderChildren

public void reorderChildren(int[] permutation)
Rearranges children list to the given permutaion.

Parameters:
permutation - integer array with index represents current index and value is final index after reordered.

removeChild

public Node removeChild(Node node)
Removes the node from children list. Since the model is immutable checks if current node is not already in tree.

Specified by:
removeChild in interface Node
Parameters:
node - - The node being removed from the list.
Returns:
The node removed.

insertBefore

public Node insertBefore(Node newChild,
                         Node refChild)
                  throws DOMException
Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children. Since the model is immutable checks if current node and node being inserted are not already in tree.

Specified by:
insertBefore in interface Node
Parameters:
newChild - - The node to insert.
refChild - - The reference node, i.e., the node before which the new node must be inserted.
Returns:
The node being inserted.
Throws:
DOMException

hasAttributes

public boolean hasAttributes()
Returns whether this node has any attributes.

Specified by:
hasAttributes in interface Node
Returns:
Returns true if this node has any attributes, false otherwise.

getAttributes

public NamedNodeMap getAttributes()
A NamedNodeMap that contains all attributes of this node.

Specified by:
getAttributes in interface Node
Returns:
Returns NamedNodeMap containing attributes

getOwnerDocument

public Document getOwnerDocument()
The Document object associated with this node.

Specified by:
getOwnerDocument in interface Node
Returns:
the document object

getParentNode

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

getNextSibling

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

getPreviousSibling

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

getNodeType

public abstract short getNodeType()
Specified by:
getNodeType in interface Node

getNodeName

public abstract String getNodeName()
Specified by:
getNodeName in interface Node

getNodeValue

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

setNodeValue

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

getLocalName

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

getNamespaceURI

public String getNamespaceURI(Document document)
Description copied from interface: Node
Returns namespace of this node in the given Document tree.

Returns:
namespace URI string if this node is in the Document tree and has namespace; otherwise null.

getNamespaceURI

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

lookupNamespaceURI

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

lookupNamespace

public static String lookupNamespace(Node current,
                                     List<Node> ancestors)

lookupNamespace

public static String lookupNamespace(String prefix,
                                     List<Node> path)

lookupPrefix

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

lookupPrefix

public static String lookupPrefix(String uri,
                                  List<Node> path)

getPrefix

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

setPrefix

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

normalize

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

compareDocumentPosition

public short compareDocumentPosition(Node a)
Specified by:
compareDocumentPosition in interface Node

getBaseURI

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

getFeature

public Object getFeature(String a,
                         String b)
Specified by:
getFeature in interface Node

getTextContent

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

getUserData

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

isDefaultNamespace

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

isEqualNode

public boolean isEqualNode(Node a)
Specified by:
isEqualNode in interface Node

isSameNode

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

setTextContent

public void setTextContent(String a)
Specified by:
setTextContent in interface Node

setUserData

public Object setUserData(String a,
                          Object b,
                          UserDataHandler c)
Specified by:
setUserData in interface Node

copyTokens

public void copyTokens(Node newNode)

getAttributesForRead

protected List<Attribute> getAttributesForRead()
Returns a readonly List of all attributes of this node.

Returns:
Returns a unmodifiable List of all attributes of this node.

getAttributesForWrite

protected List<Attribute> getAttributesForWrite()
Returns a modifiable List of all attributes of this node for updates.

Returns:
Returns a modifiable List of all attributes of this node.

getTokens

public List<Token> getTokens()
Returns the readonly lexical tokens associated with this node.

Returns:
The unmodifiable list of lexical tokens.

copy

public Node copy()
Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. Used during Copy/Paste, Cut/Paste operation

Returns:
the clone

toString

public String toString()
Overrides:
toString in class Object

org.netbeans.modules.xml.xdm/1 1.19.0 1

Built on May 25 2012.  |  Portions Copyright 1997-2012 Oracle. All rights reserved.