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

Quick Search    Search Deep

pspdash.data
Class HashTree  view HashTree download HashTree.java

java.lang.Object
  extended bypspdash.data.HashTree

public class HashTree
extends java.lang.Object

Implements a specialized hashtable. Keys must be strings, but values can be of any type. Neither keys nor values may be null. Key strings are assumed to contain frequent instances of the '/' character. Keys are split apart on these '/' characters, and a hierarchically nested tree of hashtables is used to store the results.


Nested Class Summary
private  class HashTree.HashTreeIterator
           
 
Field Summary
private  java.util.HashMap attributes
          Attribute values associated with this node
private  java.util.HashMap contents
          The contents of this node of the HashTree
private static int DEFAULT_ATTR_CAPACITY
          The default capacity of a HashTree nodes attributes table
private static int DEFAULT_CAPACITY
          The default capacity of a HashTree node
private  HashTree parent
          The canonical parent of this node of the HashTree.
private  HashTree root
          The root of this collection of HashTree nodes.
private static char SEPARATOR
          The character used to split apart key strings
 
Constructor Summary
  HashTree()
          Create a new, empty HashTree with a default capacity
protected HashTree(HashTree parent, int capacity)
          Create a HashTree node with the given node as its parent
  HashTree(int capacity)
          Create a new, empty HashTree with the given capacity
 
Method Summary
 java.lang.Object get(java.lang.String key)
          Returns the value to which the specified key is mapped in this hashtree.
 java.util.Iterator getAllKeys()
          Return an iterator containing all the keys in this hashtree.
 java.lang.Object getAttribute(java.lang.String name, boolean inherit)
           
protected  java.lang.Object getImpl(java.lang.String key)
          Returns the value to which the specified key is mapped in this hashtree, when key is known to be a non-null, relative reference.
 java.util.Iterator getKeysEndingWith(java.lang.String terminalName)
           
 HashTree getParent()
           
 HashTree getRoot()
           
private  HashTree keyClone(HashTree parent, java.lang.String terminalName)
          Return a copy of this hashtree, with all keys mapped to a bogus value.
 java.lang.Object put(java.lang.String key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtree.
 void putAttribute(java.lang.String name, java.lang.Object value)
           
protected  java.lang.Object putImpl(java.lang.String key, java.lang.Object value)
          Maps the specified key to the specified value in this hashtree, where key is known to be a non-null, relative reference.
 java.lang.Object remove(java.lang.String key)
          Removes the key (and its corresponding value) from this hashtree.
protected  java.lang.Object removeImpl(java.lang.String key)
          Removes the key (and its corresponding value) from this hashtree, when key is known to be a non-null, relative reference.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

private static final char SEPARATOR
The character used to split apart key strings

See Also:
Constant Field Values

DEFAULT_CAPACITY

private static final int DEFAULT_CAPACITY
The default capacity of a HashTree node

See Also:
Constant Field Values

DEFAULT_ATTR_CAPACITY

private static final int DEFAULT_ATTR_CAPACITY
The default capacity of a HashTree nodes attributes table

See Also:
Constant Field Values

contents

private java.util.HashMap contents
The contents of this node of the HashTree


attributes

private java.util.HashMap attributes
Attribute values associated with this node


root

private HashTree root
The root of this collection of HashTree nodes.


parent

private HashTree parent
The canonical parent of this node of the HashTree. (The root node of the HashTree will have a null parent)

Constructor Detail

HashTree

public HashTree()
Create a new, empty HashTree with a default capacity


HashTree

public HashTree(int capacity)
Create a new, empty HashTree with the given capacity


HashTree

protected HashTree(HashTree parent,
                   int capacity)
Create a HashTree node with the given node as its parent

Method Detail

getRoot

public HashTree getRoot()

getParent

public HashTree getParent()

get

public java.lang.Object get(java.lang.String key)
Returns the value to which the specified key is mapped in this hashtree. If key starts with a slash, it is an absolute path and will be looked up relative to the root of the HashTree hierarchy. Otherwise, it is looked up relative to this node of the HashTree.


getImpl

protected java.lang.Object getImpl(java.lang.String key)
Returns the value to which the specified key is mapped in this hashtree, when key is known to be a non-null, relative reference.


remove

public java.lang.Object remove(java.lang.String key)
Removes the key (and its corresponding value) from this hashtree. This method does nothing if the key is not in the hashtree.


removeImpl

protected java.lang.Object removeImpl(java.lang.String key)
Removes the key (and its corresponding value) from this hashtree, when key is known to be a non-null, relative reference.


put

public java.lang.Object put(java.lang.String key,
                            java.lang.Object value)
Maps the specified key to the specified value in this hashtree. Neither the key nor the value can be null. The value can be retrieved by calling the get method with a key that is equal to the original key.


putImpl

protected java.lang.Object putImpl(java.lang.String key,
                                   java.lang.Object value)
Maps the specified key to the specified value in this hashtree, where key is known to be a non-null, relative reference.


getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     boolean inherit)

putAttribute

public void putAttribute(java.lang.String name,
                         java.lang.Object value)

getAllKeys

public java.util.Iterator getAllKeys()
Return an iterator containing all the keys in this hashtree.


getKeysEndingWith

public java.util.Iterator getKeysEndingWith(java.lang.String terminalName)

keyClone

private HashTree keyClone(HashTree parent,
                          java.lang.String terminalName)
Return a copy of this hashtree, with all keys mapped to a bogus value. If the resulting hashtree is empty, returns null.