ncsa.hdf.object.h4
Class H4Datatype

java.lang.Object
  extended byncsa.hdf.object.HObject
      extended byncsa.hdf.object.Datatype
          extended byncsa.hdf.object.h4.H4Datatype
All Implemented Interfaces:
DataFormat, java.io.Serializable

public class H4Datatype
extends Datatype

Datatype encapsulates information of a datatype. Information includes the class, size, endian of a datatype.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class ncsa.hdf.object.Datatype
CLASS_ARRAY, CLASS_BITFIELD, CLASS_CHAR, CLASS_COMPOUND, CLASS_ENUM, CLASS_FLOAT, CLASS_INTEGER, CLASS_NO_CLASS, CLASS_OPAQUE, CLASS_REFERENCE, CLASS_STRING, CLASS_VLEN, datatypeClass, datatypeOrder, datatypeSign, datatypeSize, NATIVE, nativeID, NSGN, ORDER_BE, ORDER_LE, ORDER_NONE, ORDER_VAX, SIGN_2, SIGN_NONE
 
Fields inherited from class ncsa.hdf.object.HObject
hasAttribute, oid, separator
 
Constructor Summary
H4Datatype(int nativeID)
          Create a Datatype with a given HDF native datatype.
H4Datatype(int tclass, int tsize, int torder, int tsign)
          Create an Datatype with specified class, size, byte order and sign.
 
Method Summary
static java.lang.Object allocateArray(int datatype, int datasize)
          Allocate a 1D array large enough to hold a multidimensional array of 'datasize' elements of 'datatype' numbers.
 void fromNative(int tid)
          Specify this datatype with a given id of a user defined datatype.
 java.lang.String getDatatypeDescription()
          Returns a short text description of this datatype.
static java.lang.String getDatatypeDescription(int datatype)
          Returns the short description of a given datatype.
 boolean isUnsigned()
          Checks if this datatype is an unsigned integer.
static boolean isUnsigned(int datatype)
          Checks if the datatype is an unsigned integer.
 int toNative()
          Converts this datatype to a user defined datatype.
 
Methods inherited from class ncsa.hdf.object.Datatype
close, getDatatypeClass, getDatatypeOrder, getDatatypeSign, getDatatypeSize, getMetadata, open, removeMetadata, writeMetadata
 
Methods inherited from class ncsa.hdf.object.HObject
equalsOID, getFID, getFile, getFileFormat, getName, getOID, getPath, hasAttribute, setName, setPath, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

H4Datatype

public H4Datatype(int tclass,
                  int tsize,
                  int torder,
                  int tsign)
Create an Datatype with specified class, size, byte order and sign.

Parameters:
tclass - the class of the datatype.
tsize - the size of the datatype.
torder - the order of the datatype.
tsign - the sign of the datatype.

H4Datatype

public H4Datatype(int nativeID)
Create a Datatype with a given HDF native datatype.

Parameters:
nativeID - the hdf native datatype.
Method Detail

fromNative

public void fromNative(int tid)
Description copied from class: Datatype
Specify this datatype with a given id of a user defined datatype. Subclasses must implement it so that this datatype will be converted.

For example, if the type identifier is a 32-bit unsigned integer created from HDF5,

 int user_type = H5.J2C( HDF5CDataTypes.JH5T_NATIVE_UNINT32);
 Datatype dtype = new Datatype(user_type);
 
will construct a datatype equivalent to new Datatype(CLASS_INTEGER, 4, NATIVE, SIGN_NONE);

Specified by:
fromNative in class Datatype
Parameters:
tid - the identifier of user defined datatype.

allocateArray

public static final java.lang.Object allocateArray(int datatype,
                                                   int datasize)
                                            throws java.lang.OutOfMemoryError
Allocate a 1D array large enough to hold a multidimensional array of 'datasize' elements of 'datatype' numbers.

Parameters:
datatype - the data type
datasize - the size of the data array
Returns:
an array of 'datasize' numbers of datatype.
Throws:
java.lang.OutOfMemoryError

getDatatypeDescription

public java.lang.String getDatatypeDescription()
Description copied from class: Datatype
Returns a short text description of this datatype.

Overrides:
getDatatypeDescription in class Datatype

getDatatypeDescription

public static final java.lang.String getDatatypeDescription(int datatype)
Returns the short description of a given datatype.


isUnsigned

public boolean isUnsigned()
Description copied from class: Datatype
Checks if this datatype is an unsigned integer.

Specified by:
isUnsigned in class Datatype
Returns:
True is the datatype is an unsigned integer; otherwise returns false.

isUnsigned

public static final boolean isUnsigned(int datatype)
Checks if the datatype is an unsigned integer.

Parameters:
datatype - the data type.
Returns:
True is the datatype is an unsigned integer; otherwise returns false.

toNative

public int toNative()
Description copied from class: Datatype
Converts this datatype to a user defined datatype. Subclasses must implement it so that this datatype will be converted.

For example, a HDF5 datatype created from

 H5Dataype dtype = new H5Datatype(CLASS_INTEGER, 4, NATIVE, SIGN_NONE);
 int type = dtype.toNative();
 
here "type" will be the HDF5 datatype id of a 32-bit unsigned integer, which is equivalent to
 int type = H5.J2C( HDF5CDataTypes.JH5T_NATIVE_UNINT32);
 

Specified by:
toNative in class Datatype
Returns:
the identifier of the user defined datatype.