Package hdf.object.h5

Class H5Link

Object
hdf.object.HObject
hdf.object.h5.H5Link
All Implemented Interfaces:
MetaDataContainer, Serializable

public class H5Link extends HObject implements MetaDataContainer
An H5Link object represents an existing HDF5 object in file. H5Link object is an HDF5 object that is either a soft or an external link to an object in a file that does not exist. The type of the object is unknown. Once the object being linked to is created, and the type is known, then H5link object will change its type.
Version:
2.7.2 7/6/2010
Author:
Nidhi Gupta
See Also:
  • Constructor Details

    • H5Link

      public H5Link(FileFormat theFile, String theName, String thePath)
      Constructs an HDF5 link with specific name, path, and parent.
      Parameters:
      theFile - the file which containing the link.
      theName - the name of this link, e.g. "link1".
      thePath - the full path of this link, e.g. "/groups/".
    • H5Link

      public H5Link(FileFormat theFile, String theName, String thePath, long[] oid)
      Constructs an HDF5 link with specific name, path, parent and oid.
      Parameters:
      theFile - the file which containing the link.
      theName - the name of this link, e.g. "link1".
      thePath - the full path of this link, e.g. "/groups/".
      oid - the oid of this link, e.g. "/groups/".
  • Method Details

    • open

      public long open()
      Description copied from class: HObject
      Opens an existing object such as a dataset or group for access. The return value is an object identifier obtained by implementing classes such as H5.H5Dopen(). This function is needed to allow other objects to be able to access the object. For instance, H5File class uses the open() function to obtain object identifier for copyAttributes(long src_id, long dst_id) and other purposes. The open() function should be used in pair with close(long) function.
      Specified by:
      open in class HObject
      Returns:
      the object identifier if successful; otherwise returns a negative value.
      See Also:
    • close

      public void close(long id)
      Description copied from class: HObject
      Closes access to the object. 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.
      Specified by:
      close in class HObject
      Parameters:
      id - The object identifier.
    • getToken

      public long[] getToken()
      Get the token for this object.
      Returns:
      true if it has any attributes, false otherwise.
    • hasAttribute

      public boolean hasAttribute()
      Check if the object has any attributes attached.
      Specified by:
      hasAttribute in interface MetaDataContainer
      Returns:
      true if it has any attributes, false otherwise.
    • clear

      public void clear()
      Removes all of the elements from metadata list. The list should be empty after this call returns.
      Specified by:
      clear in interface MetaDataContainer
    • getMetadata

      public List<Attribute> getMetadata() throws hdf.hdf5lib.exceptions.HDF5Exception
      Retrieves the object's metadata, such as attributes, from the file. Metadata, such as attributes, is stored in a List.
      Specified by:
      getMetadata in interface MetaDataContainer
      Returns:
      the list of metadata objects.
      Throws:
      hdf.hdf5lib.exceptions.HDF5Exception - if the metadata can not be retrieved
    • getMetadata

      public List<Attribute> getMetadata(int... attrPropList) throws hdf.hdf5lib.exceptions.HDF5Exception
      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:
      hdf.hdf5lib.exceptions.HDF5Exception - if the metadata can not be retrieved
    • writeMetadata

      public void writeMetadata(Object info) throws Exception
      Writes a specific piece of metadata (such as an attribute) into the file. If an HDF(4&5) attribute exists in the file, this method updates its value. If the attribute does not exist in the file, it creates the attribute in the file and attaches it to the object. It will fail to write a new attribute to the object where an attribute with the same name already exists. To update the value of an existing attribute in the file, one needs to get the instance of the attribute by getMetadata(), change its values, then use writeMetadata() to write the value.
      Specified by:
      writeMetadata in interface MetaDataContainer
      Parameters:
      info - the metadata to write.
      Throws:
      Exception - if the metadata can not be written
    • removeMetadata

      public void removeMetadata(Object info) throws hdf.hdf5lib.exceptions.HDF5Exception
      Deletes an existing piece of metadata from this object.
      Specified by:
      removeMetadata in interface MetaDataContainer
      Parameters:
      info - the metadata to delete.
      Throws:
      hdf.hdf5lib.exceptions.HDF5Exception - if the metadata can not be removed
    • updateMetadata

      public void updateMetadata(Object info) throws hdf.hdf5lib.exceptions.HDF5Exception
      Updates an existing piece of metadata attached to this object.
      Specified by:
      updateMetadata in interface MetaDataContainer
      Parameters:
      info - the metadata to update.
      Throws:
      hdf.hdf5lib.exceptions.HDF5Exception - if the metadata can not be updated
    • setName

      public void setName(String newName) throws Exception
      Description copied from class: HObject
      Sets the name of the object. setName (String newName) changes the name of the object in the file.
      Overrides:
      setName in class HObject
      Parameters:
      newName - The new name of the object.
      Throws:
      Exception - if name is root or contains separator