public class H4Datatype extends Datatype
This class provides several methods to convert an HDF4 datatype identifier to a datatype object, and vice versa. A datatype object is described by four basic fields: datatype class, size, byte order, and sign, while an HDF5 datatype is presented by a datatype identifier.
arrayDims, baseType, CLASS_ARRAY, CLASS_BITFIELD, CLASS_CHAR, CLASS_COMPOUND, CLASS_ENUM, CLASS_FLOAT, CLASS_INTEGER, CLASS_NO_CLASS, CLASS_OPAQUE, CLASS_REFERENCE, CLASS_STRING, CLASS_TIME, CLASS_VLEN, compoundMemberNames, compoundMemberOffsets, compoundMemberTypes, datatypeClass, datatypeDescription, datatypeOrder, datatypeSign, datatypeSize, enumMembers, is_variable_str, is_VLEN, NATIVE, NSGN, ORDER_BE, ORDER_LE, ORDER_NONE, ORDER_VAX, SIGN_2, SIGN_NONE
fileFormat, linkTargetObjName, oid, separator
Constructor and Description |
---|
H4Datatype(int tclass,
int tsize,
int torder,
int tsign)
Constructs a H4Datatype with specified class, size, byte order and sign.
|
H4Datatype(long nativeID)
Constructs a H4Datatype with a given native datatype identifier.
|
Modifier and Type | Method and Description |
---|---|
static Object |
allocateArray(long datatype,
int datasize)
Allocate a 1D array large enough to hold a multidimensional array of 'datasize' elements of
'datatype' numbers.
|
void |
close(long id)
Closes a datatype identifier.
|
long |
createNative()
Converts the datatype object to a native datatype.
|
void |
fromNative(long tid)
Set datatype characteristics (class, size, byte order and sign) from a given datatype identifier.
|
String |
getDescription()
Returns a short text description of this datatype.
|
List |
getMetadata(int... attrPropList) |
boolean |
hasAttribute()
Check if the object has any attributes attached.
|
boolean |
isText() |
boolean |
isUnsigned()
Checks if this datatype is unsigned.
|
static boolean |
isUnsigned(long datatype)
Checks if the datatype is an unsigned integer.
|
getArrayDims, getCompoundMemberNames, getCompoundMemberTypes, getDatatypeBase, getDatatypeClass, getDatatypeOrder, getDatatypeSign, getDatatypeSize, getEnumMembers, getEnumMembersAsString, getMetadata, isArray, isBitField, isChar, isCompound, isEnum, isFloat, isInteger, isOpaque, isRef, isString, isVarStr, isVLEN, open, removeMetadata, setEnumMembers, toString, updateMetadata, writeMetadata
debug, equals, equalsOID, getFID, getFile, getFileFormat, getFullName, getLinkTargetObjName, getName, getOID, getPath, setLinkTargetObjName, setName, setPath
public H4Datatype(int tclass, int tsize, int torder, int tsign)
The following is a list of a few examples of H4Datatype:
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 H4Datatype(long nativeID)
For example,
Datatype dtype = new H4Datatype(HDFConstants.DFNT_INT32);will construct a datatype equivalent to
new H4Datatype(CLASS_INTEGER, 4, NATIVE, SIGN_NONE);
nativeID
- the native datatype identifier.fromNative(long nativeID)
public boolean hasAttribute()
MetaDataContainer
public void fromNative(long tid)
Datatype
Sub-classes must implement it so that this datatype will be converted accordingly.
For example, if the type identifier is a 64-bit unsigned integer created from HDF5,
H5Datatype dtype = new H5Datatype(); dtype.fromNative(HDF5Constants.H5T_NATIVE_UNINT32);Where dtype is equivalent to
fromNative
in class Datatype
tid
- the datatype identifier.public static final Object allocateArray(long datatype, int datasize) throws OutOfMemoryError
datatype
- the data typedatasize
- the size of the data arrayOutOfMemoryError
- if the array cannot be allocatedpublic String getDescription()
Datatype
getDescription
in class Datatype
public boolean isUnsigned()
Datatype
isUnsigned
in class Datatype
public static final boolean isUnsigned(long datatype)
datatype
- the data type.public long createNative()
Datatype
For example, a HDF5 datatype created from
H5Dataype dtype = new H5Datatype(CLASS_INTEGER, 4, NATIVE, SIGN_NONE); int tid = dtype.createNative();The "tid" will be the HDF5 datatype id of a 64-bit unsigned integer, which is equivalent to
int tid = H5.H5Tcopy(HDF5Constants.H5T_NATIVE_UNINT32);
createNative
in class Datatype
public void close(long id)
Datatype
Sub-classes must replace this default implementation.
public List getMetadata(int... attrPropList) throws Exception
Exception
Copyright © 2018. All Rights Reserved.