Package ucar.nc2

Class Group.Builder

  • Enclosing class:
    Group

    public static class Group.Builder
    extends Object
    • Constructor Detail

      • Builder

        public Builder()
    • Method Detail

      • getParentGroup

        @Nullable
        public Group.Builder getParentGroup()
      • addDimension

        public Group.Builder addDimension​(Dimension dim)
        Add Dimension with error if it already exists
      • addDimensionIfNotExists

        public boolean addDimensionIfNotExists​(Dimension dim)
        Add Dimension if one with same name doesnt already exist.
        Returns:
        true if it did not exist and was added.
      • replaceDimension

        public boolean replaceDimension​(Dimension dim)
        Replace dimension if it exists, else just add it.
        Returns:
        true if there was an existing dimension of that name
      • removeDimension

        public boolean removeDimension​(String name)
        Remove dimension, if it exists.
        Returns:
        true if there was an existing dimension of that name
      • findDimensionLocal

        public Optional<Dimension> findDimensionLocal​(String name)
        Find Dimension local to this Group
      • contains

        public boolean contains​(Dimension want)
        Find Dimension in this Group or a parent Group
      • findDimension

        public Optional<Dimension> findDimension​(String name)
        Find Dimension in this Group or a parent Group
      • removeGroup

        public boolean removeGroup​(String name)
        Remove group, if it exists.
        Returns:
        true if there was an existing group of that name
      • findGroupNested

        public Optional<Group.Builder> findGroupNested​(String reletiveName)
        Find a subgroup of this Group, with the specified reletive name. An embedded "/" separates group names. Can have a leading "/" only if this is the root group.
        Parameters:
        reletiveName - eg "group/subgroup/wantGroup".
        Returns:
        Group or empty if not found.
      • isParent

        public boolean isParent​(Group.Builder other)
        Is this group a parent of the other group ?
      • findOrAddEnumTypedef

        public EnumTypedef findOrAddEnumTypedef​(String name,
                                                Map<Integer,​String> map)
        Add a EnumTypedef if it does not already exist. Return new or existing.
      • addVariable

        public Group.Builder addVariable​(Variable.Builder<?> variable)
        Add a Variable, throw error if one of the same name if it exists.
      • replaceVariable

        public boolean replaceVariable​(Variable.Builder<?> vb)
        Replace variable of same name, if it exists, else just add it.
        Returns:
        true if there was an existing variable of that name
      • removeVariable

        public boolean removeVariable​(String name)
        Remove variable, if it exists.
        Returns:
        true if there was an existing variable of that name
      • findVariableNested

        public Optional<Variable.Builder<?>> findVariableNested​(String reletiveName)
        Find a Variable, with the specified reletive name. No structure members.
        Parameters:
        reletiveName - eg "group/subgroup/varname".
      • findVariable

        public Optional<Variable.Builder<?>> findVariable​(String fullNameEscaped)
        Find a Variable, with the specified (escaped full) name. It may possibly be nested in multiple groups and/or structures. An embedded "." is interpreted as structure.member. An embedded "/" is interpreted as group/variable. If the name actually has a ".", you must escape it (call NetcdfFiles.makeValidPathName(varname)) Any other chars may also be escaped, as they are removed before testing.
        Parameters:
        fullNameEscaped - eg "/group/subgroup/name1.name2.name".
        Returns:
        Optional Variable.Builder NetcdfFile.findVariable(String fullNameEscaped)
      • findVariableOrInParent

        public Optional<Variable.Builder<?>> findVariableOrInParent​(String varShortName)
        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 empty.
      • makeFullName

        public String makeFullName()
        Make the full name of the this group. TODO In light of CF groups, we may have to start full names with '/'
      • removeDimensionFromAllGroups

        public void removeDimensionFromAllGroups​(Group.Builder group,
                                                 Dimension remove)
        Remove the given dimension from this group and any subgroups
      • build

        public Group build()
        Build the root group, with parent = null.