ist.palcom.hmap
Class HmapNode

java.lang.Object
  extended by ist.palcom.hmap.HmapNode
Direct Known Subclasses:
HmapDir, HmapLeaf

public abstract class HmapNode
extends Object

HmapNode is the abstract superclass for all hmap directories and leaves


Nested Class Summary
 class HmapNode.NameHandler
          The handler class for HmapNode names.
 
Field Summary
static int HET_DIR
           
static int HET_LEAF
           
static int HET_UNKNOWN
           
static String HMAPNODE_COMMAND_GETNAME
           
static String HMAPNODE_COMMAND_SETNAME
           
 NameInvokator nameInvokator
           
 NodeInvokator nodeInvokator
           
protected  HmapDir parent
          parent of the node
protected  HmapPath path
          Path of the node.
 ValueInvokator valueInvokator
           
 
Constructor Summary
protected HmapNode(int treeNodeType, String name, String typeName, String typeVersion, String typeFullyQualifiedName)
           
 
Method Summary
 void addHandler(Handler handler)
          Add a handler to this node
 void addInvokator(Invokator invocator)
          Add an invocator to this node
 void addListener(Listener listener)
          Add a listener to this node
 HmapDir asDir()
           
 HmapLeaf asLeaf()
           
 void callback(Listener listener, HmapPath path, String command, HmapNode parameters)
          Invokes a handler somewhere in the hmap --:: CAN ONLY BE CALLED FROM LISTENERS ASSOCIATED WITH THIS NODE!!!
 String getFullyQualifiedType()
           
 int getHmapEntryType()
           
 HmapKey getKey()
           
 String getName()
           
 HmapDir getParent()
           
 HmapPath getPath()
           
 String getType()
           
 String getTypeVersion()
           
protected  void handle(HmapEvent event)
          The actual handler invocation
 Iterator handlerIterator()
           
 boolean hasHandlers()
           
 boolean hasInvokators()
           
 boolean hasListeners()
           
 boolean hasName()
           
 boolean hasType()
           
 void invokation(Invokator invocator, HmapPath path, String command, HmapNode parameters)
          Invokes a handler somewhere in the hmap --:: CAN ONLY BE CALLED FROM INVOCATORS ASSOCIATED WITH THIS NODE!!!
 Iterator invokatorIterator()
           
protected abstract  void invokeHandlers(HmapEvent event)
          Resovles and invokes handlers specified in the event
protected  void invokeListeners(HmapEvent event)
          Triggers all listeners listening on this node with an event.
protected abstract  boolean isAncestorOf(HmapNode node)
          Returns true if this node is a direct ancestor of
 boolean isDir()
           
 boolean isLeaf()
           
 Iterator listenerIterator()
           
 String printHandlers(int indent)
           
 String printInvokators(int indent)
           
 String printListeners(int indent)
           
protected  void recalculatePath()
          Sets up a new path with this node as root
protected abstract  void recalculatePath(HmapPath parentPath)
          Recalculates the path on the basis of the path of ones ancestors
 void removeHandler(Handler handler)
          Remove a handler from this node
 void removeInvocator(Invokator invocator)
          Remove an invocator from this node
 void removeListener(Listener listener)
          Remove a listener from this node
 HmapNode resolve(HmapPath path)
           
abstract  HmapNode resolve(HmapPath path, int type)
          Resolves a node in the current h-map
 HmapNode resolve(String path)
           
 HmapDir resolveDir(HmapPath path)
           
 HmapDir resolveDir(String path)
           
 HmapDir resolveDirLocally(HmapKey key)
           
 HmapDir resolveDirLocally(String name)
           
 HmapLeaf resolveLeaf(HmapPath path)
           
 HmapLeaf resolveLeaf(String path)
           
 HmapLeaf resolveLeafLocally(HmapKey key)
           
 HmapLeaf resolveLeafLocally(String name)
           
 HmapNode resolveLocally(HmapKey key)
           
abstract  HmapNode resolveLocally(HmapKey key, int type)
          Resolves a child of the current node
 HmapNode resolveLocally(String name)
           
 void setName(HmapEvent event)
           
 void setName(String name)
          Sets the name of the node
 void setParent(HmapDir parent)
          Sets the parent of this node
