gov.nasa.gsfc.drl.rtstps.core.output.hdf5
Class HDFAttribute

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.core.output.hdf5.HDFAttribute

public class HDFAttribute
extends java.lang.Object

Utility class for reading/writing HDF attributes


Constructor Summary
HDFAttribute()
           
 
Method Summary
static java.lang.Float readFloat(int dataSet, java.lang.String attribute)
          Read an HDF attribute float from the given data set.
static java.lang.String readString(int dataSet, java.lang.String attribute)
          Read an HDF attribute string from the given data set
static java.lang.String[] readStrings(int dataSet, java.lang.String attribute)
          Read an array of string attribute values to the named string attribute in the data set
static java.lang.Long readULong(int dataSet, java.lang.String attribute)
          Read an HDF attribute unsigned long (64-bits) from the given data set.
static long[] readULongs(int dataSet, java.lang.String attribute)
          Read an HDF attribute set of unsigned long (64-bits) values from the given data set.
static void writeFloat(int dataSet, java.lang.String name, float value)
          Write an HDF attribute float to the given data set.
static void writeString(int dataSet, java.lang.String name, java.lang.String value)
          Write a string attribute value to the named string attribute in the data set
static void writeStrings(int dataSet, java.lang.String name, java.lang.String[] values)
          Write an array of string attribute values to the named string attribute in the data set
static void writeULong(int dataSet, java.lang.String name, long value)
          Write to an HDF attribute unsigned long (64-bits) to the given data set.
static void writeULongs(int dataSet, java.lang.String name, long[] values)
          Write to an HDF attribute a set of unsigned long (64-bits) values to the given data set.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HDFAttribute

public HDFAttribute()
Method Detail

readString

public static java.lang.String readString(int dataSet,
                                          java.lang.String attribute)
                                   throws RtStpsException
Read an HDF attribute string from the given data set

Parameters:
dataSet - an descriptor to the open data set
attribute - the name of the attribute in question that should be in the data set
Returns:
a string containing the attribute's value
Throws:
RtStpsException - wraps any HDF library exception

writeString

public static void writeString(int dataSet,
                               java.lang.String name,
                               java.lang.String value)
                        throws RtStpsException
Write a string attribute value to the named string attribute in the data set

Parameters:
dataSet - a descriptor to the open data set
name - the name of the attribute in question that should be in the data set
value - the value of the attribute in question that should be in the data set
Throws:
RtStpsException - wraps any HDF library exception

writeStrings

public static void writeStrings(int dataSet,
                                java.lang.String name,
                                java.lang.String[] values)
                         throws RtStpsException
Write an array of string attribute values to the named string attribute in the data set

Parameters:
dataSet - a descriptor to the open data set
name - the name of the attribute in question that should be in the data set
values - an array of values of the attribute in question that should be in the data set
Throws:
RtStpsException

readStrings

public static java.lang.String[] readStrings(int dataSet,
                                             java.lang.String attribute)
                                      throws RtStpsException
Read an array of string attribute values to the named string attribute in the data set

Parameters:
dataSet - a descriptor to the open data set
attribute - the name of the attribute in question that should be in the data set
Returns:
an array of values of the attribute in question that should be in the data set
Throws:
RtStpsException

readULong

public static java.lang.Long readULong(int dataSet,
                                       java.lang.String attribute)
                                throws RtStpsException
Read an HDF attribute unsigned long (64-bits) from the given data set. The return data type is signed in Java. The user of this routine should either know that the information held in the attribute fits within the non-negative portion of the Java data type or know that the item will be treated for example like a timestamp where sub-fields are taken to convert to other values. If a full 64-bits is needed of unsigned values, then some other Java data type will have to returned (BigInteger?) to hold the value, and another method created in this utility class to support it.

Parameters:
dataSet - an descriptor to the open data set
attribute - the name of the attribute in question that should be in the data set
Returns:
a long containing the attribute's value
Throws:
RtStpsException - wraps any HDF library exception

writeULong

public static void writeULong(int dataSet,
                              java.lang.String name,
                              long value)
                       throws RtStpsException
Write to an HDF attribute unsigned long (64-bits) to the given data set. The input data type is signed in Java. However it is written to the H5T_NATIVE_ULLONG HDF data type.

Parameters:
dataSet - an descriptor to the open data set
name - the name of the attribute in question that should be in the data set
value - a long containing the attribute's value
Throws:
RtStpsException - wraps any HDF library exception

readULongs

public static long[] readULongs(int dataSet,
                                java.lang.String attribute)
                         throws RtStpsException
Read an HDF attribute set of unsigned long (64-bits) values from the given data set. The out data type is signed in Java. However it is reading as if from the H5T_STD_U64BE HDF data type. This contradicts the data-type in writeULong method above but seems to work.

Parameters:
dataSet - an descriptor to the open data set
attribute - the name of the attribute in question that should be in the data set
Returns:
a long array containing the attribute's value
Throws:
RtStpsException - wraps any HDF library exception

writeULongs

public static void writeULongs(int dataSet,
                               java.lang.String name,
                               long[] values)
                        throws RtStpsException
Write to an HDF attribute a set of unsigned long (64-bits) values to the given data set. The input data type is signed in Java. However it is written to the H5T_STD_U64BE HDF data type.

Parameters:
dataSet - an descriptor to the open data set
name - the name of the attribute in question that should be in the data set
values - an array of long containing the attribute's value
Throws:
RtStpsException - wraps any HDF library exception

readFloat

public static java.lang.Float readFloat(int dataSet,
                                        java.lang.String attribute)
                                 throws RtStpsException
Read an HDF attribute float from the given data set. The item is actually read as a an HDF H5T_NATIVE_ULLONG date type, and then byte converted to a Java float.

Parameters:
dataSet - an descriptor to the open data set
attribute - the name of the attribute in question that should be in the data set
Returns:
a float containing the attribute's value
Throws:
RtStpsException - wraps any HDF library exception

writeFloat

public static void writeFloat(int dataSet,
                              java.lang.String name,
                              float value)
                       throws RtStpsException
Write an HDF attribute float to the given data set. The item is actually written as a an HDF H5T_NATIVE_ULLONG date type.

Parameters:
dataSet - an descriptor to the open data set
name - the name of the attribute in question that should be in the data set
Throws:
RtStpsException - wraps any HDF library exception