ncsa.hdf.object.h4.H4Group Maven / Gradle / Ivy
Show all versions of hdf-java Show documentation
/*****************************************************************************
* Copyright by The HDF Group. *
* Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of the HDF Java Products distribution. *
* The full copyright notice, including terms governing use, modification, *
* and redistribution, is contained in the files COPYING and Copyright.html. *
* COPYING can be found at the root of the source code distribution tree. *
* Or, see http://hdfgroup.org/products/hdf-java/doc/Copyright.html. *
* If you do not have access to either file, you may request a copy from *
* [email protected]. *
****************************************************************************/
package ncsa.hdf.object.h4;
import java.util.*;
import ncsa.hdf.hdflib.*;
import ncsa.hdf.object.*;
/**
* An H4Group is a vgroup in HDF4, inheriting from Group.
* A vgroup is a structure designed to associate related data objects. The
* general structure of a vgroup is similar to that of the UNIX file system in
* that the vgroup may contain references to other vgroups or HDF data objects
* just as the UNIX directory may contain subdirectories or files.
*
* @version 1.1 9/4/2007
* @author Peter X. Cao
*/
public class H4Group extends Group
{
public static final long serialVersionUID = HObject.serialVersionUID;
/**
* The list of attributes of this data object. Members of the list are
* instance of Attribute.
*/
private List attributeList;
private int nAttributes = -1;
/** The default object ID for HDF4 objects */
private final static long[] DEFAULT_OID = {0, 0};
public H4Group(FileFormat theFile, String name, String path, Group parent)
{
this(theFile, name, path, parent, null);
}
/**
* Creates a group object with specific name, path, and parent.
*
* @param theFile the HDF file.
* @param name the name of this group.
* @param path the full path of this group.
* @param parent the parent of this group.
* @param oid the unique identifier of this data object.
*/
public H4Group(
FileFormat theFile,
String name,
String path,
Group parent,
long[] oid)
{
super (theFile, name, path, parent, ((oid == null) ? DEFAULT_OID : oid));
}
/*
* (non-Javadoc)
* @see ncsa.hdf.object.DataFormat#hasAttribute()
*/
public boolean hasAttribute ()
{
if (nAttributes < 0) {
int vgid = open();
try {
nAttributes =HDFLibrary.Vnattrs(vgid);
nMembersInFile = HDFLibrary.Vntagrefs(vgid);
} catch (Exception ex) {nAttributes = 0;}
close(vgid);
}
return (nAttributes>0);
}
// Implementing DataFormat
public List getMetadata() throws HDFException
{
if (attributeList != null)
{
return attributeList;
} else {
attributeList = new Vector();
}
int vgid = open();
if (vgid <= 0) {
return attributeList;
}
int n = -1;
try {
n = HDFLibrary.Vnattrs(vgid);
boolean b = false;
String[] attrName = new String[1];
int[] attrInfo = new int[3];
for (int i=0; i