Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.lanceolav.jreftree
Class W3CMutableTreeNode  view W3CMutableTreeNode download W3CMutableTreeNode.java

java.lang.Object
  extended bycom.lanceolav.jreftree.W3CMutableTreeNode
All Implemented Interfaces:
javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode

public class W3CMutableTreeNode
extends java.lang.Object
implements javax.swing.tree.MutableTreeNode

W3CMutableTreeNode can be used in DefaultTreeModel (in addition to DefaultMutableTreeNode). It is only a thin wrapper around org.w3c.dom.Node, and owns only one instane of this class. It let's this node take care of all the bookkeeping with parents and children. The advantage is that we don't have to implement TreeModel, but can use the existing DefaultTreeModel, which has methods such as insertNodeInto(), which will dispatch the necessary events to update the tree.


Field Summary
private  org.w3c.dom.Node domNode
           
private static java.lang.String[] typeName
           
 
Constructor Summary
W3CMutableTreeNode(org.w3c.dom.Node node)
           
 
Method Summary
 java.util.Enumeration children()
          Returns the children of the receiver as an Enumeration.
 boolean getAllowsChildren()
          Returns true if the receiver allows children.
 javax.swing.tree.TreeNode getChildAt(int childIndex)
          Returns the child TreeNode at index childIndex.
 int getChildCount()
          Returns the number of children TreeNodes the receiver contains.
 int getIndex(javax.swing.tree.TreeNode node)
          Returns the index of node in the receivers children.
private  org.w3c.dom.Node getNode(javax.swing.tree.MutableTreeNode mtn)
           
private  org.w3c.dom.Node getNode(javax.swing.tree.TreeNode tn)
           
 javax.swing.tree.TreeNode getParent()
          Returns the parent TreeNode of the receiver.
 void insert(javax.swing.tree.MutableTreeNode child, int index)
          Adds child to the receiver at index.
 boolean isLeaf()
          Returns true if the receiver is a leaf.
 void remove(int index)
          Removes the child at index from the receiver.
 void remove(javax.swing.tree.MutableTreeNode node)
          Removes node from the receiver.
 void removeFromParent()
          Removes the receiver from its parent.
 void setParent(javax.swing.tree.MutableTreeNode newParent)
          Sets the parent of the receiver to newParent.
 void setUserObject(java.lang.Object object)
          Resets the user object of the receiver to object.
 java.lang.String toString()
          Convert this Object to a human-readable String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

domNode

private org.w3c.dom.Node domNode

typeName

private static final java.lang.String[] typeName
Constructor Detail

W3CMutableTreeNode

public W3CMutableTreeNode(org.w3c.dom.Node node)
Method Detail

getNode

private org.w3c.dom.Node getNode(javax.swing.tree.MutableTreeNode mtn)

getNode

private org.w3c.dom.Node getNode(javax.swing.tree.TreeNode tn)

toString

public java.lang.String toString()
Description copied from class: java.lang.Object
Convert this Object to a human-readable String. There are no limits placed on how long this String should be or what it should contain. We suggest you make it as intuitive as possible to be able to place it into System.out.println() 55 and such.

It is typical, but not required, to ensure that this method never completes abruptly with a java.lang.RuntimeException.

This method will be called when performing string concatenation with this object. If the result is null, string concatenation will instead use "null".

The default implementation returns getClass().getName() + "@" + Integer.toHexString(hashCode()).


insert

public void insert(javax.swing.tree.MutableTreeNode child,
                   int index)
Adds child to the receiver at index. child will be messaged with setParent.

Specified by:
insert in interface javax.swing.tree.MutableTreeNode

remove

public void remove(int index)
Removes the child at index from the receiver.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode

remove

public void remove(javax.swing.tree.MutableTreeNode node)
Removes node from the receiver. setParent will be messaged on node.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode

setUserObject

public void setUserObject(java.lang.Object object)
Resets the user object of the receiver to object.

Specified by:
setUserObject in interface javax.swing.tree.MutableTreeNode

removeFromParent

public void removeFromParent()
Removes the receiver from its parent.

Specified by:
removeFromParent in interface javax.swing.tree.MutableTreeNode

setParent

public void setParent(javax.swing.tree.MutableTreeNode newParent)
Sets the parent of the receiver to newParent.

Specified by:
setParent in interface javax.swing.tree.MutableTreeNode

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
Returns the child TreeNode at index childIndex.

Specified by:
getChildAt in interface javax.swing.tree.TreeNode

getChildCount

public int getChildCount()
Returns the number of children TreeNodes the receiver contains.

Specified by:
getChildCount in interface javax.swing.tree.TreeNode

getParent

public javax.swing.tree.TreeNode getParent()
Returns the parent TreeNode of the receiver.

Specified by:
getParent in interface javax.swing.tree.TreeNode

getIndex

public int getIndex(javax.swing.tree.TreeNode node)
Returns the index of node in the receivers children. If the receiver does not contain node, -1 will be returned.

Specified by:
getIndex in interface javax.swing.tree.TreeNode

getAllowsChildren

public boolean getAllowsChildren()
Returns true if the receiver allows children.

Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

isLeaf

public boolean isLeaf()
Returns true if the receiver is a leaf.

Specified by:
isLeaf in interface javax.swing.tree.TreeNode

children

public java.util.Enumeration children()
Returns the children of the receiver as an Enumeration.

Specified by:
children in interface javax.swing.tree.TreeNode