ncsa.hdf.object
Class HObject

java.lang.Object
  extended byncsa.hdf.object.HObject
All Implemented Interfaces:
DataFormat, java.io.Serializable
Direct Known Subclasses:
Dataset, Datatype, Group

public abstract class HObject
extends java.lang.Object
implements java.io.Serializable, DataFormat

HObject is the base class for for all the data objects. Current implementing classes include HDF4 and HDF5 data objects. If a new FileFormat is added, the objects of the FileFormat should implementing HObject.

All the HDF4 and HDF5 data objects are inherited from HObject. At the top level of hierarchy, both HDF4 and HDF5 have the same super-classes such Group, and Dataset. At bottom level of hierarchy, HDF4 and HDF5 objects have their own implementation such H4Vdata, H4SDS, H4GRImage, H5ScalarDS, H5CompoundDS, and etc.

Warning: HDF4 and HDF5 may have multiple links to the same object. Data object in this model does not deal with multiple links. Users may create duplicate copies of the same data object with different path. Applications should check the OID of the data object to avoid duplicate copies of the same object.

HDF4 objects are uniquely identified by the (ref_id, tag_id) pairs. HDF5 objects uniquely identified by the reference identifier.

See Also:
DataFormat, Serialized Form

Field Summary
protected  boolean hasAttribute
           
protected  long[] oid
          array of long integer storing unique identifier for each HDF object.
static java.lang.String separator
          The path separator of HDF4 and HDF5 objects.
 
Constructor Summary
HObject()
           
HObject(FileFormat theFileFormat, java.lang.String theName, java.lang.String thePath)
          Constructs an instance of the data object with specific name and path.
HObject(FileFormat theFileFormat, java.lang.String theName, java.lang.String thePath, long[] oid)
          Constructs an instance of the data object with specific name and path.
 
Method Summary
abstract  void close(int id)
          Closes access to this object.
 boolean equalsOID(long[] theID)
          Check if this object has the given object identifier.
 int getFID()
          Returns the file identifier of this data object.
 java.lang.String getFile()
          Returns the full path of the file that contains this data object.
 FileFormat getFileFormat()
          Returns the fileformat which contains this object.
 java.lang.String getName()
          Returns the name of this object.
 long[] getOID()
          Returns a cloned copy of the object identifier.
 java.lang.String getPath()
          Returns the full path of this object.
 boolean hasAttribute()
           
abstract  int open()
          Opens access to this object.
 void setName(java.lang.String newName)
          Sets the name of the data object.
 void setPath(java.lang.String newPath)
          Sets the path of the data object.
 java.lang.String toString()
          Returns the string representation of this data object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ncsa.hdf.object.DataFormat
getMetadata, removeMetadata, writeMetadata
 

Field Detail

separator

public static final java.lang.String separator
The path separator of HDF4 and HDF5 objects.

See Also:
Constant Field Values

oid

protected final long[] oid
array of long integer storing unique identifier for each HDF object.

HDF4 objects are uniquely identified by the (tag_id, ref_id) pairs. HDF5 objects uniquely identified by the reference identifier.


hasAttribute

protected boolean hasAttribute
Constructor Detail

HObject

public HObject()

HObject

public HObject(FileFormat theFileFormat,
               java.lang.String theName,
               java.lang.String thePath)
Constructs an instance of the data object with specific name and path. An HDF data object must have a name. A data object is uniquely identified by its full name (the full path + the name of the object) and the file that contains the data object.


HObject

public HObject(FileFormat theFileFormat,
               java.lang.String theName,
               java.lang.String thePath,
               long[] oid)
Constructs an instance of the data object with specific name and path. An HDF data object must have a name. A data object is uniquely identified by its full name (the full path + the name of the object) and the file that contains the data object.

Parameters:
oid - the unique identifier of this data object.
Method Detail

getFile

public final java.lang.String getFile()
Description copied from interface: DataFormat
Returns the full path of the file that contains this data object. The file name is necessary because the file of this data object is uniquely identified when mutilple files are opened by an application at the same time.

Specified by:
getFile in interface DataFormat

getName

public final java.lang.String getName()
Returns the name of this object.


getPath

public final java.lang.String getPath()
Returns the full path of this object.


setName

public void setName(java.lang.String newName)
             throws java.lang.Exception
Sets the name of the data object.

Parameters:
newName - the new name of the object.
Throws:
java.lang.Exception

setPath

public void setPath(java.lang.String newPath)
             throws java.lang.Exception
Sets the path of the data object.

Parameters:
newPath - the new path of the object.
Throws:
java.lang.Exception

open

public abstract int open()
Opens access to this object.

Sub-classes have to implement this interface so that different data objects have their own ways of how the data resources are opened.

Returns:
the interface identifier for access this object.

close

public abstract void close(int id)
Closes access to this object.

Parameters:
id - the object identifier. Sub-classes have to implement this interface so that different data objects have their own ways of how the data resources are closed.

getFID

public final int getFID()
Returns the file identifier of this data object.


equalsOID

public final boolean equalsOID(long[] theID)
Check if this object has the given object identifier.

HDF4 and HDF5 data objects are identified by their unique OIDs. A data object in file may have multiple pathes which are presented in the tree as separate objects. HObject.equalsOID(long[] theID) checks if two data objects int the tree point to the same object in the file.


getFileFormat

public final FileFormat getFileFormat()
Returns the fileformat which contains this object.


getOID

public final long[] getOID()
Returns a cloned copy of the object identifier. The object OID cannot be modified once it is created. getIOD() clones the object OID to ensure the object OID cannot be modified.

Returns:
the cloned copy of the object OID.

toString

public java.lang.String toString()
Returns the string representation of this data object. The String consists of the name and path of the data object.


hasAttribute

public boolean hasAttribute()