Package ucar.nc2
Class Group
java.lang.Object
ucar.nc2.CDMNode
ucar.nc2.Group
- All Implemented Interfaces:
Iterable<Attribute>,AttributeContainer
A logical collection of Variables, Attributes, and Dimensions.
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.
Immutable if setImmutable() was called.
TODO Group will be immutable in 6.
TODO Group will not implement AttributeContainer in 6, use Group.attributes().
TODO Group will not extend CDMNode in 6.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionThe attributes contained by this Group.static Group.Builderbuilder()commonParent(Group other) Get the common parent of this and the other group.booleanInstances which have same name and parent are equal.findAttribute(String name) Find the attribute by name, return null if not existfindAttributeString(String attName, String defaultValue) Find a String-valued Attribute by name (ignore case), return the String value of the Attribute.findDimension(String name) Find a Dimension in this or a parent Group, matching on short name.findDimension(Dimension dim) Find a Dimension in this or a parent Group, using equals.findDimensionLocal(String shortName) Find a Dimension using its (short) name, in this group onlyfindEnumeration(String name) Find a Enumeration in this Group, using its short name.findEnumeration(String name, boolean searchup) Find a Enumeration in this or optionally the parent Groups, using its short name.findGroupLocal(String groupShortName) Retrieve the Group with the specified (short) name.findSimilarEnumTypedef(EnumTypedef template, boolean searchup) Locate an enum type definition that is structurally similar to the template type def.findVariableByAttribute(String attName, String attValue) Look in this Group and in its nested Groups for a Variable with a String valued Attribute with the given name and value.findVariableLocal(String varShortName) Find the Variable with the specified (short) name in this group.findVariableOrInParent(String varShortName) Find the Variable with the specified (short) name in this group or a parent group.Get the shared Dimensions contained directly in this group.com.google.common.collect.ImmutableList<EnumTypedef>Get the enumerations contained directly in this group.Get the full name of this object.com.google.common.collect.ImmutableList<Group>Get the Groups contained directly in this Group.Get String with name and attributes.Get the owning NetcdfFileGet the parent Group, or null if its the root group.Get the Variables contained directly in this group.inthashCode()Override Object.hashCode() to implement equals.booleanIs this a parent of the other Group?booleanisRoot()Is this the root group?com.google.common.collect.ImmutableList<Dimension>makeDimensionsList(String dimString) Create a dimension list using dimension names.Turn into a mutable Builder.toString()Methods inherited from class ucar.nc2.CDMNode
getShortNameMethods inherited from interface ucar.nc2.AttributeContainer
findAttributeDouble, findAttributeIgnoreCase, findAttributeInteger, getName, hasAttribute, hasAttributeIgnoreCase, isEmpty, iteratorMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Method Details
-
isRoot
public boolean isRoot()Is this the root group?- Returns:
- true if root group
-
getVariables
Get the Variables contained directly in this group.- Returns:
- List of type Variable; may be empty, not null. TODO return ImmutableList
-
findVariableLocal
Find the Variable with the specified (short) name in this group.- Parameters:
varShortName- short name of Variable within this group.- Returns:
- the Variable, or null if not found
-
findVariableOrInParent
Find the Variable with the specified (short) name in this group or a parent group.- Parameters:
varShortName- short name of Variable.- Returns:
- the Variable, or null if not found
-
findVariableByAttribute
Look in this Group and in its nested Groups for a Variable with a String valued Attribute with the given name and value.- Parameters:
attName- look for an Attribuite with this name.attValue- look for an Attribuite with this value.- Returns:
- the first Variable that matches, or null if none match.
-
getParentGroup
Get the parent Group, or null if its the root group. Not deprecated. -
getFullName
Get the full name of this object. Certain characters are backslash escaped (see NetcdfFiles.getFullName(Group)) Not deprecated.- Returns:
- full name with backslash escapes
-
getGroups
Get the Groups contained directly in this Group.- Returns:
- List of type Group; may be empty, not null.
-
getNetcdfFile
Get the owning NetcdfFile -
findGroupLocal
Retrieve the Group with the specified (short) name.- Parameters:
groupShortName- short name of the nested group you are looking for.- Returns:
- the Group, or null if not found
-
getDimensions
Get the shared Dimensions contained directly in this group.- Returns:
- List of type Dimension; may be empty, not null. TODO return ImmutableList
-
makeDimensionsList
public com.google.common.collect.ImmutableList<Dimension> makeDimensionsList(String dimString) throws IllegalArgumentException Create a dimension list using dimension names. The dimension is searched for recursively in the parent groups.- Parameters:
dimString- : whitespace separated list of dimension names, or '*' for Dimension.UNKNOWN, or number for anon dimension. null or empty String is a scalar.- Returns:
- list of dimensions, will return ImmutableList<> in version 6
- Throws:
IllegalArgumentException- if cant find dimension or parse error.
-
getEnumTypedefs
Get the enumerations contained directly in this group.- Returns:
- List of type EnumTypedef; may be empty, not null.
-
findDimension
Find a Dimension in this or a parent Group, matching on short name.- Parameters:
name- Dimension name.- Returns:
- the Dimension, or null if not found
-
findDimension
Find a Dimension in this or a parent Group, using equals.- Parameters:
dim- Dimension .- Returns:
- the Dimension, or null if not found
-
findDimensionLocal
Find a Dimension using its (short) name, in this group only- Parameters:
shortName- Dimension name.- Returns:
- the Dimension, or null if not found
-
attributes
The attributes contained by this Group. -
findAttribute
Find the attribute by name, return null if not exist- Specified by:
findAttributein interfaceAttributeContainer
-
findAttributeString
Find a String-valued Attribute by name (ignore case), return the String value of the Attribute.- Specified by:
findAttributeStringin interfaceAttributeContainer- Returns:
- the attribute value, or defaultValue if not found
-
findEnumeration
Find a Enumeration in this Group, using its short name. -
findEnumeration
Find a Enumeration in this or optionally the parent Groups, using its short name. -
findSimilarEnumTypedef
Locate an enum type definition that is structurally similar to the template type def. The Enum names are ignored.- Parameters:
template- match this enum type defsearchup- if true, then search this group and then parent groups.
-
commonParent
Get the common parent of this and the other group. Cant fail, since the root group is always a parent of any 2 groups.- Parameters:
other- the other group- Returns:
- common parent of this and the other group
-
isParent
Is this a parent of the other Group?- Parameters:
other- another Group- Returns:
- true is it is equal or a parent
-
getNameAndAttributes
Get String with name and attributes. Used in short descriptions like tooltips.- Returns:
- name and attributes String.
-
toString
-
equals
Instances which have same name and parent are equal. -
hashCode
public int hashCode()Override Object.hashCode() to implement equals. -
toBuilder
Turn into a mutable Builder. Can use toBuilder().build() to copy. -
builder
-