things.data.impl
Class NamedTree

java.lang.Object
  extended by things.data.impl.NamedTree

public class NamedTree
extends java.lang.Object

A named tree implementation. This is NOT indexed and thus should not be used in anything needing speed. However, the tree can be trimmed, pruned, spliced, and diced at your whim and whenever. It assumes that the values are immutable!

Version:
1.0

Version History

EPG - Initial - 6 SEP 02
 
Author:
Erich P. Gatejen

Constructor Summary
NamedTree()
          CONSTRUCTOR
 
Method Summary
 java.lang.Object get(java.lang.String path)
          Get the value at the path
 NamedTree mirror(java.lang.String path)
          Mirror the tree to a new tree
 void remove(java.lang.String path)
          It will remove everything at and beyond the named path.
 boolean set(java.lang.String path, java.lang.Object value)
          Set the value of a path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NamedTree

public NamedTree()
CONSTRUCTOR

Method Detail

set

public boolean set(java.lang.String path,
                   java.lang.Object value)
Set the value of a path. If the value already exists, it will be changed. It will automatically fill in nodes to make the tree whole. If it fails, it will do so quietly, but return false.

Parameters:
path - in dot notation (level1.level2.terminal)
value - as an Object
Returns:
true is successful, otherwise false

remove

public void remove(java.lang.String path)
It will remove everything at and beyond the named path. It will never fail. If the path doesn't exist, it will simple exit.

Parameters:
path - in dot notation (level1.level2.terminal)

get

public java.lang.Object get(java.lang.String path)
Get the value at the path

Parameters:
path - in dot notation (level1.level2.terminal)
Returns:
the value as an Object

mirror

public NamedTree mirror(java.lang.String path)
Mirror the tree to a new tree

Parameters:
path - root in dot notation (level1.level2.terminal)
Returns:
a new tree or an empty tree if the path has no nodes


Things.