Object
hdf.object.HObject
hdf.object.Datatype
hdf.object.h4.H4Datatype
- All Implemented Interfaces:
MetaDataContainer
,Serializable
This class defines HDF4 data type characteristics and APIs for a data type.
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.
- Version:
- 1.1 9/4/2007
- Author:
- Peter X. Cao
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class hdf.object.Datatype
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, isNamed, isVariableStr, isVLEN, NATIVE, NSGN, ORDER_BE, ORDER_LE, ORDER_NONE, ORDER_VAX, SIGN_2, SIGN_NONE
Fields inherited from class hdf.object.HObject
fileFormat, linkTargetObjName, oid, SEPARATOR
-
Constructor Summary
ConstructorDescriptionH4Datatype(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. -
Method Summary
Modifier and TypeMethodDescriptionstatic 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
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.Returns a short text description of this datatype.getMetadata(int... attrPropList)
Retrieves the object's metadata, such as attributes, from the file.boolean
Check if the object has any attributes attached.boolean
isText()
Checks if this datatype is a boolean type.boolean
Checks if this datatype is unsigned.static boolean
isUnsigned(long datatype)
Checks if the datatype is an unsigned integer.Methods inherited from class hdf.object.Datatype
clear, getArrayDims, getCompoundMemberNames, getCompoundMemberOffsets, getCompoundMemberTypes, getDatatypeBase, getDatatypeClass, getDatatypeOrder, getDatatypeSign, getDatatypeSize, getEnumMembers, getEnumMembersAsString, getMetadata, getReferenceType, isArray, isBitField, isChar, isCompound, isEnum, isFloat, isInteger, isNamed, isOpaque, isRef, isString, isVarStr, isVLEN, open, removeMetadata, setEnumMembers, toString, updateMetadata, writeMetadata
Methods inherited from class hdf.object.HObject
createFullname, debug, equals, equals, equalsOID, getFID, getFile, getFileFormat, getFullName, getLinkTargetObjName, getName, getOID, getPath, hashCode, setFullname, setLinkTargetObjName, setName, setPath
-
Constructor Details
-
H4Datatype
Constructs a H4Datatype with specified class, size, byte order and sign. The following is a list of a few examples of H4Datatype:- to create unsigned native integer
H4Datatype type = new H4Dataype(Datatype.CLASS_INTEGER, Datatype.NATIVE, Datatype.NATIVE, Datatype.SIGN_NONE); - to create 16-bit signed integer with big endian
H4Datatype type = new H4Dataype(Datatype.CLASS_INTEGER, 2, Datatype.ORDER_BE, Datatype.NATIVE); - to create native float
H4Datatype type = new H4Dataype(Datatype.CLASS_FLOAT, Datatype.NATIVE, Datatype.NATIVE, Datatype.NATIVE); - to create 64-bit double
H4Datatype type = new H4Dataype(Datatype.CLASS_FLOAT, 8, Datatype.NATIVE, Datatype.NATIVE);
- Parameters:
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. Valid values are NATIVE or a positive value.torder
- the byte order of the datatype. Valid values are ORDER_LE, ORDER_BE, ORDER_VAX, ORDER_NONE and NATIVE.tsign
- the sign of the datatype. Valid values are SIGN_NONE, SIGN_2 and NATIVE.- Throws:
Exception
- if there is an error
- to create unsigned native integer
-
H4Datatype
Constructs a H4Datatype with a given native datatype identifier. For example,Datatype dtype = new H4Datatype(HDFConstants.DFNT_INT32);
will construct a datatype equivalent tonew H4Datatype(Datatype.CLASS_INTEGER, 4, Datatype.NATIVE, Datatype.SIGN_NONE);
- Parameters:
nativeID
- the native datatype identifier.- Throws:
Exception
- if there is an error- See Also:
fromNative(long nativeID)
-
-
Method Details
-
fromNative
Description copied from class:Datatype
Set datatype characteristics (class, size, byte order and sign) from a given datatype identifier. 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
new H5Datatype(CLASS_INTEGER, 4, NATIVE, SIGN_NONE);- Specified by:
fromNative
in classDatatype
- Parameters:
tid
- the datatype identifier.
-
allocateArray
Allocate a 1D array large enough to hold a multidimensional array of 'datasize' elements of 'datatype' numbers.- Parameters:
datatype
- the data typedatasize
- the size of the data array- Returns:
- an array of 'datasize' numbers of datatype.
- Throws:
OutOfMemoryError
- if the array cannot be allocated
-
getDescription
Description copied from class:Datatype
Returns a short text description of this datatype.- Overrides:
getDescription
in classDatatype
- Returns:
- a short text description of this datatype
-
isUnsigned
Description copied from class:Datatype
Checks if this datatype is unsigned.- Overrides:
isUnsigned
in classDatatype
- Returns:
- true if the datatype is unsigned; otherwise, returns false.
-
isUnsigned
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.
-
isText
Description copied from class:Datatype
Checks if this datatype is a boolean type. -
createNative
Description copied from class:Datatype
Converts the datatype object to a native datatype. Subclasses must implement it so that this datatype will be converted accordingly. Use close() to close the native identifier; otherwise, the datatype will be left open. 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 toint tid = H5.H5Tcopy(HDF5Constants.H5T_NATIVE_UNINT32);
- Specified by:
createNative
in classDatatype
- Returns:
- the identifier of the native datatype.
-
close
Description copied from class:Datatype
Closes a datatype identifier. Sub-classes must replace this default implementation. -
getMetadata
Retrieves the object's metadata, such as attributes, from the file. Metadata, such as attributes, is stored in a List.- Parameters:
attrPropList
- the list of properties to get- Returns:
- the list of metadata objects.
- Throws:
Exception
- if the metadata can not be retrieved
-
hasAttribute
Check if the object has any attributes attached.- Returns:
- true if it has any attributes, false otherwise.
-