org.apache.jorphan.collections

## Class ListedHashTree

- java.lang.Object
- - org.apache.jorphan.collections.HashTree
  - - org.apache.jorphan.collections.ListedHashTree

- All Implemented Interfaces:
    Serializable, Cloneable, Map<Object,HashTree>

      public class ListedHashTree
      extends HashTree
      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 . 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.
  See Also:
    `HashTree`, Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface java.util.Map

      `Map.Entry<K,V>`

  - ### Field Summary

    - ### Fields inherited from class org.apache.jorphan.collections.HashTree

      `data`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ListedHashTree()`
    `ListedHashTree(Collection<?> keys)`
    `ListedHashTree(Object key)`
    `ListedHashTree(Object[] keys)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `Collection<Object>` | `list()` Gets a Collection of all keys in the current HashTree node.
    `HashTree` | `remove(Object key)` Removes the entire branch specified by the given key.
    `void` | `replaceKey(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, HashTree t)` Sets a key into the current tree and assigns it a HashTree as its subtree.
    `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.

    - ### Methods inherited from class org.apache.jorphan.collections.HashTree

      `add, add, add, add, add, add, add, add, add, add, add, add, add, addTreePath, cloneTree, containsKey, containsValue, entrySet, get, getArray, getArray, getArray, getTree, getTree, getTree, getTreePath, isEmpty, keySet, list, list, list, put, putAll, search, set, set, set, set, set, size, toString, traverse, values`

    - ### Methods inherited from class java.lang.Object

      `finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface java.util.Map

      `compute, computeIfAbsent, computeIfPresent, forEach, getOrDefault, merge, putIfAbsent, remove, replace, replace, replaceAll`

- - ### Constructor Detail

    - #### ListedHashTree

          public ListedHashTree()

    - #### ListedHashTree

          public ListedHashTree(Object key)

    - #### ListedHashTree

          public ListedHashTree(Collection<?> keys)

    - #### ListedHashTree

          public ListedHashTree(Object[] keys)

  - ### Method Detail

    - #### 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).
      Overrides:
        `clone` in class `HashTree`

    - #### 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.
      Overrides:
        `set` in class `HashTree`
      Parameters:
        `key` - key to be set up
        `value` - value to be set up as a key 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.
      Overrides:
        `set` in class `HashTree`
      Parameters:
        `key` - key to be set up
        `t` - HashTree that the key maps to

    - #### 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.
      Overrides:
        `set` in class `HashTree`
      Parameters:
        `key` - Key to be set up
        `values` - Array of objects to be added as keys in the secondary node

    - #### 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.
      Overrides:
        `set` in class `HashTree`
      Parameters:
        `key` - key to be set up
        `values` - Collection of objects to be added as keys in the secondary node

    - #### replaceKey

          public void replaceKey(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.
      Overrides:
        `replaceKey` in class `HashTree`
      Parameters:
        `currentKey` - name of the key to be replaced
        `newKey` - name of the new key

    - #### 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.
      Overrides:
        `createNewTree` in class `HashTree`
      Returns:
        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.
      Overrides:
        `createNewTree` in class `HashTree`
      Parameters:
        `key` - object to use as the key for the top level
      Returns:
        newly created `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.
      Overrides:
        `createNewTree` in class `HashTree`
      Parameters:
        `values` - objects to be added to the new `HashTree`
      Returns:
        newly created `HashTree`

    - #### add

          public HashTree add(Object key)

      Adds an key into the HashTree at the current level. If a HashTree exists for the key already, no new tree will be added
      Overrides:
        `add` in class `HashTree`
      Parameters:
        `key` - key to be added to HashTree
      Returns:
        newly generated tree, if no tree was found for the given key; existing key otherwise

    - #### list

          public Collection<Object> 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.
      Overrides:
        `list` in class `HashTree`
      Returns:
        Set of all keys in this HashTree

    - #### remove

          public HashTree remove(Object key)

      Removes the entire branch specified by the given key.
      Specified by:
        `remove` in interface `Map<Object,HashTree>`
      Overrides:
        `remove` in class `HashTree`
      See Also:
        `Map.remove(Object)`

    - #### 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.
      Overrides:
        `getArray` in class `HashTree`
      Returns:
        array of all keys in this HashTree.

    - #### hashCode

          public int hashCode()

      Returns a hashcode for this HashTree.
      Specified by:
        `hashCode` in interface `Map<Object,HashTree>`
      Overrides:
        `hashCode` in class `HashTree`
      See Also:
        `Object.hashCode()`

    - #### 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.
      Specified by:
        `equals` in interface `Map<Object,HashTree>`
      Overrides:
        `equals` in class `HashTree`
      Parameters:
        `o` - Object to be compared against
      See Also:
        `Object.equals(Object)`

    - #### clear

          public void clear()

      Clears the HashTree of all contents.
      Specified by:
        `clear` in interface `Map<Object,HashTree>`
      Overrides:
        `clear` in class `HashTree`
      See Also:
        `Map.clear()`

Copyright © 1998-2017 Apache Software Foundation. All Rights Reserved.