Module org.hdfgroup.object
Package hdf.object

# Class Group

Object
hdf.object.HObject
hdf.object.Group

All Implemented Interfaces:
  `MetaDataContainer`, `Serializable`

Direct Known Subclasses:
  `FitsGroup`, `H4Group`, `H5Group`, `NC2Group`

public abstract class Group extends HObject implements MetaDataContainer
Group is an abstract class. Current implementing classes are the H4Group and H5Group. This class includes general information of a group object such as members of a group and common operations on groups.

Members of a group may include other groups, datasets or links.

Version:
  1.1 9/4/2007
Author:
  Peter X. Cao
See Also:
  Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static int`
  `CRT_ORDER_INDEXED`
  `static int`
  `CRT_ORDER_TRACKED`
  `static int`
  `LINK_TYPE_EXTERNAL`
  `static int`
  `LINK_TYPE_HARD`
  `static int`
  `LINK_TYPE_SOFT`
  `protected int`
  `nMembersInFile`
  Total number of members of this group in file.
  `protected Group`
  `parent`
  The parent group where this group is located.

  ### Fields inherited from class hdf.object.HObject

  `fileFormat, linkTargetObjName, oid, SEPARATOR`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Group​(FileFormat theFile, String grpName, String grpPath, Group grpParent)`
  Constructs an instance of the group with specific name, path and parent group.
  `Group​(FileFormat theFile, String grpName, String grpPath, Group grpParent, long[] oid)`
  Deprecated.
  Not for public use in the future.
  Using `Group(FileFormat, String, String, Group)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addToMemberList​(HObject object)`
  Adds an object to the member list of this group in memory.
  `List<HObject>`
  `breadthFirstMemberList()`
  `void`
  `clear()`
  Clears up member list and other resources in memory for the group.
  `List<HObject>`
  `depthFirstMemberList()`
  `HObject`
  `getMember​(int idx)`
  Get the HObject at the specified index in this Group's member list.
  `List<HObject>`
  `getMemberList()`
  Returns the list of members of this group.
  `int`
  `getNumberOfMembersInFile()`
  Returns the total number of members of this group in file.
  `Group`
  `getParent()`
  `boolean`
  `isRoot()`
  Checks if it is a root group.
  `void`
  `removeFromMemberList​(HObject object)`
  Removes an object from the member list of this group in memory.
  `void`
  `setName​(String newName)`
  Sets the name of the group.

  ### Methods inherited from class hdf.object.HObject

  `close, createFullname, debug, equals, equals, equalsOID, getFID, getFile, getFileFormat, getFullName, getLinkTargetObjName, getName, getOID, getPath, hashCode, open, setFullname, setLinkTargetObjName, setPath, toString`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface hdf.object.MetaDataContainer

  `getMetadata, hasAttribute, removeMetadata, updateMetadata, writeMetadata`

- ## Field Details

  - ### parent

    protected Group parent
    The parent group where this group is located. The parent of the root group is null.

  - ### nMembersInFile

    protected int nMembersInFile
    Total number of members of this group in file.

  - ### LINK_TYPE_HARD

    public static final int LINK_TYPE_HARD
    See Also:
      Constant Field Values

  - ### LINK_TYPE_SOFT

    public static final int LINK_TYPE_SOFT
    See Also:
      Constant Field Values

  - ### LINK_TYPE_EXTERNAL

    public static final int LINK_TYPE_EXTERNAL
    See Also:
      Constant Field Values

  - ### CRT_ORDER_TRACKED

    public static final int CRT_ORDER_TRACKED
    See Also:
      Constant Field Values

  - ### CRT_ORDER_INDEXED

    public static final int CRT_ORDER_INDEXED
    See Also:
      Constant Field Values

- ## Constructor Details

  - ### Group

    public Group​(FileFormat theFile, String grpName, String grpPath, Group grpParent)
    Constructs an instance of the group with specific name, path and parent group. An HDF data object must have a name. The path is the group path starting from the root. The parent group is the group where this group is located.

    For example, in H5Group(h5file, "grp", "/groups/", pgroup), "grp" is the name of the group, "/groups/" is the group path of the group, and pgroup is the group where "grp" is located.

    Parameters:
      `theFile` - the file containing the group.
      `grpName` - the name of this group, e.g. "grp01".
      `grpPath` - the full path of this group, e.g. "/groups/".
      `grpParent` - the parent of this group.

  - ### Group

    @Deprecated public Group​(FileFormat theFile, String grpName, String grpPath, Group grpParent, long[] oid)
    Deprecated.
    Not for public use in the future.
    Using `Group(FileFormat, String, String, Group)`
    Parameters:
      `theFile` - the file containing the group.
      `grpName` - the name of this group, e.g. "grp01".
      `grpPath` - the full path of this group, e.g. "/groups/".
      `grpParent` - the parent of this group.
      `oid` - the oid of this group.

- ## Method Details

  - ### clear

    public void clear()
    Clears up member list and other resources in memory for the group. Since the destructor will clear memory space, the function is usually not needed.

  - ### addToMemberList

    public void addToMemberList​(HObject object)
    Adds an object to the member list of this group in memory.
    Parameters:
      `object` - the HObject to be added to the member list.

  - ### removeFromMemberList

    public void removeFromMemberList​(HObject object)
    Removes an object from the member list of this group in memory.
    Parameters:
      `object` - the HObject (Group or Dataset) to be removed from the member list.

  - ### getMemberList

    public List<HObject> getMemberList()
    Returns the list of members of this group. The list is an java.util.List containing HObjects.
    Returns:
      the list of members of this group.

  - ### breadthFirstMemberList

    public List<HObject> breadthFirstMemberList()
    Returns:
      the members of this Group in breadth-first order.

  - ### depthFirstMemberList

    public List<HObject> depthFirstMemberList()
    Returns:
      the members of this Group in depth-first order.

  - ### setName

    public void setName​(String newName) throws Exception
    Sets the name of the group.

    setName (String newName) changes the name of the group in memory and file.

    setName() updates the path in memory for all the objects that are under the group with the new name.

    Overrides:
      `setName` in class `HObject`
    Parameters:
      `newName` - The new name of the group.
    Throws:
      `Exception` - if the name can not be set

  - ### getParent

    public final Group getParent()
    Returns:
      the parent group.

  - ### isRoot

    public final boolean isRoot()
    Checks if it is a root group.
    Returns:
      true if the group is a root group; otherwise, returns false.

  - ### getNumberOfMembersInFile

    public int getNumberOfMembersInFile()
    Returns the total number of members of this group in file. Current Java applications such as HDFView cannot handle files with large numbers of objects (1,000,000 or more objects) due to JVM memory limitation. The max_members is used so that applications such as HDFView will load up to max_members number of objects. If the number of objects in file is larger than max_members, only max_members are loaded in memory.

    getNumberOfMembersInFile() returns the number of objects in this group. The number of objects in memory is obtained by getMemberList().size().

    Returns:
      Total number of members of this group in the file.

  - ### getMember

    public HObject getMember​(int idx)
    Get the HObject at the specified index in this Group's member list.
    Parameters:
      `idx` - The index of the HObject to get.
    Returns:
      The HObject at the specified index.