abstract  String toString(int indent)
           
abstract  String toStringAll(int indent)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, println, toString
 

Field Detail

HMAPNODE_COMMAND_GETNAME

public static final String HMAPNODE_COMMAND_GETNAME
See Also:
Constant Field Values

HMAPNODE_COMMAND_SETNAME

public static final String HMAPNODE_COMMAND_SETNAME
See Also:
Constant Field Values

path

protected HmapPath path
Path of the node. Recalculated on moves


parent

protected HmapDir parent
parent of the node


HET_UNKNOWN

public static final int HET_UNKNOWN
See Also:
Constant Field Values

HET_DIR

public static final int HET_DIR
See Also:
Constant Field Values

HET_LEAF

public static final int HET_LEAF
See Also:
Constant Field Values

nameInvokator

public NameInvokator nameInvokator

valueInvokator

public ValueInvokator valueInvokator

nodeInvokator

public NodeInvokator nodeInvokator
Constructor Detail

HmapNode

protected HmapNode(int treeNodeType,
                   String name,
                   String typeName,
                   String typeVersion,
                   String typeFullyQualifiedName)
Parameters:
treeNodeType - the type of the treenode
name - the name of the treenode
Method Detail

getType

public String getType()

getFullyQualifiedType

public String getFullyQualifiedType()

getTypeVersion

public String getTypeVersion()

resolve

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

isDir

public boolean isDir()
Returns:
true if this node is a dir. False if not

isLeaf

public boolean isLeaf()
Returns:
true if this node is a leaf. False if not

hasName

public boolean hasName()
Returns:
True if the node has a name, false if not

hasType

public boolean hasType()
Returns:
True if the node has a type, false if not

asDir

public HmapDir asDir()
Returns:
this node as a dir - nul if it is not a dir

asLeaf

public HmapLeaf asLeaf()
Returns:
this node as a leaf - null if it is not a leaf

getPath

public HmapPath getPath()
Returns:
The path of this node (relative to its hmap root)

setName

public void setName(String name)
Sets the name of the node

Parameters:
name - new name

setName

public void setName(HmapEvent event)

getName

public String getName()
Returns:
the name of the node

getKey

public HmapKey getKey()
Returns:
The key for this hmap node

setParent

public void setParent(HmapDir parent)
Sets the parent of this node

Parameters:
parent - new parent

getParent

public HmapDir getParent()
Returns:
the parent dir of this node (which is null if it has none)

recalculatePath

protected void recalculatePath()
Sets up a new path with this node as root


invokation

public void invokation(Invokator invocator,
                       HmapPath path,
                       String command,
                       HmapNode parameters)
Invokes a handler somewhere in the hmap --:: CAN ONLY BE CALLED FROM INVOCATORS ASSOCIATED WITH THIS NODE!!! ::--

Parameters:
invocator - The invocator caller
path - The path on which to invoka the handler
command - The command to invoke the handler with
parameters - The parameters with which the handler is invoked

callback

public void callback(Listener listener,
                     HmapPath path,
                     String command,
                     HmapNode parameters)
Invokes a handler somewhere in the hmap --:: CAN ONLY BE CALLED FROM LISTENERS ASSOCIATED WITH THIS NODE!!! ::--

Parameters:
listener - The listener caller
path - The path on which to invoka the handler
command - The command to invoke the handler with
parameters - The parameters with which the handler is invoked

handle

protected void handle(HmapEvent event)
The actual handler invocation

Parameters:
event - The event to invoke the handlers with

resolveDir

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

resolveDir

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

resolveDirLocally

public HmapDir resolveDirLocally(HmapKey key)
Parameters:
key - the key of the dir to resolve
Returns:
The local dir with the given key. null if no such dir exists

resolveDirLocally

public HmapDir resolveDirLocally(String name)
Parameters:
name - the name of the dir to resolve
Returns:
The local dir with the given name. null if no such dir exists

resolveLeaf

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

resolveLeaf

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

resolveLeafLocally

