jason.service.crusader.datastructure.graph
Class GraphNode

java.lang.Object
  |
  +--jason.service.crusader.datastructure.graph.GraphNode

public class GraphNode
extends java.lang.Object

This class is an limited implementation of a graph datastructure. This class represents a node in a data graph.
Author - Sanjay"Ironluca"Debnath Ironluca@yahoo.com
Last Modified - 2/07/2001


Field Summary
protected  java.util.Hashtable nodeAttributes
          Stores the ttributes of the node - mostly to be set by the server or not at all.
protected  java.util.Hashtable nodeList
          This variable stores the vertices or the traversal path from this node to child nodes if any.
protected  java.lang.String nodeName
          The name of a node - unique in it's context.
protected  java.util.Hashtable nodeProperties
          The parameters associated with a node.
 
Constructor Summary
GraphNode()
          No args default constructor.
GraphNode(java.lang.String nodeName)
          Parameterised constructor - initializes the name of this node to the name passed.
 
Method Summary
 void addNodeAttributeToTree(java.lang.String childNodeName, java.lang.String attributeName, java.lang.String attributeValue)
          This is a convenience method to add a nodeAttribute to one particular node in the tree.
 void addNodePropertyToTree(java.lang.String childNodeName, java.lang.String propertyName, java.lang.String propertyValue)
          This is a convenience method to add a nodeProperty to one particular node in the tree.
 GraphNode getChildFromTree(java.lang.String childNodeName, boolean create)
          This method retrieves a particular child node from the tree.
 GraphNode getChildNode(java.lang.String name)
          Returns the particular named child of this node if it exists or "null" if it does not.
 java.lang.Object getNodeAttribute(java.lang.String name)
          This method returns an named attribute of the node or "null" if one does not exist.
 java.util.Enumeration getNodeAttributeNames()
          Returns the names of the attributes of the node.
 java.lang.String getNodeName()
          Returns the unique name of the node in this context - NOTE - it does not return the fully qualified node name from the root.
 java.lang.String getNodeProperty(java.lang.String name)
          Retrieves a property of a node, if present as indicated by the property name or "null" if the named property does not exist.
 java.util.Enumeration getNodePropertyNames()
           
 GraphNode getParent()
          This method retrieves the parent of this node - if any or null.
 boolean hasChildNodes()
          Convenience method to check wether this node has children or not.
 boolean hasParent()
          Convenient method to check wether this node has a parent or not.
 void removeNodeAttribute(java.lang.String attributeName)
          Removes one particular attribute as indicated by the name
 GraphNode setChildNode(java.lang.String name, GraphNode childNode)
          Sets a new child node to this node.
 java.lang.String setNodeAttribute(java.lang.String name, java.lang.Object value)
          This method is responsible to set a particular attribute of the node.
 void setNodeName(java.lang.String nodeName)
          Changes the name of the node.
 java.lang.String setNodeProperty(java.lang.String name, java.lang.String value)
          This method is responsible to set a particular property of the node.
 GraphNode setParent(GraphNode parent)
          This method sets a new parent to this node.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodeName

protected java.lang.String nodeName
The name of a node - unique in it's context.


nodeAttributes

protected java.util.Hashtable nodeAttributes
Stores the ttributes of the node - mostly to be set by the server or not at all.


nodeProperties

protected java.util.Hashtable nodeProperties
The parameters associated with a node.


nodeList

protected java.util.Hashtable nodeList
This variable stores the vertices or the traversal path from this node to child nodes if any.

Constructor Detail

GraphNode

public GraphNode()
No args default constructor.


GraphNode

public GraphNode(java.lang.String nodeName)
Parameterised constructor - initializes the name of this node to the name passed.

Parameters:
nodeName - The name to which this node is to be set.
Method Detail

getNodeName

public java.lang.String getNodeName()
Returns the unique name of the node in this context - NOTE - it does not return the fully qualified node name from the root.

Returns:
java.lang.String The unique name of this node in the context, or "null" if one does not exist.

setNodeName

public void setNodeName(java.lang.String nodeName)
Changes the name of the node.

Parameters:
nodeName - The name to which the node has to be set.

getNodeProperty

