context.arch.comm
Class DataObject

java.lang.Object
  |
  +--context.arch.comm.DataObject

public class DataObject
extends java.lang.Object

This class implements the DataObject class. It stores the data used for sending messages between components.


Constructor Summary
DataObject()
          Basic constructor.
DataObject(java.lang.String name)
          Constructor that sets the name of the DataObject element
DataObject(java.lang.String name, java.util.Hashtable atts, java.util.Vector value)
          Constructor that sets the name of the DataObject element, a vector of values for the element, and a list of attributes
DataObject(java.lang.String name, java.lang.String value)
          Constructor that sets the name of the DataObject element and a single value for the element
DataObject(java.lang.String name, java.util.Vector value)
          Constructor that sets the name of the DataObject element and a vector of values for the element
 
Method Summary
 void addElement(java.lang.String name)
          This method adds an element to this DataObject
 void addElement(java.lang.String name, java.util.Hashtable atts)
          This method adds an element and list of attributes to this DataObject
 void addValue(java.lang.String value)
          Adds a value to the current element
 void closeElement(java.lang.String name)
          This method closes the currently open/added element in order to do some internal housecleaning.
 int countChildren()
          Counts the children of the current DataObject
 boolean existsElement(java.lang.String name)
          This method looks for an element in this DataObject.
 java.util.Hashtable getAttributes()
          Returns the list of attributes for the DataObject element
 java.util.Vector getChild(int i)
          Returns the specified child of the current DataObject
 java.util.Vector getChildren()
          Returns the children of the current DataObject
 DataObject getDataObject(java.lang.String string)
          Returns the DataObject element/sub-element with the specified name
 java.lang.Object getDataObjectFirstValue(java.lang.String string)
          Returns the first value of the DataObject element/sub-element with the specified name, if it exists.
 java.lang.String getName()
          Returns the name of the DataObject element
 DataObject getNthDataObject(java.lang.String string, int n)
          Returns the Nth DataObject element/sub-element with the specified name NB: we assume the current DataObject has 1 level of children.
 java.util.Vector getValue()
          Returns the values for the DataObject element
 void setAttributes(java.util.Hashtable atts)
          Sets the list of attributes for the DataObject element
 void setName(java.lang.String name)
          Sets the name of the DataObject element
 void setValue(java.lang.String value)
          Sets a value for the DataObject element
 void setValue(java.util.Vector value)
          Sets the values for the DataObject element
 java.lang.String toString()
          This method creates a string version of the recursive DataObject
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DataObject

public DataObject()
Basic constructor. Sets up necessary internal variables.

DataObject

public DataObject(java.lang.String name)
Constructor that sets the name of the DataObject element
Parameters:
name - Name of the DataObject element

DataObject

public DataObject(java.lang.String name,
                  java.lang.String value)
Constructor that sets the name of the DataObject element and a single value for the element
Parameters:
name - Name of the DataObject element
value - Value of the DataObject element

DataObject

public DataObject(java.lang.String name,
                  java.util.Vector value)
Constructor that sets the name of the DataObject element and a vector of values for the element
Parameters:
name - Name of the DataObject element
value - Vector of values for the DataObject element

DataObject

public DataObject(java.lang.String name,
                  java.util.Hashtable atts,
                  java.util.Vector value)
Constructor that sets the name of the DataObject element, a vector of values for the element, and a list of attributes
Parameters:
name - Name of the DataObject element
atts - Hashtable of attributes for the DataObject element
value - Vector of values for the DataObject element
Method Detail

getName

public java.lang.String getName()
Returns the name of the DataObject element
Returns:
Name of the DataObject element

getAttributes

public java.util.Hashtable getAttributes()
Returns the list of attributes for the DataObject element
Returns:
Hashtable of attributes for the DataObject element

getValue

public java.util.Vector getValue()
Returns the values for the DataObject element
Returns:
Vector of values for the DataObject element

setName

public void setName(java.lang.String name)
Sets the name of the DataObject element
Parameters:
name - Name of the DataObject element

setAttributes

public void setAttributes(java.util.Hashtable atts)
Sets the list of attributes for the DataObject element
Parameters:
atts - Hashtable of attributes for the DataObject element

setValue

public void setValue(java.lang.String value)
Sets a value for the DataObject element
Parameters:
value - Value for the DataObject element

setValue

public void setValue(java.util.Vector value)
Sets the values for the DataObject element
Parameters:
value - Vector of values for the DataObject element

countChildren

public int countChildren()
Counts the children of the current DataObject
Returns:
int the number of children

getChild

public java.util.Vector getChild(int i)
Returns the specified child of the current DataObject
Parameters:
int - Index of the child to return
Returns:
Vector the requested child

getChildren

public java.util.Vector getChildren()
Returns the children of the current DataObject
Returns:
Vector a vector containing the children

getDataObject

public DataObject getDataObject(java.lang.String string)
Returns the DataObject element/sub-element with the specified name
Parameters:
string - Name of the element to return
Returns:
DataObject with the specified name or null, if not found

getNthDataObject

public DataObject getNthDataObject(java.lang.String string,
                                   int n)
Returns the Nth DataObject element/sub-element with the specified name NB: we assume the current DataObject has 1 level of children. Thus, getNthDataObject (x, 1) is not equivalent to getDataObject (x) I'll fix this later. --DS
Parameters:
string - Name of the element to return
Returns:
DataObject with the specified name or null, if not found

existsElement

public boolean existsElement(java.lang.String name)
This method looks for an element in this DataObject.
Parameters:
name - Name of an element
Returns:
boolean true if there is an element by that name, else false

addElement

public void addElement(java.lang.String name)
This method adds an element to this DataObject
Parameters:
name - Name of an element

addElement

public void addElement(java.lang.String name,
                       java.util.Hashtable atts)
This method adds an element and list of attributes to this DataObject
Parameters:
name - Name of an element
atts - Hashtable list of attributes

closeElement

public void closeElement(java.lang.String name)
This method closes the currently open/added element in order to do some internal housecleaning.
Parameters:
name - Name of the element being closed

addValue

public void addValue(java.lang.String value)
Adds a value to the current element
Parameters:
value - Value being added to the current element

getDataObjectFirstValue

public java.lang.Object getDataObjectFirstValue(java.lang.String string)
Returns the first value of the DataObject element/sub-element with the specified name, if it exists. Returns null otherwise.
Parameters:
string - Name of the element to return
Returns:
1st value of the DataObject with the specified name or null, if not found

toString

public java.lang.String toString()
This method creates a string version of the recursive DataObject
Overrides:
toString in class java.lang.Object
Returns:
String version (printable) version of the DataObject