public HmapLeaf resolveLeafLocally(HmapKey key)
Parameters:
key - the key of the leaf to resolve
Returns:
The first leaf at the given key. null if no such leaf exists

resolveLeafLocally

public HmapLeaf resolveLeafLocally(String name)
Parameters:
name - the name of the leaf to resolve
Returns:
The leaf at the given key. null if no such leaf exists

resolve

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

resolveLocally

public HmapNode resolveLocally(HmapKey key)
Parameters:
key - The key of the node to resolve
Returns:
The node coresponding to the key. Null if none is found

resolveLocally

public HmapNode resolveLocally(String name)
Parameters:
name - The name of the node to resolve
Returns:
The node coresponding to the key. Null if none is found

addHandler

public void addHandler(Handler handler)
Add a handler to this node

Parameters:
handler - The handler to be added

addInvokator

public void addInvokator(Invokator invocator)
Add an invocator to this node

Parameters:
invocator - The invocator to be added

addListener

public void addListener(Listener listener)
Add a listener to this node

Parameters:
listener - The listener to be added

removeHandler

public void removeHandler(Handler handler)
Remove a handler from this node

Parameters:
handler - The handler to remove

removeInvocator

public void removeInvocator(Invokator invocator)
Remove an invocator from this node

Parameters:
invocator - The invocator to remove

removeListener

public void removeListener(Listener listener)
Remove a listener from this node

Parameters:
listener - The listener to remove

handlerIterator

public Iterator handlerIterator()
Returns:
An iterator over the collection of handlers associated with this node

invokatorIterator

public Iterator invokatorIterator()
Returns:
An iterator over the collection of invocators associated with this node

listenerIterator

public Iterator listenerIterator()
Returns:
An iterator over the collection of listeners associated with this node

hasHandlers

public boolean hasHandlers()
Returns:
true if the node has any handlers. False if not

hasInvokators

public boolean hasInvokators()
Returns:
true if the node has any invokators. False if not

hasListeners

public boolean hasListeners()
Returns:
true if the node has any listeners. False if not

getHmapEntryType

public int getHmapEntryType()
Returns:
The Entry type of this node; Can be Dir, Leaf or Unknown

invokeListeners

protected void invokeListeners(HmapEvent event)
Triggers all listeners listening on this node with an event.

Parameters:
event -

printHandlers

public String printHandlers(int indent)
Parameters:
indent - prepend a number of whitespaces to the retured string
Returns:
a stringified version of this node's handlers

printInvokators

public String printInvokators(int indent)
Parameters:
indent - prepend a number of whitespaces to the retured string
Returns:
a stringified version of this node's invokators

printListeners

public String printListeners(int indent)
Parameters:
indent - prepend a number of whitespaces to the retured string
Returns:
a stringified version of this node's listeners

toString

public abstract String toString(int indent)
Parameters:
indent - prepend a number of whitespaces to the retured string
Returns:
a stringified version of this node

toStringAll

public abstract String toStringAll(int indent)
Parameters:
indent - prepend a number of whitespaces to the retured string
Returns:
a stringified version of this node with all handlers, invokators and listernes also

invokeHandlers

protected abstract void invokeHandlers(HmapEvent event)
Resovles and invokes handlers specified in the event

Parameters:
event - The event to invoke handlers with

isAncestorOf

protected abstract boolean isAncestorOf(HmapNode node)
Returns true if this node is a direct ancestor of

Parameters:
node - The potential (grand)child node

resolve

public abstract HmapNode resolve(HmapPath path,
                                 int type)
Resolves a node in the current h-map

Parameters:
path - the path of the node to resolve
type - the type of the given node. Can be leaf, dir and unknown
Returns:
The resolved node; null if none was resolved

resolveLocally

public abstract HmapNode resolveLocally(HmapKey key,
                                        int type)
Resolves a child of the current node

Parameters:
key - The key of the child
type - The type of the given node. Can be leaf, dir and unknown
Returns:
The resolved node; null if none was resolved

recalculatePath

protected abstract void recalculatePath(HmapPath parentPath)
Recalculates the path on the basis of the path of ones ancestors

Parameters:
parentPath - The path of ones parent