ucar.nc2
Class Group

java.lang.Object
  extended by ucar.nc2.Group

public class Group
extends java.lang.Object

A Group is a logical collection of Variables. The Groups in a Dataset form a hierarchical tree, like directories on a disk. A Group has a name and optionally a set of Attributes. There is always at least one Group in a dataset, the root Group, whose name is the empty string.

Version:
$Revision:51 $ $Date:2006-07-12 17:13:13Z $
Author:
caron

Field Summary
protected  java.util.ArrayList attributes
           
protected  java.util.ArrayList dimensions
           
protected  java.util.ArrayList groups
           
protected  java.lang.String name
           
protected  NetcdfFile ncfile
           
protected  Group parent
           
protected  java.lang.String shortName
           
protected  java.util.ArrayList variables
           
 
Constructor Summary
Group(NetcdfFile ncfile, Group parent, java.lang.String shortName)
          Constructor
 
Method Summary
 void addAttribute(Attribute att)
          Add new Attribute; replace old if has same name.
 void addDimension(Dimension d)
          Add a shared Dimension
 void addGroup(Group g)
          Add a nested Group
 void addVariable(Variable v)
          Add a Variable
 boolean equals(java.lang.Object oo)
          Instances which have same content are equal.
 Attribute findAttribute(java.lang.String name)
          Find an Attribute in this Group by its name.
 Attribute findAttributeIgnoreCase(java.lang.String name)
          Find an Attribute in this Group by its name, ignore case.
 Dimension findDimension(java.lang.String name)
          Retrieve a Dimension using its (short) name.
 Dimension findDimensionLocal(java.lang.String name)
          Retrieve a Dimension using its (short) name, in this group only
 Group findGroup(java.lang.String shortName)
          Retrieve the Group with the specified (short) name.
 Variable findVariable(java.lang.String shortName)
          Find the Variable with the specified (short) name in this group.
 Variable findVariableRecurse(java.lang.String shortName)
          Find the Variable with the specified (short) name in this group or a parent group.
 java.util.List getAttributes()
          Get the set of attributes contained directly in this Group.
 java.util.List getDimensions()
          Get the Dimensions contained directly in this group.
 java.util.List getGroups()
          Get the Groups contained directly in this Group.
 java.lang.String getName()
          Get the full name, starting from the root Group.
 java.lang.String getNameAndAttributes()
          Get String with name and attributes.
 Group getParentGroup()
          Get its parent Group, or null if its the root group.
 java.lang.String getShortName()
          Get the "short" name, unique within its parent Group.
 java.util.List getVariables()
          Get the Variables contained directly in this group.
 int hashCode()
          Override Object.hashCode() to implement equals.
 boolean remove(Attribute a)
          Remove an Attribute : uses the attribute hashCode to find it.
 boolean remove(Dimension d)
          Remove an Dimension : uses the dimension hashCode to find it.
 boolean remove(Group g)
          Remove an Attribute : uses the attribute hashCode to find it.
 boolean remove(Variable v)
          Remove a Variable : uses the variable hashCode to find it.
 boolean removeDimension(java.lang.String dimName)
          remove a Dimension using its name, in this group only
 boolean removeVariable(java.lang.String varName)
          remove a Variable using its (short) name, in this group only
 void setName(java.lang.String name)
          Set the Group name
protected  void toString(java.io.PrintStream out, java.lang.String indent)
           
protected  void writeCDL(java.io.PrintStream out, java.lang.String indent, boolean strict)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ncfile

protected NetcdfFile ncfile

parent

protected Group parent

name

protected java.lang.String name

shortName

protected java.lang.String shortName

variables

protected java.util.ArrayList variables

dimensions

protected java.util.ArrayList dimensions

groups

protected java.util.ArrayList groups

attributes

protected java.util.ArrayList attributes
Constructor Detail

Group

public Group(NetcdfFile ncfile,
             Group parent,
             java.lang.String shortName)
Constructor

Method Detail

getName

public java.lang.String getName()
Get the full name, starting from the root Group.


getShortName

