public abstract class HObject extends Object implements Serializable, DataFormat
HObject __________________________|________________________________ | | | Group Dataset Datatype | _________|___________ | | | | | | ScalarDS CompoundDS | | | | | ---------------------Implementing classes such as------------------------- ____|____ _____|______ _____|_____ _____|_____ | | | | | | | | H5Group H4Group H5ScalarDS H4ScalarDS H5CompDS H4CompDS H5Datatype H4DatatypeAll HDF4 and HDF5 data objects are inherited from HObject. At the top level of the hierarchy, both HDF4 and HDF5 have the same super-classes, such as Group and Dataset. At the bottom level of the hierarchy, HDF4 and HDF5 objects have their own implementation, such as H5Group, H5ScalarDS, H5CompoundDS, and H5Datatype.
Warning: HDF4 and HDF5 may have multiple links to the same object. Data objects in this model do not deal with multiple links. Users may create duplicate copies of the same data object with different paths. Applications should check the OID of the data object to avoid duplicate copies of the same object.
HDF4 objects are uniquely identified by the OID (tag_id, ref_id) pair. The ref_id is the object reference count. The tag_id is a pre-defined number to identify the type of object. For example, DFTAG_RI is for raster image, DFTAG_SD is for scientific dataset, and DFTAG_VG is for Vgroup.
HDF5 objects are uniquely identified by the OID containing just the object reference. The OID is usually obtained by H5Rcreate(). The following example shows how to retrieve an object ID from a file:
// retrieve the object ID try { byte[] ref_buf = H5.H5Rcreate(h5file.getFID(), this.getFullName(), HDF5Constants.H5R_OBJECT, -1); long[] oid = new long[1]; oid[0] = HDFNativeData.byteToLong(ref_buf, 0); } catch (Exception ex) { }
Modifier and Type | Field and Description |
---|---|
protected FileFormat |
fileFormat
The file which contains the object
|
protected String |
linkTargetObjName
The name of the Target Object that is being linked to.
|
protected long[] |
oid
Array of long integer storing unique identifier for the object.
|
static String |
separator
The separator of object path, i.e.
|
Constructor and Description |
---|
HObject()
Constructs an instance of a data object without name and path.
|
HObject(FileFormat theFile,
String theName,
String thePath)
Constructs an instance of a data object with specific name and path.
|
HObject(FileFormat theFile,
String theName,
String thePath,
long[] oid)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
abstract void |
close(int id)
Closes access to the object.
|
protected void |
debug(Object msg)
Print out debug information
|
boolean |
equals(HObject obj)
Returns whether this HObject is equal to the specified HObject
by comparing their OIDs.
|
boolean |
equalsOID(long[] theID)
Checks if the OID of the object is the same as the given object
identifier within the same file.
|
int |
getFID()
Returns the file identifier of of the file containing the object.
|
String |
getFile()
Returns the name of the file that contains this data object.
|
FileFormat |
getFileFormat()
Returns the file that contains the object.
|
String |
getFullName()
Returns the full name (group path + object name) of the object.
|
String |
getLinkTargetObjName()
Returns the name of the target object that is linked to.
|
String |
getName()
Returns the name of the object.
|
long[] |
getOID()
Returns a cloned copy of the object identifier.
|
String |
getPath()
Returns the group path of the object.
|
abstract int |
open()
Opens an existing object such as a dataset or group for access.
|
void |
setLinkTargetObjName(String targetObjName)
Sets the name of the target object that is linked to.
|
void |
setName(String newName)
Sets the name of the object.
|
void |
setPath(String newPath)
Sets the path of the object.
|
String |
toString()
Returns the name of the object.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getMetadata, hasAttribute, removeMetadata, updateMetadata, writeMetadata
public static final String separator
protected final FileFormat fileFormat
protected long[] oid
HDF4 objects are uniquely identified by a (tag_id, ref_id) pair. i.e.
oid[0] = tag, oid[1] = ref_id.
HDF5 objects are uniquely identified by an object reference. i.e.
oid[0] = obj_id.
protected String linkTargetObjName
public HObject()
public HObject(FileFormat theFile, String theName, String thePath)
For example, in H5ScalarDS(h5file, "dset", "/arrays"), "dset" is the name of the dataset, "/arrays" is the group path of the dataset.
theFile
- the file that contains the data object.theName
- the name of the data object, e.g. "dset".thePath
- the group path of the data object, e.g. "/arrays".@Deprecated public HObject(FileFormat theFile, String theName, String thePath, long[] oid)
For example, in H5ScalarDS(h5file, "dset", "/arrays"), "dset" is the name of the dataset, "/arrays" is the group path of the dataset.
theFile
- the file that contains the data object.theName
- the name of the data object, e.g. "dset".thePath
- the group path of the data object, e.g. "/arrays".oid
- the ids of the data object.protected final void debug(Object msg)
msg
- the debug message to printpublic final String getFile()
The file name is necessary because the file of this data object is uniquely identified when multiple files are opened by an application at the same time.
getFile
in interface DataFormat
public final String getName()
public final String getLinkTargetObjName()
public final void setLinkTargetObjName(String targetObjName)
targetObjName
- The new name of the object.public final String getFullName()
public final String getPath()
public void setName(String newName) throws Exception
newName
- The new name of the object.Exception
- if name is root or contains separatorpublic void setPath(String newPath) throws Exception
setPath() is needed to change the path for an object when the name of a group containing the object is changed by setName(). The path of the object in memory under this group should be updated to the new path to the group. Unlike setName(), setPath() does not change anything in file.
newPath
- The new path of the object.Exception
- if a failure occurredpublic abstract int open()
close(int)
public abstract void close(int id)
Sub-classes must implement this interface because different data objects have their own ways of how the data resources are closed.
For example, H5Group.close() calls the hdf.hdf5lib.H5.H5Gclose() method and closes the group resource specified by the group id.
id
- The object identifier.public final int getFID()
public final boolean equalsOID(long[] theID)
HDF4 and HDF5 data objects are identified by their unique OIDs. A data object in a file may have multiple logical names , which are represented in a graph structure as separate objects.
The HObject.equalsOID(long[] theID) can be used to check if two data objects with different names are pointed to the same object within the same file.
theID
- The list object identifiers.public final FileFormat getFileFormat()
public final long[] getOID()
The object OID cannot be modified once it is created. getOID() clones the object OID to ensure the object OID cannot be modified outside of this class.
public boolean equals(HObject obj)
obj
- The objectpublic String toString()
This method overwrites the toString() method in the Java Object class (the root class of all Java objects) so that it returns the name of the HObject instead of the name of the class.
For example, toString() returns "Raster Image #2" instead of "hdf.object.h4.H4SDS".
Copyright © 2017. All Rights Reserved.