ist.palcom.hgraph.manager
Class HgraphManager

java.lang.Object
  extended by ist.palcom.hgraph.manager.HgraphManager
All Implemented Interfaces:
IHgraphNode

public class HgraphManager
extends java.lang.Object
implements IHgraphNode

The HgraphManager provides a single point of entry to the whole Hgraph. It provides both a synchronous (via regular method invokation) as well as an (potentially) asynchronous (via Hgraph invokations) interface


Field Summary
protected  HgraphNode _node
          hgraph impl
static java.lang.String VAL_LIVEVIEWCLOCK
           
static java.lang.String VAL_LIVEVIEWINTERVAL
           
 
Fields inherited from interface ist.palcom.hgraph.IHgraphNode
CHILD_NAME_CLASH, CIRCULARITY_CLASH, COMMAND_OR_NODE_MISSING, ERROR, HANDLER_MISSING, INVOKATOR_MISSING, LISTENER_MISSING, NODE_NOT_CHILD, PATH_MISSING, SIBLING_ALREADY_EXISTS, SIBLING_NONEXISTENT, SIBLING_REFERENCE_ALREADY_EXISTS, SIBLING_REFERENCE_NONEXISTENT, STATUS_OK, VALUE_ALREADY_EXISTS, VALUE_NOT_PRESENT
 
Constructor Summary
HgraphManager(PalcomScheduler scheduler)
           
 
Method Summary
 int addNodeChild(IHgraphNode node, Path callerPath)
          Adds a child to the node's private list of children.
 boolean cd(java.lang.String path)
          Checks whether a given path exists
 java.lang.String dir(java.lang.String path)
          Returns the info for some given dir
 java.lang.String dirFull(java.lang.String path)
          Returns the full info for some given dir
 java.lang.String dirRecursively(java.lang.String path)
          Returns the recursive account of some given dir and its subdirs
 java.util.Iterator getChildIterator()
           
 FuncFunc getFuncFunc()
           
 ist.palcom.hgraph.manager.HgraphManager.LiveViewClock getLiveViewClock()
           
 int getLiveViewInterval()
           
 java.lang.String getNodeName()
          hgraph impl below
 IHgraphNode getNodeParent()
           
 Path getPath()
           
 SiblingFunc getSiblingFunc()
           
 ValueFunc getValueFunc()
           
 boolean hasChildNamed(java.lang.String name)
          Checks whether the node has a child with a given name
 boolean isAncestorOf(IHgraphNode node)
          Checks whether this node is an ancestor of the parameter node.
 int newNode(java.lang.String path, java.lang.String name)
          Creates a new node
 void queryEvent(HgraphEvent event)
          Callback function for use by HgraphManager QueryHandler.
 int removeNode(java.lang.String path, java.lang.String name)
          Removes a given node
 int removeNodeChild(java.lang.String name, Path callerPath)
          Removes a child based on its name.
 void returnEvent(HgraphEvent event)
          Callback function for use by HgraphManager ReturnHandler Used for either returning reposts to the original recipient through hgraphs or for returning regular blocking calls
 void setLiveView(Path whichPath, Path returnPath)
           
 void setLiveViewClock(ist.palcom.hgraph.manager.HgraphManager.LiveViewClock clock)
           
 void setLiveViewInterval(java.lang.String input)
           
 int setNodeName(java.lang.String name, Path callerPath)
          Sets the name of the node.
 int setNodeName(java.lang.String path, java.lang.String oldName, java.lang.String newName)
          Sets the name of a node
 int setNodeParent(IHgraphNode newParent, Path callerPath)
          Sets the parent of the HgraphNode.
 void stop()
           
 java.lang.String toXML()
           
 java.lang.String toXMLFull()
           
 java.lang.String toXMLFullRecursively()
           
 java.lang.String toXMLRecursively()
           
 void unsetLiveView(Path whichPath, Path returnPath)
           
 void updatePath()
          Updates the path of the H-Graph node along with its offspring recursively.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VAL_LIVEVIEWCLOCK

public static final java.lang.String VAL_LIVEVIEWCLOCK
See Also:
Constant Field Values

VAL_LIVEVIEWINTERVAL

public static final java.lang.String VAL_LIVEVIEWINTERVAL
See Also:
Constant Field Values

_node

protected HgraphNode _node
hgraph impl

Constructor Detail

HgraphManager

public HgraphManager(PalcomScheduler scheduler)
Method Detail

getLiveViewClock

public ist.palcom.hgraph.manager.HgraphManager.LiveViewClock getLiveViewClock()

setLiveViewClock

public void setLiveViewClock(ist.palcom.hgraph.manager.HgraphManager.LiveViewClock clock)

setLiveViewInterval

public void setLiveViewInterval(java.lang.String input)

getLiveViewInterval

public int getLiveViewInterval()

stop

public void stop()

cd

public boolean cd(java.lang.String path)
Checks whether a given path exists

Parameters:
path - the path
Returns:
true if it does, false if not.

setLiveView

public void setLiveView(Path whichPath,
                        Path returnPath)

unsetLiveView

public void unsetLiveView(Path whichPath,
                          Path returnPath)

dir

public java.lang.String dir(java.lang.String path)
Returns the info for some given dir

Parameters:
path - the path of the node to dir
Returns:
A string giving the dir

dirRecursively

public java.lang.String dirRecursively(java.lang.String path)
Returns the recursive account of some given dir and its subdirs

Parameters:
path - the path of the node to dir
Returns:
A string giving the recuesive account

dirFull

public java.lang.String dirFull(java.lang.String path)
Returns the full info for some given dir

Parameters:
path - the path of the node to dir
Returns:
A string giving the full dir

newNode

