gov.sns.tools.data
Interface DataAdaptor

All Known Implementing Classes:
TransientDataAdaptor, XmlDataAdaptor

public interface DataAdaptor

DataAdaptor is a generic interface to an external data source. A specific data adaptor (e.g. XmlDataAdaptor) will implement this interface to advertise its data in a generic way for reading and writing to a specific data source (e.g. XML file). DataAdaptor is intended to be a generic wrapper for specific data adaptors. Data adaptors do not have any knowledge about the objects that read and write data. Such data receivers and writers must implement the DataListener interface. A DataAdaptor instance is generated for each node in a hierarchical data tree and advertises information about the node and provides accessors to its children. Information about a node is in the form of attributes which represent key/value pairs of primitive data.


Method Summary
 java.lang.String[] attributes()
          return the array of all attributes
 boolean booleanValue(java.lang.String attribute)
          boolean value associated with the specified attribute
 DataAdaptor childAdaptor(java.lang.String label)
          Convenience method to get a single child adaptor when only one is expected
 java.util.Iterator childAdaptorIterator()
          return an iterator of all child adaptors
 java.util.Iterator childAdaptorIterator(java.lang.String label)
          return an iterator of all child adaptors of the specified name
 java.util.List childAdaptors()
          return all child adaptors
 java.util.List childAdaptors(java.lang.String label)
          return all child adaptors of the specified node name
 DataAdaptor createChild(java.lang.String label)
          Create an new empty child adaptor with label
 double doubleValue(java.lang.String attribute)
          double value associated with the specified attribute
 boolean hasAttribute(java.lang.String attribute)
          returns true iff the node has the specified attribute
 int intValue(java.lang.String attribute)
          integer value associated with the specified attribute
 long longValue(java.lang.String attribute)
          long value associated with the specified attribute
 java.lang.String name()
          name for the particular node in the data tree
 int nodeCount()
          return the number of child node adaptors
 void setValue(java.lang.String attribute, boolean value)
          set the value of the specified attribute to the specified value
 void setValue(java.lang.String attribute, double value)
          set the value of the specified attribute to the specified value
 void setValue(java.lang.String attribute, int value)
          set the value of the specified attribute to the specified value
 void setValue(java.lang.String attribute, long value)
          set the value of the specified attribute to the specified value
 void setValue(java.lang.String attribute, java.lang.Object value)
          set the value of the specified attribute to the specified value
 void setValue(java.lang.String attribute, java.lang.String value)
          set the value of the specified attribute to the specified value
 java.lang.String stringValue(java.lang.String attribute)
          string value associated with the specified attribute
 void writeNode(DataListener listener)
          write the listener as a new node and append it to the data tree
 void writeNodes(java.util.Collection listenerList)
          write the collection of listeners to new nodes and append them to the data tree.
 

Method Detail

name

public java.lang.String name()
name for the particular node in the data tree


hasAttribute

public boolean hasAttribute(java.lang.String attribute)
returns true iff the node has the specified attribute


stringValue

public java.lang.String stringValue(java.lang.String attribute)
string value associated with the specified attribute


doubleValue

public double doubleValue(java.lang.String attribute)
double value associated with the specified attribute


longValue

public long longValue(java.lang.String attribute)
long value associated with the specified attribute


intValue

public int intValue(java.lang.String attribute)
integer value associated with the specified attribute


booleanValue

public boolean booleanValue(java.lang.String attribute)
boolean value associated with the specified attribute


setValue

public void setValue(java.lang.String attribute,
                     java.lang.String value)
set the value of the specified attribute to the specified value


setValue

public void setValue(java.lang.String attribute,
                     double value)
set the value of the specified attribute to the specified value


setValue

public void setValue(java.lang.String attribute,
                     long value)
set the value of the specified attribute to the specified value


setValue

public void setValue(java.lang.String attribute,
                     int value)
set the value of the specified attribute to the specified value


setValue

public void setValue(java.lang.String attribute,
                     boolean value)
set the value of the specified attribute to the specified value


setValue

public void setValue(java.lang.String attribute,
                     java.lang.Object value)
set the value of the specified attribute to the specified value


attributes

public java.lang.String[] attributes()
return the array of all attributes


nodeCount

public int nodeCount()
return the number of child node adaptors


childAdaptors

public java.util.List childAdaptors()
return all child adaptors


childAdaptors

public java.util.List childAdaptors(java.lang.String label)
return all child adaptors of the specified node name


childAdaptorIterator

public java.util.Iterator childAdaptorIterator()
return an iterator of all child adaptors


childAdaptorIterator

public java.util.Iterator childAdaptorIterator(java.lang.String label)
return an iterator of all child adaptors of the specified name


childAdaptor

public DataAdaptor childAdaptor(java.lang.String label)
Convenience method to get a single child adaptor when only one is expected


createChild

public DataAdaptor createChild(java.lang.String label)
Create an new empty child adaptor with label


writeNode

public void writeNode(DataListener listener)
write the listener as a new node and append it to the data tree


writeNodes

public void writeNodes(java.util.Collection listenerList)
write the collection of listeners to new nodes and append them to the data tree.