net.sourceforge.groboutils.util.datastruct.v1
Class PathRegistry

java.lang.Object
  extended bynet.sourceforge.groboutils.util.datastruct.v1.PathRegistry

public class PathRegistry
extends java.lang.Object

A path-tree registry for storing and retrieving objects. Objects can be registered at any point along the tree, but no more than one object may be at each node. A null entry at a point indicates a non-registered node.

Synchronization needs to be hauled-over to increase speed and minimize read interference with writes.

Since:
April 26, 2000 (0.9.0 Alpha)
Version:
$Date: 2003/02/10 22:52:44 $
Author:
Matt Albrecht groboclown@users.sourceforge.net

Constructor Summary
PathRegistry(char separator, boolean ignoreDuplicateSeparators)
          Users must specify all variables without corresponding defaults.
 
Method Summary
protected  void addChildNode(net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode parent, net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode child)
          Child must already be initialized correctly.
protected  net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode findNode(java.lang.String name)
          Find the node with the given name.
protected  net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode findSibling(net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode parent, java.lang.String namePart)
          Find the sibling with the given node name part.
 java.lang.Object get(java.lang.String path)
          Retrieve the object stored at the given path.
protected  java.util.Enumeration parsePath(java.lang.String path)
          Parses the given path into node elements.
 void register(java.lang.String path, java.lang.Object value, boolean isRecursive, boolean isCaseSensitive)
          Register the given object at the given path.
 void remove(java.lang.String path)
          Remove the object at the given path.
protected  void removeChild(net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode parent, net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode child)
          Find the sibling with the given node name part.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathRegistry

public PathRegistry(char separator,
                    boolean ignoreDuplicateSeparators)
Users must specify all variables without corresponding defaults. This prevents the class from implementing defaults, which have a habit of randomly changing.

Method Detail

register

public void register(java.lang.String path,
                     java.lang.Object value,
                     boolean isRecursive,
                     boolean isCaseSensitive)
              throws PathAlreadyRegisteredException
Register the given object at the given path. If the nodes leading up to this end node do not exist, then they will be created.

For future use, we will need to re-do synchronization, so that we synch on the tree node parent being worked on.

Parameters:
path - the path under which the given value will be registered.
value - the object to store under the given path.
isRecursive - set to true to notify the tree that this particular node also covers any sub-paths. If this is false, then queries will only retrieve this node if the exact path is given.
isCaseSensitive - set to true if the given node is to be case sensitive in searches. If the nodes leading to this new node do not exist, then the newly created nodes will have the same case sensitivity as this end node.
Throws:
java.lang.IllegalArgumentException - thrown if the value is null, or the given path is not well formed.
PathAlreadyRegisteredException - thrown if the given path has already been registered to another object.

remove

public void remove(java.lang.String path)
            throws NoRegisteredComponentException
Remove the object at the given path. It only removes nodes if the node no longer has any children. The siblings are automatically compressed.

For future use, we will need to re-do synchronization, so that we synch on the tree node parent being worked on.

Parameters:
path - the tree path specifying which node to remove. If the given node does not exist, or has not been registered, then a NotRegisteredException is thrown.
Throws:
java.lang.IllegalArgumentException - thrown if the value is null, or the given path is not well formed.
NoRegisteredComponentException - thrown if the given path node has not yet been registered.

get

public java.lang.Object get(java.lang.String path)
Retrieve the object stored at the given path.

Need to synchronize better so that reads don't collide with writes, but reads can be done asynchronously.

Parameters:
path - the path which specifies the object to retrieve.
Returns:
the object which was registered at the given path, or null if nothing is registered there.

parsePath

protected java.util.Enumeration parsePath(java.lang.String path)
Parses the given path into node elements. The last item in the list is ignored, unless the path ends with the path separator character.


findSibling

protected net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode findSibling(net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode parent,
                                                                                          java.lang.String namePart)
Find the sibling with the given node name part.


findNode

protected net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode findNode(java.lang.String name)
Find the node with the given name.


removeChild

protected void removeChild(net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode parent,
                           net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode child)
Find the sibling with the given node name part.


addChildNode

protected void addChildNode(net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode parent,
                            net.sourceforge.groboutils.util.datastruct.v1.PathRegistry.TreeNode child)
                     throws PathAlreadyRegisteredException
Child must already be initialized correctly.

Throws:
PathAlreadyRegisteredException


Copyright © 2001-2003 by The GroboUtils Project