public int newNode(java.lang.String path,
                   java.lang.String name)
Creates a new node

Parameters:
path - the path on which to install the node
name - the name of the new node
Returns:
status indicating the status of the command

removeNode

public int removeNode(java.lang.String path,
                      java.lang.String name)
Removes a given node

Parameters:
path - parent the path of the node
name - the name of the node to be removed
Returns:
status indicating the status of the command

setNodeName

public int setNodeName(java.lang.String path,
                       java.lang.String oldName,
                       java.lang.String newName)
Sets the name of a node

Parameters:
path - The path of the node whose name is to be set
oldName - the old name
newName - the new name
Returns:
status indicating the status of the command

returnEvent

public void returnEvent(HgraphEvent event)
Callback function for use by HgraphManager ReturnHandler Used for either returning reposts to the original recipient through hgraphs or for returning regular blocking calls

Parameters:
event - The event holding the return information

queryEvent

public void queryEvent(HgraphEvent event)
Callback function for use by HgraphManager QueryHandler. Used for reposting hgraph queries onto the overall hgraph

Parameters:
event - The caught event holding reposting information

getNodeName

public java.lang.String getNodeName()
hgraph impl below

Specified by:
getNodeName in interface IHgraphNode
Returns:
The name of the node.

setNodeName

public int setNodeName(java.lang.String name,
                       Path callerPath)
Description copied from interface: IHgraphNode
Sets the name of the node. If a sibling already has the name, an error control message is returned

Specified by:
setNodeName in interface IHgraphNode
Parameters:
name - The new name
Returns:
IHgraphNode.STATUS_OK if the change succeeded. IHgraphNode.CHILD_NAME_CLASH if a sibling with the given name already exists.

getPath

public Path getPath()
Specified by:
getPath in interface IHgraphNode
Returns:
the Path object pertaining to the path of the node

updatePath

public void updatePath()
Description copied from interface: IHgraphNode
Updates the path of the H-Graph node along with its offspring recursively. The path is updated when the node name and the node parent is sat.

Specified by:
updatePath in interface IHgraphNode

hasChildNamed

public boolean hasChildNamed(java.lang.String name)
Description copied from interface: IHgraphNode
Checks whether the node has a child with a given name

Specified by:
hasChildNamed in interface IHgraphNode
Parameters:
name - The name to check
Returns:
True iff the node has an actual child with the given name. False if not.

isAncestorOf

public boolean isAncestorOf(IHgraphNode node)
Description copied from interface: IHgraphNode
Checks whether this node is an ancestor of the parameter node. It does so with a depth-first sharch of its offspring (children etc.)

Specified by:
isAncestorOf in interface IHgraphNode
Returns:
true if this node is an ancestor of the parameter node. false if not.

removeNodeChild

public int removeNodeChild(java.lang.String name,
                           Path callerPath)
Description copied from interface: IHgraphNode
Removes a child based on its name.

Specified by:
removeNodeChild in interface IHgraphNode
Parameters:
name - The name of the child to be removed
Returns:
IHgraphNode.STATUS_OK if the operation succeeds

toXML

public java.lang.String toXML()
Specified by:
toXML in interface IHgraphNode
Returns:
A simple xml'ified String of the node (type, name, path, children)

toXMLFull

public java.lang.String toXMLFull()
Specified by:
toXMLFull in interface IHgraphNode
Returns:
A complete xml'ified String of the node (same as simple + handlers, invokators, listeners, values)

toXMLRecursively

public java.lang.String toXMLRecursively()
Specified by:
toXMLRecursively in interface IHgraphNode
Returns:
A simple recursive xml'ified String of the node (type, name, path, children)

toXMLFullRecursively

public java.lang.String toXMLFullRecursively()
Specified by:
toXMLFullRecursively in interface IHgraphNode
Returns:
A complete recursive xml'ified String of the node (same as simple + handlers, invokators, listeners, values) HEAVY!!!

setNodeParent

public int setNodeParent(IHgraphNode newParent,
                         Path callerPath)
Description copied from interface: IHgraphNode
Sets the parent of the HgraphNode. This triggers a recalculation of the path of the node and its offspring

Specified by:
setNodeParent in interface IHgraphNode
Parameters:
newParent - the new parent
Returns:
IHgraphNode.STATUS_OK if the operation succeeds. IHgraphNode.CIRCULARITY_CLASH if the operation causes a circularity.

addNodeChild

public int addNodeChild(IHgraphNode node,
                        Path callerPath)
Description copied from interface: IHgraphNode
Adds a child to the node's private list of children. Ensures that names amongst children are unique

Specified by:
addNodeChild in interface IHgraphNode
Parameters:
node - The new child to be added
Returns:
IHgraphNode.STATUS_OK if the change succeeded. IHgraphNode.CHILD_NAME_CLASH if a sibling with the given name already exists.

getSiblingFunc

public SiblingFunc getSiblingFunc()
Specified by:
getSiblingFunc in interface IHgraphNode
Returns:
The SiblingFunc Sibling functionality object for the given node.

getValueFunc

public ValueFunc getValueFunc()
Specified by:
getValueFunc in interface IHgraphNode
Returns:
The ValueFunc Value functionality object for the given node.

getFuncFunc

public FuncFunc getFuncFunc()
Specified by:
getFuncFunc in interface IHgraphNode
Returns:
The FuncFunc functional functionality (ie. handlers, invokators and listeners) object for the given node.

getNodeParent

public IHgraphNode getNodeParent()
Specified by:
getNodeParent in interface IHgraphNode
Returns:
The parent of the node. null if the parent is root

getChildIterator

public java.util.Iterator getChildIterator()
Specified by:
getChildIterator in interface IHgraphNode
Returns:
An Iterator over the children of the node