ist.palcom.hmap
Class Leaf

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

public class Leaf
extends TreeNode

The leaf class of hmap trees. A leaf has a string name and a value of some type It has an extendable handle function for handling messages sent to the leaf through its hmap ancestors.


Field Summary
static String CMD_SETVALUE
           
 
Fields inherited from class ist.palcom.hmap.TreeNode
CMD_SETNAME, CMD_SETPARENT, listeners, name, parent, path, TET_DIR, TET_LEAF, TET_UNKNOWN
 
Constructor Summary
Leaf(String name, Object val)
           
 
Method Summary
 void computePath()
          Computes the absolute path of the leaf (relative to the hmap root)
 Object getValue()
          Gets the value of the leaf
 void handle(HmapEvent event)
           
 void invokeHandler(HmapEvent event)
          Invokes the handler function of the leaf
 void invokeHandler(String path, HmapEvent event)
          Invokes the handler function of the leaf
 boolean isAncestorOf(TreeNode node)
          Returns true if this node is a direct ancestor of
 void resetPath()
          Resets the path of the node.
 void setValue(Object val)
          Sets the value of the leaf
 String toString()
           
 String toString(int indent)
           
 
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_SETVALUE

public static final String CMD_SETVALUE
See Also:
Constant Field Values
Constructor Detail

Leaf

public Leaf(String name,
            Object val)
Parameters:
name - Name of the entry
val - Value contained by this entry
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)

setValue

public void setValue(Object val)
Sets the value of the leaf

Parameters:
val - The new value

getValue

public Object getValue()
Gets the value of the leaf

Returns:
The value

toString

public String toString()
Overrides:
toString in class Object
Returns:
A stringified version of the leaf

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 leaf

invokeHandler

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

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 of the leaf

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

resetPath

public void resetPath()
Description copied from class: TreeNode
Resets the path of the node. This is used when getting moved around

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