org.jboss.cache
Class AbstractNode

java.lang.Object
  extended by org.jboss.cache.AbstractNode
All Implemented Interfaces:
DataNode, TreeNode
Direct Known Subclasses:
Node

public abstract class AbstractNode
extends java.lang.Object
implements DataNode

Base class for Node.

Author:
manik

Field Summary
protected  java.util.Map children
          Map of children names to children.
protected  java.util.Map data
          Map of general data keys to values.
protected  Fqn fqn
          Name of the node.
protected static int INDENT
          Default output indent for printing.
 
Fields inherited from interface org.jboss.cache.DataNode
LOCK_TYPE_NONE, LOCK_TYPE_READ, LOCK_TYPE_WRITE, PRINT_LOCK_DETAILS
 
Constructor Summary
AbstractNode()
           
 
Method Summary
 void addChild(java.lang.Object child_name, TreeNode n)
          Adds the already created child node.
 boolean childExists(java.lang.Object child_name)
          Returns true if the child exists.
protected  java.util.Map children()
          Override this if concurrent thread access may occur, in which case return a concurrently modifiable Map.
abstract  java.lang.Object clone()
          Returns a copy of this node.
protected  java.util.Map data()
          Returns null or the Map in use with the data.
 TreeNode getChild(java.lang.Object child_name)
          Returns the named child of this node.
 java.util.Map getChildren()
          Returns an unmodifiable map, mapping keys to child nodes.
 Fqn getFqn()
          Returns the name of this node.
 java.lang.Object getName()
          Returns the name of this node.
 TreeNode getParent()
          Returns null, children may override this method.
 boolean hasChildren()
          Returns true if this node has children.
 void print(java.lang.StringBuffer sb, int indent)
          Prints the node and children.
protected  void printDetailsInMap(java.lang.StringBuffer sb, int indent, java.util.Map map)
          Adds details of the node into a map as strings.
 void printIndent(java.lang.StringBuffer sb, int indent)
          Prints the node with indent.
 void put(java.util.Map data)
          Adds (merges) the contents of the map with the existing data.
 void removeAllChildren()
          Removes all children.
 void removeChild(java.lang.Object child_name)
          Removes the named child of this node.
 void setChildren(java.util.Map children)
          Not to be exposed.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jboss.cache.DataNode
acquire
 
Methods inherited from interface org.jboss.cache.TreeNode
acquireAll, clear, containsKey, createChild, createChild, get, getChildrenLoaded, getData, getDataKeys, getImmutableLock, getLock, getOrCreateChild, isLocked, numAttributes, printDetails, printLockInfo, put, put, release, releaseAll, releaseAllForce, releaseForce, remove, setChildrenLoaded, setRecursiveTreeCacheInstance
 

Field Detail

INDENT

protected static final int INDENT
Default output indent for printing.

See Also:
Constant Field Values

fqn

protected Fqn fqn
Name of the node.


children

protected java.util.Map children
Map of children names to children.


data

protected java.util.Map data
Map of general data keys to values.

Constructor Detail

AbstractNode

public AbstractNode()
Method Detail

getName

public java.lang.Object getName()
Returns the name of this node.

Specified by:
getName in interface TreeNode

getFqn

public Fqn getFqn()
Returns the name of this node.

Specified by:
getFqn in interface TreeNode

getChild

public TreeNode getChild(java.lang.Object child_name)
Description copied from interface: TreeNode
Returns the named child of this node.

Specified by:
getChild in interface TreeNode

getParent

public TreeNode getParent()
Returns null, children may override this method.

Specified by:
getParent in interface TreeNode

childExists

public boolean childExists(java.lang.Object child_name)
Description copied from interface: TreeNode
Returns true if the child exists.

Specified by:
childExists in interface TreeNode

getChildren

public java.util.Map getChildren()
Description copied from interface: TreeNode
Returns an unmodifiable map, mapping keys to child nodes. Implementations need to make sure the map cannot be changed.

Specified by:
getChildren in interface TreeNode
Returns:
Map

setChildren

public void setChildren(java.util.Map children)
Description copied from interface: TreeNode
Not to be exposed. Internal calls should use impl classes. Sets Map

Specified by:
setChildren in interface TreeNode
See Also:
DataNode

hasChildren

public boolean hasChildren()
Description copied from interface: TreeNode
Returns true if this node has children.

Specified by:
hasChildren in interface TreeNode

put

public void put(java.util.Map data)
Description copied from interface: TreeNode
Adds (merges) the contents of the map with the existing data.

Specified by:
put in interface TreeNode

removeChild

public void removeChild(java.lang.Object child_name)
Description copied from interface: TreeNode
Removes the named child of this node.

Specified by:
removeChild in interface TreeNode

removeAllChildren

public void removeAllChildren()
Description copied from interface: TreeNode
Removes all children.

Specified by:
removeAllChildren in interface TreeNode

print

public void print(java.lang.StringBuffer sb,
                  int indent)
Description copied from interface: TreeNode
Prints the node and children.

Specified by:
print in interface TreeNode

printIndent

public void printIndent(java.lang.StringBuffer sb,
                        int indent)
Description copied from interface: TreeNode
Prints the node with indent.

Specified by:
printIndent in interface TreeNode

addChild

public void addChild(java.lang.Object child_name,
                     TreeNode n)
Description copied from interface: TreeNode
Adds the already created child node. Replaces the existing child node if present.

Specified by:
addChild in interface TreeNode

data

protected final java.util.Map data()
Returns null or the Map in use with the data. This needs to be called with a lock if concurrency is a concern.


children

protected java.util.Map children()
Override this if concurrent thread access may occur, in which case return a concurrently modifiable Map.


printDetailsInMap

protected void printDetailsInMap(java.lang.StringBuffer sb,
                                 int indent,
                                 java.util.Map map)
Adds details of the node into a map as strings.


clone

public abstract java.lang.Object clone()
                                throws java.lang.CloneNotSupportedException
Description copied from interface: DataNode
Returns a copy of this node.

Specified by:
clone in interface DataNode
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.