org.apache.jorphan.collections
Class ListedHashTree
- Cloneable, Map, Serializable
public class ListedHashTree
implements Serializable, Cloneable
ListedHashTree is a different implementation of the
HashTree
collection class. In the ListedHashTree, the order in which values are added
is preserved (not to be confused with
SortedHashTree
, which sorts
the order of the values using the compare() function). Any listing of nodes
or iteration through the list of nodes of a ListedHashTree will be given in
the order in which the nodes were added to the tree.
ListedHashTree() - Creates an empty new HashTree.
|
ListedHashTree(Collection keys) - Creates a new HashTree and adds all the objects in the given collection
as top-level nodes in the tree.
|
ListedHashTree(Object key) - Creates a new HashTree and adds the given object as a top-level node.
|
ListedHashTree(Object[] keys) - Creates a new HashTree and adds all the objects in the given array as
top-level nodes in the tree.
|
HashTree | add(Object key) - Adds an key into the HashTree at the current level.
|
void | clear() - Clears the HashTree of all contents.
|
Object | clone() - Create a clone of this HashTree.
|
HashTree | createNewTree() - Creates a new tree.
|
HashTree | createNewTree(Collection values) - Creates a new tree.
|
HashTree | createNewTree(Object key) - Creates a new tree.
|
boolean | equals(Object o) - Compares all objects in the tree and verifies that the two trees contain
the same objects at the same tree levels.
|
Object[] | getArray() - Gets an array of all keys in the current HashTree node.
|
int | hashCode() - Returns a hashcode for this HashTree.
|
Set | keySet() - Returns a Set of all the keys in the top-level of this HashTree.
|
Collection | list() - Gets a Collection of all keys in the current HashTree node.
|
Object | remove(Object key) - Removes the entire branch specified by the given key.
|
void | replace(Object currentKey, Object newKey) - Finds the given current key, and replaces it with the given new key.
|
void | set(Object key, Collection values) - Sets a key and its values in the HashTree.
|
void | set(Object key, Object value) - Sets a key and it's value in the HashTree.
|
void | set(Object key, Object[] values) - Sets a key and its values in the HashTree.
|
void | set(Object key, HashTree t) - Sets a key into the current tree and assigns it a HashTree as its
subtree.
|
int | size() - Returns the number of top-level entries in the HashTree.
|
add , add , add , add , add , add , add , add , add , add , add , add , add , add , addTreePath , clear , clone , cloneTree , containsKey , containsValue , createNewTree , createNewTree , createNewTree , entrySet , equals , get , getArray , getArray , getArray , getArray , getTree , getTree , getTree , getTreePath , hashCode , isEmpty , keySet , list , list , list , list , put , putAll , remove , replace , search , set , set , set , set , set , set , set , set , set , size , toString , traverse , values |
ListedHashTree
public ListedHashTree()
Creates an empty new HashTree.
ListedHashTree
public ListedHashTree(Collection keys)
Creates a new HashTree and adds all the objects in the given collection
as top-level nodes in the tree.
keys
- a collection of objects to be added to the created HashTree.
ListedHashTree
public ListedHashTree(Object key)
Creates a new HashTree and adds the given object as a top-level node.
ListedHashTree
public ListedHashTree(Object[] keys)
Creates a new HashTree and adds all the objects in the given array as
top-level nodes in the tree.
add
public HashTree add(Object key)
Adds an key into the HashTree at the current level.
- add in interface HashTree
key
- key to be added to HashTree
clear
public void clear()
Clears the HashTree of all contents.
- clear in interface HashTree
clone
public Object clone()
Create a clone of this HashTree. This is not a deep clone (ie, the
contents of the tree are not cloned).
- clone in interface HashTree
createNewTree
public HashTree createNewTree()
Creates a new tree. This method exists to allow inheriting classes to
generate the appropriate types of nodes. For instance, when a node is
added, it's value is a HashTree. Rather than directly calling the
HashTree() constructor, the createNewTree() method is called. Inheriting
classes should override these methods and create the appropriate subclass
of HashTree.
- createNewTree in interface HashTree
createNewTree
public HashTree createNewTree(Collection values)
Creates a new tree. This method exists to allow inheriting classes to
generate the appropriate types of nodes. For instance, when a node is
added, it's value is a HashTree. Rather than directly calling the
HashTree() constructor, the createNewTree() method is called. Inheriting
classes should override these methods and create the appropriate subclass
of HashTree.
- createNewTree in interface HashTree
createNewTree
public HashTree createNewTree(Object key)
Creates a new tree. This method exists to allow inheriting classes to
generate the appropriate types of nodes. For instance, when a node is
added, it's value is a HashTree. Rather than directly calling the
HashTree() constructor, the createNewTree() method is called. Inheriting
classes should override these methods and create the appropriate subclass
of HashTree.
- createNewTree in interface HashTree
equals
public boolean equals(Object o)
Compares all objects in the tree and verifies that the two trees contain
the same objects at the same tree levels. Returns true if they do, false
otherwise.
- equals in interface HashTree
o
- Object to be compared against
getArray
public Object[] getArray()
Gets an array of all keys in the current HashTree node. If the HashTree
represented a file system, this would be like getting an array of all the
files in the current folder.
- getArray in interface HashTree
- array of all keys in this HashTree.
hashCode
public int hashCode()
Returns a hashcode for this HashTree.
- hashCode in interface HashTree
keySet
public Set keySet()
Returns a Set of all the keys in the top-level of this HashTree.
- keySet in interface HashTree
list
public Collection list()
Gets a Collection of all keys in the current HashTree node. If the
HashTree represented a file system, this would be like getting a
collection of all the files in the current folder.
- list in interface HashTree
- Set of all keys in this HashTree
remove
public Object remove(Object key)
Removes the entire branch specified by the given key.
- remove in interface HashTree
replace
public void replace(Object currentKey,
Object newKey)
Finds the given current key, and replaces it with the given new key. Any
tree structure found under the original key is moved to the new key.
- replace in interface HashTree
set
public void set(Object key,
Collection values)
Sets a key and its values in the HashTree. It sets up a key in the
current node, and then creates a node for that key, and set all the
values in the array as keys in the new node. Any keys previously held
under the given key are removed.
- set in interface HashTree
key
- key to be set upvalues
- Collection of objects to be added as keys in the secondary
node
set
public void set(Object key,
Object value)
Sets a key and it's value in the HashTree. It actually sets up a key, and
then creates a node for the key and sets the value to the new node, as a
key. Any previous nodes that existed under the given key are lost.
- set in interface HashTree
key
- key to be set upvalue
- value to be set up as a key in the secondary node
set
public void set(Object key,
Object[] values)
Sets a key and its values in the HashTree. It sets up a key in the
current node, and then creates a node for that key, and sets all the
values in the array as keys in the new node. Any keys previously held
under the given key are lost.
- set in interface HashTree
key
- Key to be set upvalues
- Array of objects to be added as keys in the secondary node
set
public void set(Object key,
HashTree t)
Sets a key into the current tree and assigns it a HashTree as its
subtree. Any previous entries under the given key are removed.
- set in interface HashTree
key
- key to be set upt
- HashTree that the key maps to
size
public int size()
Returns the number of top-level entries in the HashTree.
- size in interface HashTree
Copyright © 1998-2010 Apache Software Foundation. All Rights Reserved.