public java.lang.String getNodeProperty(java.lang.String name)
Retrieves a property of a node, if present as indicated by the property name or "null" if the named property does not exist.

Parameters:
name - The name of the property to be retrieved.
Returns:
java.lang.String The value of the parameter as a String or "null" if one does not exist.

setNodeProperty

public java.lang.String setNodeProperty(java.lang.String name,
                                        java.lang.String value)
This method is responsible to set a particular property of the node.

Parameters:
name - The name of the parameter to be set.
value - The value of the parameter.
Returns:
java.lang.String The old value of the parameter if any - or "null".

getNodePropertyNames

public java.util.Enumeration getNodePropertyNames()

getNodeAttribute

public java.lang.Object getNodeAttribute(java.lang.String name)
This method returns an named attribute of the node or "null" if one does not exist.

Parameters:
name - The name of the attribute the node carries.
Returns:
java.lang.String The value of the attribute if it exists or "null".

setNodeAttribute

public java.lang.String setNodeAttribute(java.lang.String name,
                                         java.lang.Object value)
This method is responsible to set a particular attribute of the node.

Parameters:
name - The name of the attribute to be set.
value - The value of the attribute.
Returns:
java.lang.String The old value of the attribute if any - or "null".

getNodeAttributeNames

public java.util.Enumeration getNodeAttributeNames()
Returns the names of the attributes of the node.

Returns:
java.util.Enumeration The names of all the nodeAttributes as String.

removeNodeAttribute

public void removeNodeAttribute(java.lang.String attributeName)
Removes one particular attribute as indicated by the name

Parameters:
attributeName - The name of the attribute to be removed.

getChildNode

public GraphNode getChildNode(java.lang.String name)
Returns the particular named child of this node if it exists or "null" if it does not.

Parameters:
name - The name of the child node required.
Returns:
jason.service.crusader.datastructure.graph.GraphNode The child node if it exists or "null" if it does not.

setChildNode

public GraphNode setChildNode(java.lang.String name,
                              GraphNode childNode)
Sets a new child node to this node. If there exists a child with a specific name, it shall be replaced.

Parameters:
name - The name under which the child is to be stored.
childNode - The child node that is to be stored.
Returns:
The old child if one exists or "null" if there is none.

getParent

public GraphNode getParent()
This method retrieves the parent of this node - if any or null.

Returns:
jason.service.crusader.datastructure.GraphNode The parent node or "null".

setParent

public GraphNode setParent(GraphNode parent)
This method sets a new parent to this node.

Parameters:
parent - The new parent.
Returns:
jason.service.crusader.datastructure.graph.GraphNode The old parent if any or "null".

hasParent

public boolean hasParent()
Convenient method to check wether this node has a parent or not. Usually all the nodes will have parent except the root node.

Returns:
boolean If true, this node has a parent and is not the root node. If false, most likely that this node is the root node.

hasChildNodes

public boolean hasChildNodes()
Convenience method to check wether this node has children or not.


addNodePropertyToTree

public void addNodePropertyToTree(java.lang.String childNodeName,
                                  java.lang.String propertyName,
                                  java.lang.String propertyValue)
This is a convenience method to add a nodeProperty to one particular node in the tree.

Parameters:
childNodeName - The name of the child node to the existing evaluation node to which this nodeProperty is to be added.
propertyName - The name of the property.
propertyValue - The value of the property.

addNodeAttributeToTree

public void addNodeAttributeToTree(java.lang.String childNodeName,
                                   java.lang.String attributeName,
                                   java.lang.String attributeValue)
This is a convenience method to add a nodeAttribute to one particular node in the tree.

Parameters:
childNodeName - The name of the child node to the existing evaluation node to which this nodeProperty is to be added.
attributeName - The name of the attribute.
attributeValue - The value of the attribute.

getChildFromTree

public GraphNode getChildFromTree(java.lang.String childNodeName,
                                  boolean create)
This method retrieves a particular child node from the tree. The node evaluation is done with respect to the current node i.e. the node on which this method is called.

Parameters:
childNodeName - The name of the child node with respect to this node.
create - Creates the series of child nodes and appends them to the tree if "true" - otherwise not.
Returns:
jason.service.crusader.datastructure.graph.GraphNode The child node - if one exists or else "null"