Class TransientDataAdaptor

java.lang.Object
xal.tools.data.TransientDataAdaptor
All Implemented Interfaces:
DataAdaptor

public class TransientDataAdaptor extends Object implements DataAdaptor
A volatile implementation of the DataAdaptor interface. TransientDataAdaptor is intended as a convenience class for passing data using the DataAdaptor interface. Note, however, class supports no persistence. Once an object of class TransientDataAdaptor is destroyed all internal data is lost.
Author:
Christopher K. Allen
  • Constructor Details

    • TransientDataAdaptor

      public TransientDataAdaptor(String strLabel)
      Create a new instance of VolatileDataAdaptor
      Parameters:
      strLabel - label for new data node
  • Method Details

    • name

      public String name()
      Get the label for this data node.
      Specified by:
      name in interface DataAdaptor
      Returns:
      name for the particular node in the data tree
    • attributes

      public String[] attributes()
      Get all the attribute names in the data node.
      Specified by:
      attributes in interface DataAdaptor
      Returns:
      array of all attributes names
    • hasAttribute

      public boolean hasAttribute(String strAttrName)
      Test whether or not an attribute is present in the data node.
      Specified by:
      hasAttribute in interface DataAdaptor
      Parameters:
      strAttrName - attribute name
      Returns:
      true if specified attribute is present, false otherwise
    • stringValue

      public String stringValue(String strAttrName)
      Get the value of an attribute.
      Specified by:
      stringValue in interface DataAdaptor
      Parameters:
      strAttrName - name of attribute
      Returns:
      value of attribute as boolean
    • booleanValue

      public boolean booleanValue(String strAttrName) throws NumberFormatException
      Get the value of an attribute.
      Specified by:
      booleanValue in interface DataAdaptor
      Parameters:
      strAttrName - name of attribute
      Returns:
      value of attribute as boolean
      Throws:
      NumberFormatException - unable to parse value as boolean
    • intValue

      public int intValue(String strAttrName)
      Get the value of an attribute.
      Specified by:
      intValue in interface DataAdaptor
      Parameters:
      strAttrName - name of attribute
      Returns:
      value of attribute as int
      Throws:
      NumberFormatException - unable to parse value as int
    • longValue

      public long longValue(String strAttrName)
      Get the value of an attribute.
      Specified by:
      longValue in interface DataAdaptor
      Parameters:
      strAttrName - name of attribute
      Returns:
      value of attribute as long
      Throws:
      NumberFormatException - unable to parse value as long
    • doubleValue

      public double doubleValue(String strAttrName)
      Get the value of an attribute.
      Specified by:
      doubleValue in interface DataAdaptor
      Parameters:
      strAttrName - name of attribute
      Returns:
      value of attribute as double
      Throws:
      NumberFormatException - unable to parse value as double
    • doubleArray

      public double[] doubleArray(String strAttr) throws NumberFormatException
      Returns the value of an attribute as an array of doubles. The attribute value must be stored as a string of comma separated values (CSVs). The values are parsed into doubles and packed into the returned array.
      Specified by:
      doubleArray in interface DataAdaptor
      Parameters:
      strAttr - the attribute name
      Returns:
      Array of double values as parsed from the value string. A null value is returned if the value string is empty.
      Throws:
      NumberFormatException - at least one value was malformed, or the CSV string was malformed
      Since:
      Mar 12, 2010
    • setValue

      public void setValue(String strAttrName, String strAttrVal)
      Set the value of the specified attribute as a string.
      Specified by:
      setValue in interface DataAdaptor
      Parameters:
      strAttrName - attribute name
      strAttrVal - attribute value
    • setValue

      public void setValue(String strAttrName, Object objAttrVal)
      Set the value of the specified attribute
      Specified by:
      setValue in interface DataAdaptor
      Parameters:
      strAttrName - attribute name
      objAttrVal - new attribute value
    • setValue

      public void setValue(String strAttrName, boolean bolAttrVal)
      Set the value of the specified attribute
      Specified by:
      setValue in interface DataAdaptor
      Parameters:
      strAttrName - attribute name
      bolAttrVal - new attribute value
    • setValue

      public void setValue(String strAttrName, int intAttrVal)
      Set the value of the specified attribute
      Specified by:
      setValue in interface DataAdaptor
      Parameters:
      strAttrName - attribute name
      intAttrVal - new attribute value
    • setValue

      public void setValue(String strAttrName, long longAttrVal)
      Set the value of the specified attribute
      Specified by:
      setValue in interface DataAdaptor
      Parameters:
      strAttrName - attribute name
      longAttrVal - new attribute value
    • setValue

      public void setValue(String strAttrName, double dblAttrVal)
      Set the value of the specified attribute
      Specified by:
      setValue in interface DataAdaptor
      Parameters:
      strAttrName - attribute name
      dblAttrVal - new attribute value
    • setValue

      public void setValue(String strAttr, double[] arrVal)
      Sets the attribute (name,value) pair for the given arguments. The value here is a double array which is stored as a string of comma separated values.
      Specified by:
      setValue in interface DataAdaptor
      Parameters:
      strAttr - attribute name
      arrVal - attribute value
      Since:
      Mar 11, 2010
      See Also:
    • nodeCount

      public int nodeCount()
      Get the number of child data nodes.
      Returns:
      number of child node adaptors
    • childAdaptor

      public DataAdaptor childAdaptor(String strLabel)
      Convenience method to get a single child adaptor when only one is expected.
      Specified by:
      childAdaptor in interface DataAdaptor
      Parameters:
      strLabel - data label of child node
      Returns:
      first child node with label strLabel, null if none exist
    • childAdaptors

      public List<DataAdaptor> childAdaptors()
      Get all the child data nodes of this adaptor.
      Specified by:
      childAdaptors in interface DataAdaptor
      Returns:
      all child adaptors
    • childAdaptors

      public List<DataAdaptor> childAdaptors(String strLabel)
      Get all the child data nodes of a particular data label.
      Specified by:
      childAdaptors in interface DataAdaptor
      Parameters:
      strLabel - data label for child nodes
      Returns:
      all child adaptors with specified label
    • childAdaptorIterator

      public Iterator<DataAdaptor> childAdaptorIterator()
      Get an iterator containing all child adaptors of this node.
      Returns:
      iterator of all child adaptors
    • childAdaptorIterator

      public Iterator<DataAdaptor> childAdaptorIterator(String strLabel)
      Get an iterator for all child data nodes having a given data label.
      Parameters:
      strLabel - data label for child nodes
      Returns:
      iterator of child adaptors with specified label
    • createChild

      public DataAdaptor createChild(String strLabel)
      Create a new empty child adaptor with the specified label.
      Specified by:
      createChild in interface DataAdaptor
      Parameters:
      strLabel - data label for the child node
      Returns:
      new child data node attached to this
    • removeChild

      public void removeChild(DataAdaptor adaptor)
      Description copied from interface: DataAdaptor
      Remove a child adaptor
      Specified by:
      removeChild in interface DataAdaptor
    • writeNode

      public void writeNode(DataListener ifcSrc)
      Write out the listener data as a new node then append it as a child node in the data tree.
      Specified by:
      writeNode in interface DataAdaptor
      Parameters:
      ifcSrc -
    • writeNodes

      public void writeNodes(Collection<? extends DataListener> colSrcs)
      write the collection of listeners to new nodes and append them to the data tree.
      Specified by:
      writeNodes in interface DataAdaptor
      Parameters:
      colSrcs - collection data sources exposing DataListener interface
    • print

      public void print(PrintStream os)
      Print out the contents of this adaptor.
      Parameters:
      os - output stream
      Since:
      Mar 12, 2010