public java.lang.String getShortName()
Get the "short" name, unique within its parent Group.


getParentGroup

public Group getParentGroup()
Get its parent Group, or null if its the root group.


getVariables

public java.util.List getVariables()
Get the Variables contained directly in this group.

Returns:
List of type Variable; may be empty, not null.

findVariable

public Variable findVariable(java.lang.String shortName)
Find the Variable with the specified (short) name in this group.

Parameters:
shortName - short name of Variable within this group.
Returns:
the Variable, or null if not found

findVariableRecurse

public Variable findVariableRecurse(java.lang.String shortName)
Find the Variable with the specified (short) name in this group or a parent group.

Parameters:
shortName - short name of Variable.
Returns:
the Variable, or null if not found

getGroups

public java.util.List getGroups()
Get the Groups contained directly in this Group.

Returns:
List of type Group; may be empty, not null.

findGroup

public Group findGroup(java.lang.String shortName)
Retrieve the Group with the specified (short) name.

Parameters:
shortName - short name of the nested group you are looking for.
Returns:
the Group, or null if not found

getDimensions

public java.util.List getDimensions()
Get the Dimensions contained directly in this group.

Returns:
List of type Dimension; may be empty, not null.

findDimension

public Dimension findDimension(java.lang.String name)
Retrieve a Dimension using its (short) name. If it doesnt exist in this group, recursively look in parent groups.

Parameters:
name - Dimension name.
Returns:
the Dimension, or null if not found

findDimensionLocal

public Dimension findDimensionLocal(java.lang.String name)
Retrieve a Dimension using its (short) name, in this group only

Parameters:
name - Dimension name.
Returns:
the Dimension, or null if not found

removeDimension

public boolean removeDimension(java.lang.String dimName)
remove a Dimension using its name, in this group only

Parameters:
dimName - Dimension name.
Returns:
true if dimension found and removed

removeVariable

public boolean removeVariable(java.lang.String varName)
remove a Variable using its (short) name, in this group only

Parameters:
varName - Variable name.
Returns:
true if Variable found and removed

getAttributes

public java.util.List getAttributes()
Get the set of attributes contained directly in this Group.

Returns:
List of type Attribute; may be empty, not null.

findAttribute

public Attribute findAttribute(java.lang.String name)
Find an Attribute in this Group by its name.

Parameters:
name - the name of the attribute
Returns:
the attribute, or null if not found

findAttributeIgnoreCase

public Attribute findAttributeIgnoreCase(java.lang.String name)
Find an Attribute in this Group by its name, ignore case.

Parameters:
name - the name of the attribute
Returns:
the attribute, or null if not found

getNameAndAttributes

public java.lang.String getNameAndAttributes()
Get String with name and attributes. Used in short descriptions like tooltips.


toString

protected void toString(java.io.PrintStream out,
                        java.lang.String indent)

writeCDL

protected void writeCDL(java.io.PrintStream out,
                        java.lang.String indent,
                        boolean strict)

setName

public void setName(java.lang.String name)
Set the Group name


addAttribute

public void addAttribute(Attribute att)
Add new Attribute; replace old if has same name.


addDimension

public void addDimension(Dimension d)
Add a shared Dimension


addGroup

public void addGroup(Group g)
Add a nested Group


addVariable

public void addVariable(Variable v)
Add a Variable


remove

public boolean remove(Attribute a)
Remove an Attribute : uses the attribute hashCode to find it.

Returns:
true if was found and removed

remove

public boolean remove(Dimension d)
Remove an Dimension : uses the dimension hashCode to find it.

Returns:
true if was found and removed

remove

public boolean remove(Group g)
Remove an Attribute : uses the attribute hashCode to find it.

Returns:
true if was found and removed

remove

public boolean remove(Variable v)
Remove a Variable : uses the variable hashCode to find it.

Returns:
true if was found and removed

equals

public boolean equals(java.lang.Object oo)
Instances which have same content are equal.

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Override Object.hashCode() to implement equals.

Overrides:
hashCode in class java.lang.Object