ncsa.hdf.object
Class Attribute

java.lang.Object
  extended byncsa.hdf.object.Attribute
All Implemented Interfaces:
Metadata, java.io.Serializable

public class Attribute
extends java.lang.Object
implements Metadata

An attribute is a (name, value) pair metadata that are attached to primary datasets and groups. The value field can be a scalar data point or an arrya of native datatype or compound data type.

The following is an example of how to create an attribute of one dimension integer array of size two.

 // Create an attribute
 String name = "data range";
 Datatype type = new Datatype(Datatype.CLASS_INTEGER, Datatype.NATIVE,
     Datatype.NATIVE, Datatype.NATIVE);
 long[] space = {2};
 int[] value = {0, 255};

 Attribute dataRange = new Attribute(name, type, space);
 dataRange.setValue(value);

 

See Also:
Datatype, Serialized Form

Field Summary
static int DEFAULT_STRING_ATTRIBUTE_LENGTH
          the default length of a string attribute
 
Constructor Summary
Attribute(java.lang.String attrName, Datatype attrType, long[] attrDims)
          Create an attribute with specified name, data type and dimension sizes.
 
Method Summary
 long[] getDataDims()
          Returns the dimension sizes of the data value of this attribute.
 java.lang.String getName()
          Returns the name of this attribute.
 int getRank()
          Returns the rank of the data value of this attribute.
 Datatype getType()
          Returns the datatype of the attribute.
 java.lang.Object getValue()
          Returns the value of this attriubte from file.
 boolean isUnsigned()
          Check the data type of the attribute is unsigned.
 void setValue(java.lang.Object theValue)
          Sets the value of this attribute.
 java.lang.String toString()
          Returns the string representation of this attribute.
 java.lang.String toString(java.lang.String delimiter)
          Returns the string representation of the value of this attribute.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_STRING_ATTRIBUTE_LENGTH

public static final int DEFAULT_STRING_ATTRIBUTE_LENGTH
the default length of a string attribute

See Also:
Constant Field Values
Constructor Detail

Attribute

public Attribute(java.lang.String attrName,
                 Datatype attrType,
                 long[] attrDims)
Create an attribute with specified name, data type and dimension sizes. For scalar attribute, the dimension size can either an array of size one or null. The rank can be either 1 or zero. Attribute is independent of dataformat, i.e., this implementation of attribute applies to both HDF4 and HDF5.

See Also:
Datatype
Method Detail

getValue

public java.lang.Object getValue()
Returns the value of this attriubte from file.

Specified by:
getValue in interface Metadata

setValue

public void setValue(java.lang.Object theValue)
Sets the value of this attribute.

Specified by:
setValue in interface Metadata

getName

public java.lang.String getName()
Returns the name of this attribute.


getRank

public int getRank()
Returns the rank of the data value of this attribute.


getDataDims

public long[] getDataDims()
Returns the dimension sizes of the data value of this attribute.


getType

public Datatype getType()
Returns the datatype of the attribute.


isUnsigned

public boolean isUnsigned()
Check the data type of the attribute is unsigned.


toString

public java.lang.String toString(java.lang.String delimiter)
Returns the string representation of the value of this attribute.

Parameters:
delimiter - the delimiter to separate individual data points.

toString

public java.lang.String toString()
Returns the string representation of this attribute. The String consists of the name and path of the data object.