Interface DataAdaptor

All Known Subinterfaces:
FileDataAdaptor
All Known Implementing Classes:
Hdf5DataAdaptor, InMemoryDataAdaptor, 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 sources and sinks. Data adaptors do not have any knowledge about the objects that read and write data. Such data receivers and writers should implement the DataListener interface (or the IArchive interface for model persistence).

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. The node also contains a text string which represents the data node "content".

The general structure of the data should be tree based, analogous to that of the XML DOM structure. Data is distributed by nodes in a tree, each node having a data label (see name()), attributes, and possibly some type of string content (see DataAdaptor#getContent() - currently unimplimented). There are potentially child data nodes of each node (see createChild(String) and childAdaptor(String)).

Any object that is able to read and write from DataAdaptor interfaces can implement the DataListener interface. The idea is that such an object should know, itself, how to load and save data from this interface, and expect to receive the appropriate DataAdaptor object for doing so. Finally, note that the update(DataAdaptor) and write(DataAdaptor) methods of the IDataAware interface expect IDataAdaptors in different positions on the data tree. This must be the case for proper logistical implementation. The update() method expects to be synchronized to the current data node while the write() method expects to be given the parent of the data node it is to populate. See the documentation for the DataListener interface for more information.
Author:
Tom Pelaia, Christopher K. Allen
  • Method Summary

    Modifier and Type
    Method
    Description
    return the array of all attributes
    boolean
    booleanValue(String attribute)
    boolean value associated with the specified attribute
    Convenience method to get a single child adaptor when only one is expected
    return all child adaptors
    return all child adaptors of the specified node name
    Create an new empty child adaptor with label
    double[]
    doubleArray(String attribute)
    Returns the value of an attribute as an array of doubles.
    double
    doubleValue(String attribute)
    double value associated with the specified attribute
    boolean
    hasAttribute(String attribute)
    returns true if the node has the specified attribute
    int
    intValue(String attribute)
    integer value associated with the specified attribute
    long
    longValue(String attribute)
    long value associated with the specified attribute
    name for the particular node in the data tree
    void
    Remove a child adaptor
    void
    setValue(String attribute, boolean value)
    set the value of the specified attribute to the specified value
    void
    setValue(String attribute, double value)
    set the value of the specified attribute to the specified value
    void
    setValue(String attribute, double[] array)
    Stores the value of the given double[] object in the data adaptor backing store.
    void
    setValue(String attribute, int value)
    set the value of the specified attribute to the specified value
    void
    setValue(String attribute, long value)
    set the value of the specified attribute to the specified value
    void
    setValue(String attribute, Object value)
    set the value of the specified attribute to the specified value
    void
    setValue(String attribute, String value)
    set the value of the specified attribute to the specified value
    stringValue(String attribute)
    string value associated with the specified attribute
    void
    write the listener as a new node and append it to the data tree
    void
    Write the collection of listeners to new nodes and append them to the data tree.
  • Method Details

    • name

      String name()
      name for the particular node in the data tree
    • hasAttribute

      boolean hasAttribute(String attribute)
      returns true if the node has the specified attribute
    • stringValue

      String stringValue(String attribute)
      string value associated with the specified attribute
    • doubleValue

      double doubleValue(String attribute)
      double value associated with the specified attribute
    • longValue

      long longValue(String attribute)
      long value associated with the specified attribute
    • intValue

      int intValue(String attribute)
      integer value associated with the specified attribute
    • booleanValue

      boolean booleanValue(String attribute)
      boolean value associated with the specified attribute
    • doubleArray

      double[] doubleArray(String attribute)
      Returns the value of an attribute as an array of doubles.
      Parameters:
      attribute - the attribute name
      Returns:
      Array of double values, a null value is returned if the value string is empty.
    • setValue

      void setValue(String attribute, String value)
      set the value of the specified attribute to the specified value
    • setValue

      void setValue(String attribute, double value)
      set the value of the specified attribute to the specified value
    • setValue

      void setValue(String attribute, long value)
      set the value of the specified attribute to the specified value
    • setValue

      void setValue(String attribute, int value)
      set the value of the specified attribute to the specified value
    • setValue

      void setValue(String attribute, boolean value)
      set the value of the specified attribute to the specified value
    • setValue

      void setValue(String attribute, Object value)
      set the value of the specified attribute to the specified value
    • setValue

      void setValue(String attribute, double[] array)
      Stores the value of the given double[] object in the data adaptor backing store.
      Parameters:
      attribute - attribute name
      array - attribute value
    • attributes

      String[] attributes()
      return the array of all attributes
    • childAdaptors

      List<DataAdaptor> childAdaptors()
      return all child adaptors
    • childAdaptors

      List<DataAdaptor> childAdaptors(String label)
      return all child adaptors of the specified node name
    • childAdaptor

      DataAdaptor childAdaptor(String label)
      Convenience method to get a single child adaptor when only one is expected
    • createChild

      DataAdaptor createChild(String label)
      Create an new empty child adaptor with label
    • removeChild

      void removeChild(DataAdaptor adaptor)
      Remove a child adaptor
    • writeNode

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

      void writeNodes(Collection<? extends DataListener> nodes)
      Write the collection of listeners to new nodes and append them to the data tree.
      Parameters:
      nodes - the nodes to write