Package ucar.nc2

Class Group


  • @Immutable
    public class Group
    extends Object
    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.
    • Method Detail

      • attributes

        public AttributeContainer attributes()
        The attributes contained by this Group.
      • commonParent

        public Group commonParent​(Group other)
        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
      • findAttribute

        @Nullable
        public Attribute findAttribute​(String name)
        Find the attribute by name, or null if not exist
      • findAttributeString

        public String findAttributeString​(String attName,
                                          String defaultValue)
        Find a String-valued Attribute by name (ignore case), return the String value of the Attribute.
        Returns:
        the attribute value, or defaultValue if not found
      • findDimension

        public Optional<Dimension> findDimension​(String name)
        Find a Dimension in this or a parent Group, matching on short name
      • findDimension

        @Nullable
        public Dimension findDimension​(Dimension dim)
        Find a Dimension in this or a parent Group, using equals, or null if not found
      • findDimensionLocal

        @Nullable
        public Dimension findDimensionLocal​(String shortName)
        Find a Dimension using its (short) name, in this group only, or null if not found
      • findEnumeration

        @Nullable
        public EnumTypedef findEnumeration​(String name)
        Find a Enumeration in this or a parent Group, using its short name.
      • findGroupLocal

        @Nullable
        public Group findGroupLocal​(String groupShortName)
        Retrieve the local Group with the specified (short) name. Must be contained in this Group.
        Parameters:
        groupShortName - short name of the local group you are looking for.
        Returns:
        the Group, or null if not found
      • findGroupNested

        public Optional<Group> findGroupNested​(String groupShortName)
        Retrieve the nested Group with the specified (short) name. May be any level of nesting.
        Parameters:
        groupShortName - short name of the nested group you are looking for.
      • findVariableByAttribute

        @Nullable
        public Variable 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.
        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.
      • findVariableLocal

        @Nullable
        public Variable findVariableLocal​(String varShortName)
        Find the Variable with the specified (short) name in this group, or null if not found
      • findVariableOrInParent

        @Nullable
        public Variable findVariableOrInParent​(String varShortName)
        Find the Variable with the specified (short) name in this group or a parent group, or null if not found
      • getDimensions

        public List<Dimension> getDimensions()
        Get the shared Dimensions contained directly in this group.
      • getEnumTypedefs

        public List<EnumTypedef> getEnumTypedefs()
        Get the enumerations contained directly in this group.
      • getFullName

        public String getFullName()
        Get the full name of this Group. Certain characters are backslash escaped (see NetcdfFiles.makeFullName(Group))
        Returns:
        full name with backslash escapes
      • getGroups

        public List<Group> getGroups()
        Get the Groups contained directly in this Group.
      • getNetcdfFile

        public NetcdfFile getNetcdfFile()
        Get the NetcdfFile that owns this Group.
      • getParentGroup

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

        public String getShortName()
        Get the short name of the Group.
      • getVariables

        public List<Variable> getVariables()
        Get the Variables contained directly in this group.
      • isParent

        public boolean isParent​(Group other)
        Is this a parent of the other Group?
        Parameters:
        other - another Group
        Returns:
        true is it is equal or a parent
      • isRoot

        public boolean isRoot()
        Is this the root group?
      • makeDimensionsList

        public List<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 anonomous dimension. null or empty String is a scalar.
        Returns:
        list of dimensions.
        Throws:
        IllegalArgumentException - if cant find dimension or parse error.
      • getNameAndAttributes

        public String getNameAndAttributes()
        Get String with name and attributes. Used in short descriptions like tooltips.
        Returns:
        name and attributes String.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toBuilder

        public Group.Builder toBuilder()
        Turn into a mutable Builder. Can use toBuilder().build() to copy.