|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectncsa.hdf.object.HObject
ncsa.hdf.object.Datatype
public abstract class Datatype
Datatype is an abstract class that defines datatype characteristics and APIs for a data type.
A datatype has four basic characteristics: class, size, byte order and sign. These charactertics are defeined in the HDF5 User's Guide.
These charactertics apply to all the sub-classes. The sub-classes may have different ways to describe a datatype. We here define the native datatype to the datatype used by the sub-class. For example, H5Datatype uses a datatype identifier (hid_t) to specify a datatype. NC2Datatype uses ucar.nc2.DataType object to describe its dataype. "Native" here is different from the "native" definition in the HDF5 library.
Two functions, toNative() and fromNative(), are defined to convert the general charactertics to/form the native datatype. Sub-classes must implement these functions so that the conversion will be done correctly.
Field Summary | |
---|---|
static int |
CLASS_ARRAY
See HDF5 User's Guide |
static int |
CLASS_BITFIELD
See HDF5 User's Guide |
static int |
CLASS_CHAR
See HDF5 User's Guide |
static int |
CLASS_COMPOUND
See HDF5 User's Guide |
static int |
CLASS_ENUM
See HDF5 User's Guide |
static int |
CLASS_FLOAT
See HDF5 User's Guide |
static int |
CLASS_INTEGER
See HDF5 User's Guide |
static int |
CLASS_NO_CLASS
See HDF5 User's Guide |
static int |
CLASS_OPAQUE
See HDF5 User's Guide |
static int |
CLASS_REFERENCE
See HDF5 User's Guide |
static int |
CLASS_STRING
See HDF5 User's Guide |
static int |
CLASS_VLEN
See HDF5 User's Guide |
static int |
NATIVE
The default definition for datatype size, order, and sign. |
static int |
NSGN
See HDF5 User's Guide |
static int |
ORDER_BE
See HDF5 User's Guide |
static int |
ORDER_LE
See HDF5 User's Guide |
static int |
ORDER_NONE
See HDF5 User's Guide |
static int |
ORDER_VAX
See HDF5 User's Guide |
static int |
SIGN_2
See HDF5 User's Guide |
static int |
SIGN_NONE
See HDF5 User's Guide |
Fields inherited from class ncsa.hdf.object.HObject |
---|
separator, serialVersionUID |
Constructor Summary | |
---|---|
Datatype(FileFormat theFile,
java.lang.String name,
java.lang.String path)
Constructs a named datatype with a given file, name and path. |
|
Datatype(FileFormat theFile,
java.lang.String name,
java.lang.String path,
long[] oid)
Deprecated. Not for public use in the future. Using Datatype(FileFormat, String, String) |
|
Datatype(int type)
Constructs a Datatype with a given native datatype identifier. |
|
Datatype(int tclass,
int tsize,
int torder,
int tsign)
Constructs a Datatype with specified class, size, byte order and sign. |
Method Summary | |
---|---|
abstract void |
close(int id)
Closes a datatype identifier. |
abstract void |
fromNative(int nativeID)
Set datatype characteristics (class, size, byte order and sign) from a given datatye identifier. |
Datatype |
getBasetype()
Returns the datatype of array element for ARRAY 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 byte order of the datatype. |
int |
getDatatypeSign()
Returns the sign (SIGN_NONE, SIGN_2 or NSGN) of an integer datatype. |
int |
getDatatypeSize()
Returns the size of the datatype in bytes. |
java.lang.String |
getEnumMembers()
Returns the "name=value" pairs of enum members for enum datatype. |
java.util.List |
getMetadata()
Retrieves the metadata such as attributes from file. |
abstract boolean |
isUnsigned()
Checks if this datatype is an unsigned integer. |
int |
open()
Opens access to this named datatype. |
void |
removeMetadata(java.lang.Object info)
Deletes an existing metadata from this data object. |
void |
setEnumMembers(java.lang.String enumStr)
Sets the (name, value) pairs of enum members for enum datatype. |
abstract int |
toNative()
Converts the datatype object to a native datatype. |
void |
writeMetadata(java.lang.Object info)
Writes a specific metadata (such as attribute) into file. |
Methods inherited from class ncsa.hdf.object.HObject |
---|
equalsOID, getFID, getFile, getFileFormat, getFullName, getLinkTargetObjName, getName, getOID, getPath, setLinkTargetObjName, setName, setPath, toString |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface ncsa.hdf.object.DataFormat |
---|
hasAttribute |
Field Detail |
---|
public static final int NATIVE
public static final int CLASS_NO_CLASS
public static final int CLASS_INTEGER
public static final int CLASS_FLOAT
public static final int CLASS_CHAR
public static final int CLASS_STRING
public static final int CLASS_BITFIELD
public static final int CLASS_OPAQUE
public static final int CLASS_COMPOUND
public static final int CLASS_REFERENCE
public static final int CLASS_ENUM
public static final int CLASS_VLEN
public static final int CLASS_ARRAY
public static final int ORDER_LE
public static final int ORDER_BE
public static final int ORDER_VAX
public static final int ORDER_NONE
public static final int SIGN_NONE
public static final int SIGN_2
public static final int NSGN
Constructor Detail |
---|
public Datatype(FileFormat theFile, java.lang.String name, java.lang.String path)
theFile
- the HDF file.name
- the name of the datatype, e.g "12-bit Integer".path
- the full group path of the datatype, e.g. "/datatypes/".@Deprecated public Datatype(FileFormat theFile, java.lang.String name, java.lang.String path, long[] oid)
Datatype(FileFormat, String, String)
public Datatype(int tclass, int tsize, int torder, int tsign)
The following is a list of a few example of H5Datatype.
tclass
- the class of the datatype, e.g. CLASS_INTEGER, CLASS_FLOAT and
etc.tsize
- the size of the datatype in bytes, e.g. for a 32-bit integer,
the size is 4.torder
- the byte order of the datatype. Valid values are ORDER_LE,
ORDER_BE, ORDER_VAX and ORDER_NONEtsign
- the sign of the datatype. Valid values are SIGN_NONE, SIGN_2
and MSGNpublic Datatype(int type)
For example, if the datatype identifier is a 32-bit unsigned integer created from HDF5,
int tid = H5.H5Tcopy(HDF5Constants.H5T_NATIVE_UNINT32); Datatype dtype = new Datatype(tid);will construct a datatype equivalent to new Datatype(CLASS_INTEGER, 4, NATIVE, SIGN_NONE);
type
- the native datatype identifier.fromNative(int nativeID)
Method Detail |
---|
public int getDatatypeClass()
public int getDatatypeSize()
public int getDatatypeOrder()
public int getDatatypeSign()
public Datatype getBasetype()
For example, a dataset set of ARRAY of inteter, The datatype of the dataset is ARRAY. The datatype of the base type is integer.
public final void setEnumMembers(java.lang.String enumStr)
For Example,
enumStr
- the (name, value) pairs of enum memberspublic final java.lang.String getEnumMembers()
For Example,
public abstract int toNative()
For example, a HDF5 datatype created from
H5Dataype dtype = new H5Datatype(CLASS_INTEGER, 4, NATIVE, SIGN_NONE); int tid = dtype.toNative();There "tid" will be the HDF5 datatype id of a 32-bit unsigned integer, which is equivalent to
int tid = H5.H5Tcopy(HDF5Constants.H5T_NATIVE_UNINT32);
public abstract void fromNative(int nativeID)
Sub-classes must implement it so that this datatype will be converted accordingly.
For example, if the type identifier is a 32-bit unsigned integer created from HDF5,
H5Datatype dtype = new H5Datatype(); dtype.fromNative(HDF5Constants.H5T_NATIVE_UNINT32);Where dtype is equivalent to
nativeID
- the datatype identifier.public java.lang.String getDatatypeDescription()
public abstract boolean isUnsigned()
public int open()
open
in class HObject
HObject.close(int)
public abstract void close(int id)
Sub-clases must replace this default implementation.
close
in class HObject
id
- the datatype identifier to close.public java.util.List getMetadata() throws java.lang.Exception
DataFormat
Metadata such as attributes are stored in a List.
java.lang.Exception
public void writeMetadata(java.lang.Object info) throws java.lang.Exception
DataFormat
If an HDF(4&5) attribute exists in file, the method updates its value. If the attribute does not exists in file, it creates the attribute in file and attaches it to the object. It will fail to write a new attribute to the object where an attribute with the same name already exists. To update the value of an existing attribute in file, one needs to get the instance of the attribute by getMetadata(), change its values, and use writeMetadata() to write the value.
info
- the metadata to write.
java.lang.Exception
public void removeMetadata(java.lang.Object info) throws java.lang.Exception
DataFormat
info
- the metadata to delete.
java.lang.Exception
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |