Class Hdf5DataAdaptor

java.lang.Object
xal.tools.hdf5.Hdf5DataAdaptor
All Implemented Interfaces:
DataAdaptor, FileDataAdaptor

public class Hdf5DataAdaptor extends Object implements FileDataAdaptor
This class creates an HDF5 structure in memory before writing to a file, since the HDF5 library only supports directly writing to a file.
Author:
Juan F. Esteban Müller <JuanF.EstebanMuller@esss.se>
  • Method Details

    • name

      public String name()
      get the tag name for the main node
      Specified by:
      name in interface DataAdaptor
      Returns:
    • hasAttribute

      public boolean hasAttribute(String attribute)
      check whether the main node has the specified attribute
      Specified by:
      hasAttribute in interface DataAdaptor
      Parameters:
      attribute - Name of the attribute to find.
      Returns:
      Boolean specifying if the attribute exists.
    • stringValue

      public String stringValue(String attributeName)
      Description copied from interface: DataAdaptor
      string value associated with the specified attribute
      Specified by:
      stringValue in interface DataAdaptor
    • doubleValue

      public double doubleValue(String attributeName)
      Description copied from interface: DataAdaptor
      double value associated with the specified attribute
      Specified by:
      doubleValue in interface DataAdaptor
    • longValue

      public long longValue(String attributeName)
      Description copied from interface: DataAdaptor
      long value associated with the specified attribute
      Specified by:
      longValue in interface DataAdaptor
    • intValue

      public int intValue(String attributeName)
      Description copied from interface: DataAdaptor
      integer value associated with the specified attribute
      Specified by:
      intValue in interface DataAdaptor
    • booleanValue

      public boolean booleanValue(String attributeName)
      Description copied from interface: DataAdaptor
      boolean value associated with the specified attribute
      Specified by:
      booleanValue in interface DataAdaptor
    • doubleArray

      public double[] doubleArray(String attributeName)
      Description copied from interface: DataAdaptor
      Returns the value of an attribute as an array of doubles.
      Specified by:
      doubleArray in interface DataAdaptor
      Parameters:
      attributeName - the attribute name
      Returns:
      Array of double values, a null value is returned if the value string is empty.
    • setValue

      public void setValue(String attributeName, String value)
      Description copied from interface: DataAdaptor
      set the value of the specified attribute to the specified value
      Specified by:
      setValue in interface DataAdaptor
    • setValue

      public void setValue(String attributeName, double value)
      Description copied from interface: DataAdaptor
      set the value of the specified attribute to the specified value
      Specified by:
      setValue in interface DataAdaptor
    • setValue

      public void setValue(String attributeName, long value)
      Description copied from interface: DataAdaptor
      set the value of the specified attribute to the specified value
      Specified by:
      setValue in interface DataAdaptor
    • setValue

      public void setValue(String attributeName, int value)
      Description copied from interface: DataAdaptor
      set the value of the specified attribute to the specified value
      Specified by:
      setValue in interface DataAdaptor
    • setValue

      public void setValue(String attributeName, boolean value)
      Description copied from interface: DataAdaptor
      set the value of the specified attribute to the specified value
      Specified by:
      setValue in interface DataAdaptor
    • setValue

      public void setValue(String attributeName, Object value)
      Description copied from interface: DataAdaptor
      set the value of the specified attribute to the specified value
      Specified by:
      setValue in interface DataAdaptor
    • setValue

      public void setValue(String attributeName, double[] array)
      Description copied from interface: DataAdaptor
      Stores the value of the given double[] object in the data adaptor backing store.
      Specified by:
      setValue in interface DataAdaptor
      Parameters:
      attributeName - attribute name
      array - attribute value
    • attributes

      public String[] attributes()
      Description copied from interface: DataAdaptor
      return the array of all attributes
      Specified by:
      attributes in interface DataAdaptor
    • childAdaptors

      public List<DataAdaptor> childAdaptors()
      Description copied from interface: DataAdaptor
      return all child adaptors
      Specified by:
      childAdaptors in interface DataAdaptor
    • childAdaptors

      public List<DataAdaptor> childAdaptors(String label)
      Create a list of child adaptors (one adaptor for each non-null child node whose tag name is equal to the specified label).
      Specified by:
      childAdaptors in interface DataAdaptor
      Parameters:
      label - the label for which to match the node's tag
      Returns:
      a list of child adaptors
    • childAdaptor

      public DataAdaptor childAdaptor(String label)
      Description copied from interface: DataAdaptor
      Convenience method to get a single child adaptor when only one is expected
      Specified by:
      childAdaptor in interface DataAdaptor
    • createChild

      public DataAdaptor createChild(String tagName)
      Description copied from interface: DataAdaptor
      Create an new empty child adaptor with label
      Specified by:
      createChild in interface DataAdaptor
    • 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 listener)
      Description copied from interface: DataAdaptor
      write the listener as a new node and append it to the data tree
      Specified by:
      writeNode in interface DataAdaptor
    • writeNodes

      public void writeNodes(Collection<? extends DataListener> nodes)
      Description copied from interface: DataAdaptor
      Write the collection of listeners to new nodes and append them to the data tree.
      Specified by:
      writeNodes in interface DataAdaptor
      Parameters:
      nodes - the nodes to write
    • writeTo

      public void writeTo(File file) throws IOException
      Description copied from interface: FileDataAdaptor
      Convenience method for writing a DataAdaptor to a file
      Specified by:
      writeTo in interface FileDataAdaptor
      Throws:
      IOException
    • writeToUrl

      public void writeToUrl(URL url) throws IOException
      Description copied from interface: FileDataAdaptor
      Write DataAdaptor to the specified url
      Specified by:
      writeToUrl in interface FileDataAdaptor
      Throws:
      IOException
    • writeToUrlSpec

      public void writeToUrlSpec(String urlSpec) throws IOException
      Description copied from interface: FileDataAdaptor
      Write DataAdaptor to the specified url
      Specified by:
      writeToUrlSpec in interface FileDataAdaptor
      Throws:
      IOException
    • adaptorForUrl

      public static Hdf5DataAdaptor adaptorForUrl(String urlPath)
      Generate an Hdf5DataAdaptor from a urlPath.
    • adaptorForUrl

      public static Hdf5DataAdaptor adaptorForUrl(URL url)
      Generate an Hdf5DataAdaptor from a URL.
    • adaptorForFile

      public static Hdf5DataAdaptor adaptorForFile(File file) throws MalformedURLException
      Generate an Hdf5DataAdaptor from a File.
      Throws:
      MalformedURLException
    • newEmptyDocumentAdaptor

      public static Hdf5DataAdaptor newEmptyDocumentAdaptor()
      Create an empty HDF5 document
      Returns:
      DataAdaptor containing the root document node.