public abstract class Datatype extends HObject
A datatype has four basic characteristics: class, size, byte order and sign. These characteristics are defined in the HDF5 User's Guide.
These characteristics 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 datatype. "Native" here is different from the "native" definition in the HDF5 library.
Two functions, toNative() and fromNative(), are defined to convert the general characteristics to/from the native datatype. Sub-classes must implement these functions so that the conversion will be done correctly. The values of the CLASS member are not identical to HDF5 values for a datatype class.
Modifier and Type | Field and Description |
---|---|
protected Datatype |
baseType
The base datatype of every element of the array (for CLASS_ARRAY
datatype).
|
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_TIME
|
static int |
CLASS_VLEN
|
protected List<Integer> |
compoundMemberFieldIDs
The list of field IDs of members of a compound Datatype.
|
protected List<String> |
compoundMemberNames
The list of names of members of a compound Datatype.
|
protected List<Long> |
compoundMemberOffsets
The list of offsets of members of a compound Datatype.
|
protected List<Datatype> |
compoundMemberTypes
The list of types of members of a compound Datatype
|
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.
|
protected long[] |
dims
The dimensions of the ARRAY element of an ARRAY datatype.
|
protected String |
enumMembers
The (name, value) pairs of enum members.
|
protected boolean |
isVLEN
Determines whether this datatype is a variable-length type.
|
static int |
NATIVE
The default definition for datatype size, order, and sign.
|
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
|
fileFormat, linkTargetObjName, oid, separator
Constructor and Description |
---|
Datatype(FileFormat theFile,
String name,
String path)
Constructs a named datatype with a given file, name and path.
|
Datatype(FileFormat theFile,
String name,
String path,
long[] oid)
Deprecated.
Not for public use in the future.
Using Datatype(FileFormat, String, String) |
Datatype(int tid)
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.
|
Datatype(int tclass,
int tsize,
int torder,
int tsign,
Datatype tbase)
Constructs a Datatype with specified class, size, byte order and sign.
|
Modifier and Type | Method and Description |
---|---|
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 datatype identifier.
|
long[] |
getArrayDims()
Returns the dimensions of an Array Datatype.
|
Datatype |
getBasetype()
Returns the datatype of array elements for an ARRAY datatype.
|
List<String> |
getCompoundMemberNames() |
List<Datatype> |
getCompoundMemberTypes() |
int |
getDatatypeClass()
Returns the class of the datatype.
|
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.
|
String |
getEnumMembers()
Returns the "name=value" pairs of enum members for enum datatype.
|
List |
getMetadata()
Retrieves the metadata such as attributes from file.
|
abstract boolean |
isUnsigned()
Checks if this datatype is an unsigned integer.
|
boolean |
isVLEN()
Checks if this datatype is a variable-length type.
|
int |
open()
Opens access to this named datatype.
|
void |
removeMetadata(Object info)
Deletes an existing metadata from this data object.
|
void |
setEnumMembers(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 |
updateMetadata(Object info)
Updates an existing metadata from this data object.
|
void |
writeMetadata(Object info)
Writes a specific metadata (such as attribute) into file.
|
debug, equals, equalsOID, getFID, getFile, getFileFormat, getFullName, getLinkTargetObjName, getName, getOID, getPath, setLinkTargetObjName, setName, setPath, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
hasAttribute
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 CLASS_TIME
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
protected int datatypeClass
protected int datatypeSize
protected int datatypeOrder
protected int datatypeSign
protected String enumMembers
protected List<String> compoundMemberNames
protected List<Datatype> compoundMemberTypes
protected List<Long> compoundMemberOffsets
protected List<Integer> compoundMemberFieldIDs
protected Datatype baseType
protected long[] dims
protected boolean isVLEN
public Datatype(FileFormat theFile, String name, 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, String name, String path, long[] oid)
Datatype(FileFormat, String, String)
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/".oid
- the oidof the datatype.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 tclass, int tsize, int torder, int tsign, Datatype tbase)
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 MSGNtbase
- the base datatype of the new datatypepublic Datatype(int tid)
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);
tid
- the native datatype identifier.fromNative(int tid)
public int getDatatypeClass()
public int getDatatypeSize()
public int getDatatypeOrder()
public int getDatatypeSign()
public Datatype getBasetype()
For example, in a dataset of type ARRAY of integer, the datatype of the dataset is ARRAY. The datatype of the base type is integer.
public final void setEnumMembers(String enumStr)
For Example,
enumStr
- the (name, value) pairs of enum memberspublic final String getEnumMembers()
For Example,
public final long[] getArrayDims()
public final List<String> getCompoundMemberNames()
public final List<Datatype> getCompoundMemberTypes()
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 String getDatatypeDescription()
public abstract boolean isUnsigned()
public boolean isVLEN()
public int open()
open
in class HObject
HObject.close(int)
public abstract void close(int id)
Sub-classes must replace this default implementation.
public List getMetadata() throws Exception
DataFormat
Metadata such as attributes are stored in a List.
Exception
- if the metadata can not be retrievedpublic void writeMetadata(Object info) throws Exception
DataFormat
info
- the metadata to write.Exception
- if the metadata can not be writtenpublic void removeMetadata(Object info) throws Exception
DataFormat
info
- the metadata to delete.Exception
- if the metadata can not be removedpublic void updateMetadata(Object info) throws Exception
DataFormat
info
- the metadata to update.Exception
- if the metadata can not be updatedCopyright © 2017. All Rights Reserved.