ncsa.hdf.object
Class Datatype

java.lang.Object
  extended byncsa.hdf.object.HObject
      extended byncsa.hdf.object.Datatype
All Implemented Interfaces:
DataFormat, java.io.Serializable
Direct Known Subclasses:
H4Datatype, H5Datatype

public abstract class Datatype
extends HObject

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

See Also:
Serialized Form

Field Summary
static int CLASS_ARRAY
           
static int CLASS_BITFIELD
           
static int CLASS_CHAR
           
static int CLASS_COMPOUND
           
static int CLASS_ENUM
           
static int CLASS_FLOAT
           
static int CLASS_INTEGER
           
static int CLASS_NO_CLASS
           
static int CLASS_OPAQUE
           
static int CLASS_REFERENCE
           
static int CLASS_STRING
           
static int CLASS_VLEN
           
protected  int datatypeClass
          The class of the datatype.
protected  int datatypeOrder
          The byte order of the datatype.
protected  int datatypeSign
          The sign of the datatype.
protected  int datatypeSize
          The size (in bytes) of the datatype.
static int NATIVE
           
protected  int nativeID
          Datatype identifier of the implementing class of this datatype.
static int NSGN
           
static int ORDER_BE
           
static int ORDER_LE
           
static int ORDER_NONE
           
static int ORDER_VAX
           
static int SIGN_2
           
static int SIGN_NONE
           
 
Fields inherited from class ncsa.hdf.object.HObject
hasAttribute, oid, separator
 
Constructor Summary
Datatype(FileFormat fileFormat, java.lang.String name, java.lang.String path, long[] oid)
           
Datatype(int type)
          Create a Datatype with a given identifier of user defined datatype.
Datatype(int tclass, int tsize, int torder, int tsign)
          Create an Datatype with specified class, size, byte order and sign.
 
Method Summary
 void close(int id)
          Closes access to this object.
abstract  void fromNative(int nativeID)
          Specify this datatype with a given id of a user defined datatype.
 int getDatatypeClass()
          Returns the class of the datatype.
 java.lang.String getDatatypeDescription()
          Returns a short text description of this datatype.
 int getDatatypeOrder()
          Returns the Order of the datatype.
 int getDatatypeSign()
          Returns the sign of the datatype.
 int getDatatypeSize()
          Returns the size of the datatype.
 java.util.List getMetadata()
          Loads the metadata such as attributes and type of the the data object into memory if the metadata is not loaded.
abstract  boolean isUnsigned()
          Checks if this datatype is an unsigned integer.
 int open()
          Opens access to this object.
 void removeMetadata(java.lang.Object info)
          Deletes an existing metadata from this data object.
abstract  int toNative()
          Converts this datatype to a user defined datatype.
 void writeMetadata(java.lang.Object info)
          Saves a specific metadata into file.
 
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
 

Field Detail

NATIVE

public static final int NATIVE
See Also:
Constant Field Values

CLASS_NO_CLASS

public static final int CLASS_NO_CLASS
See Also:
Constant Field Values

CLASS_INTEGER

public static final int CLASS_INTEGER
See Also:
Constant Field Values

CLASS_FLOAT

public static final int CLASS_FLOAT
See Also:
Constant Field Values

CLASS_CHAR

public static final int CLASS_CHAR
See Also:
Constant Field Values

CLASS_STRING

public static final int CLASS_STRING
See Also:
Constant Field Values

CLASS_BITFIELD

public static final int CLASS_BITFIELD
See Also:
Constant Field Values

CLASS_OPAQUE

public static final int CLASS_OPAQUE
See Also:
Constant Field Values

CLASS_COMPOUND

public static final int CLASS_COMPOUND
See Also:
Constant Field Values

CLASS_REFERENCE

public static final int CLASS_REFERENCE
See Also:
Constant Field Values

CLASS_ENUM

public static final int CLASS_ENUM
See Also:
Constant Field Values

CLASS_VLEN

public static final int CLASS_VLEN
See Also:
Constant Field Values

CLASS_ARRAY

public static final int CLASS_ARRAY
See Also:
Constant Field Values

ORDER_LE

public static final int ORDER_LE
See Also:
Constant Field Values

ORDER_BE

public static final int ORDER_BE
See Also:
Constant Field Values

ORDER_VAX

public static final int ORDER_VAX
See Also:
Constant Field Values

ORDER_NONE

public static final int ORDER_NONE
See Also:
Constant Field Values

SIGN_NONE

public static final int SIGN_NONE
See Also:
Constant Field Values

SIGN_2

public static final int SIGN_2
See Also:
Constant Field Values

NSGN

public static final int NSGN
See Also:
Constant Field Values

datatypeClass

protected int datatypeClass
The class of the datatype.


datatypeSize

protected int datatypeSize
The size (in bytes) of the datatype.


datatypeOrder

protected int datatypeOrder
The byte order of the datatype.


datatypeSign

protected int datatypeSign
The sign of the datatype.


nativeID

protected int nativeID
Datatype identifier of the implementing class of this datatype.

Constructor Detail

Datatype

public Datatype(FileFormat fileFormat,
                java.lang.String name,
                java.lang.String path,
                long[] oid)

Datatype

public Datatype(int tclass,
                int tsize,
                int torder,
                int tsign)
Create an Datatype with specified class, size, byte order and sign. The following list a few example of how to create a Datatype.
  1. to create unsigned native integer
    Datatype type = new Dataype(CLASS_INTEGER, NATIVE, NATIVE, SIGN_NONE);
  2. to create 16-bit signed integer with big endian
    Datatype type = new Dataype(CLASS_INTEGER, 2, ORDER_BE, NATIVE);
  3. to create native float
    Datatype type = new Dataype(CLASS_FLOAT, NATIVE, NATIVE, -1);
  4. to create 64-bit double
    Datatype type = new Dataype(CLASS_FLOAT, 8, NATIVE, -1);

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

Datatype

public Datatype(int type)
Create a Datatype with a given identifier of user defined datatype. 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);

Parameters:
type - the identifier of user defined datatype.
See Also:
fromNative(int nativeID)
Method Detail

getDatatypeClass

public int getDatatypeClass()
Returns the class of the datatype.


getDatatypeSize

public int getDatatypeSize()
Returns the size of the datatype.


getDatatypeOrder

public int getDatatypeOrder()
Returns the Order of the datatype.


getDatatypeSign

public int getDatatypeSign()
Returns the sign of the datatype.


toNative

public abstract int toNative()
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);
 

Returns:
the identifier of the user defined datatype.

fromNative

public abstract void fromNative(int nativeID)
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);

Parameters:
nativeID - the identifier of user defined datatype.

getDatatypeDescription

public java.lang.String getDatatypeDescription()
Returns a short text description of this datatype.


isUnsigned

public abstract boolean isUnsigned()
Checks if this datatype is an unsigned integer.

Returns:
True is the datatype is an unsigned integer; otherwise returns false.

open

public int open()
Description copied from class: HObject
Opens access to this object.

Sub-classes have to implement this interface so that different data objects have their own ways of how the data resources are opened.

Specified by:
open in class HObject
Returns:
the interface identifier for access this object.

close

public void close(int id)
Description copied from class: HObject
Closes access to this object.

Specified by:
close in class HObject
Parameters:
id - the object identifier. Sub-classes have to implement this interface so that different data objects have their own ways of how the data resources are closed.

getMetadata

public java.util.List getMetadata()
                           throws java.lang.Exception
Description copied from interface: DataFormat
Loads the metadata such as attributes and type of the the data object into memory if the metadata is not loaded. If the metadata is loaded, it returns the metadata. The metadata is stored as a collection of metadata ojbects in a List.

Returns:
the list of metadata objects.
Throws:
java.lang.Exception
See Also:
List

writeMetadata

public void writeMetadata(java.lang.Object info)
                   throws java.lang.Exception
Description copied from interface: DataFormat
Saves a specific metadata into file. If the metadata exists, it updates its value. If the metadata does not exists, it creates and attach the new metadata to the object and saves it into file.

Parameters:
info - the specific metadata.
Throws:
java.lang.Exception

removeMetadata

public void removeMetadata(java.lang.Object info)
                    throws java.lang.Exception
Description copied from interface: DataFormat
Deletes an existing metadata from this data object.

Parameters:
info - the metadata to delete.
Throws:
java.lang.Exception