ist.palcom.hmap
Class Dir

java.lang.Object
  extended by ist.palcom.hmap.TreeNode
      extended by ist.palcom.hmap.Dir
All Implemented Interfaces:
Handler

public class Dir
extends TreeNode

The dir class of hmap trees. A dir has a string name and a collection of children It has an extendable handle function for handling messages sent to the dir through its hmap ancestors and the outside.


Field Summary
static String CMD_ADDENTRY
           
static String CMD_REMOVEENTRY
           
protected  Collection entries
          Collection of entries contained by this h-map dir.
 
Fields inherited from class ist.palcom.hmap.TreeNode
CMD_SETNAME, CMD_SETPARENT, listeners, name, parent, path, TET_DIR, TET_LEAF, TET_UNKNOWN
 
Constructor Summary
Dir(String name)
           
 
Method Summary
 void addEntry(TreeNode node)
          Adds a hmap node to this dir
 void computePath()
          Computes the absolute path of the leaf (relative to the hmap root)
 void handle(HmapEvent event)
           
 void invokeHandler(HmapEvent event)
          Invokes the handler function of the dir
 void invokeHandler(String path, HmapEvent event)
          Invokes the handler function at a given path
 boolean isAncestorOf(TreeNode node)
          Returns true if this node is a direct ancestor of
 Iterator iterator()
           
 boolean remove(String path)
          Removes the first found node at a given path
 void removeEntry(TreeNode node)
          Removes a node from this dir
 boolean removeEntryByName(String name)
          Removes the first found child node of this dir named
 void resetPath()
          Resets the path recursively
 TreeNode resolve(String path)
           
 Dir resolveDir(String path)
           
 Leaf resolveLeaf(String path)
           
 String toString()
           
 String toString(int indent)
           
 String toStringFlat()
           
 
Methods inherited from class ist.palcom.hmap.TreeNode
addListener, asDir, asLeaf, firstOfPath, getName, getParent, getPath, invokeListeners, isDir, isLeaf, printListeners, printListeners, removeListener, restOfPath, setName, setParent
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, println
 

Field Detail

CMD_ADDENTRY

public static final String CMD_ADDENTRY
See Also:
Constant Field Values

CMD_REMOVEENTRY

public static final String CMD_REMOVEENTRY
See Also:
Constant Field Values

entries

protected Collection entries
Collection of entries contained by this h-map dir.

Constructor Detail

Dir

public Dir(String name)
Parameters:
name - The name of the directory
Method Detail

computePath

public void computePath()
Computes the absolute path of the leaf (relative to the hmap root)

Specified by:
computePath in class TreeNode

handle

public void handle(HmapEvent event)

invokeHandler

public void invokeHandler(HmapEvent event)
Invokes the handler function of the dir

Specified by:
invokeHandler in class TreeNode
Parameters:
event - The payload to invoke the handler with

invokeHandler

public void invokeHandler(String path,
                          HmapEvent event)
Invokes the handler function at a given path

Specified by:
invokeHandler in class TreeNode
Parameters:
event - The payload to invoke the handler with
path - The path on which to invoke the handler

resolveDir

public Dir resolveDir(String path)
Parameters:
path - the path to resolve
Returns:
The first dir at the given path. null if no such dir exists

resolveLeaf

public Leaf resolveLeaf(String path)
Parameters:
path - the path to resolve
Returns:
The first leaf at the given path. null if no such leaf exists

resolve

public TreeNode resolve(String path)
Parameters:
path - the path to resolve
Returns:
The first node at the given path. null if no such node exists

addEntry

public void addEntry(TreeNode node)
Adds a hmap node to this dir

Parameters:
node - The entry to add

removeEntry

public void removeEntry(TreeNode node)
Removes a node from this dir

Parameters:
node - The entry to remove

removeEntryByName

public boolean removeEntryByName(String name)
Removes the first found child node of this dir named

Parameters:
name - The name of the child node to remove
Returns:
True if a node has been removed. False if no node named was found

remove

public boolean remove(String path)
Removes the first found node at a given path

Parameters:
path - The path of the node to be removed
Returns:
True if a node was found and removed. False if not

iterator

public Iterator iterator()
Returns:
The iterator of the internal datastructure holding the child entries

toString

public String toString()
Overrides:
toString in class Object
Returns:
A stringified version of the dir and its children

toStringFlat

public String toStringFlat()
Returns:
A stringified version of the dir

toString

public String toString(int indent)
Specified by:
toString in class TreeNode
Parameters:
indent - Start the returned string with a number of whitespaces
Returns:
A stringified version of the dir and its children

resetPath

public void resetPath()
Resets the path recursively

Specified by:
resetPath in class TreeNode

isAncestorOf

public boolean isAncestorOf(TreeNode node)
Description copied from class: TreeNode
Returns true if this node is a direct ancestor of

Specified by:
isAncestorOf in class TreeNode
Parameters:
node - The potential (grand)child node