Package ucar.nc2
Class Group.Builder
- java.lang.Object
-
- ucar.nc2.Group.Builder
-
-
Field Summary
Fields Modifier and Type Field Description List<EnumTypedef>enumTypedefsList<Group.Builder>gbuildersStringshortNameList<Variable.Builder<?>>vbuilders
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Group.BuilderaddAttribute(Attribute att)Group.BuilderaddAttributes(Iterable<Attribute> atts)Group.BuilderaddDimension(Dimension dim)Add Dimension with error if it already existsbooleanaddDimensionIfNotExists(Dimension dim)Add Dimension if it doesnt already existGroup.BuilderaddDimensions(Collection<Dimension> dims)Add Dimensions with error if any already existGroup.BuilderaddEnumTypedef(EnumTypedef typedef)Group.BuilderaddEnumTypedefs(Collection<EnumTypedef> typedefs)Group.BuilderaddGroup(Group.Builder nested)Add a nested Group.Group.BuilderaddGroups(Collection<Group.Builder> groups)Group.BuilderaddVariable(Variable.Builder<?> variable)Add a Variable, throw error if one of the same name if it exists.Group.BuilderaddVariables(Collection<Variable.Builder<?>> vars)Add Variables, throw error if one of the same name if it exists.Groupbuild()Build the root group, with parent = null.Group.BuildercommonParent(Group.Builder other)Find the common parent with the other group ?booleancontains(Dimension want)Is the Dimension contained within this Group or a parent GroupOptional<Dimension>findDimension(String name)Find Dimension in this Group or a parent GroupOptional<Dimension>findDimensionLocal(String name)Find Dimension local to this GroupOptional<EnumTypedef>findEnumTypedef(String name)Optional<Group.Builder>findGroupLocal(String shortName)Optional<Group.Builder>findGroupNested(String relativeName)Find a subgroup of this Group, with the specified relative name.EnumTypedeffindOrAddEnumTypedef(String name, Map<Integer,String> map)Add a EnumTypedef if it does not already exist.Optional<Variable.Builder<?>>findVariableLocal(String name)Optional<Variable.Builder<?>>findVariableNested(String relativeName)Find a Variable, with the specified relative name.Optional<Variable.Builder<?>>findVariableOrInParent(String varShortName)Find the Variable with the specified (short) name in this group or a parent group.AttributeContainerMutablegetAttributeContainer()Iterable<Dimension>getDimensions()NetcdfFilegetNcfile()Deprecated.Group.BuildergetParentGroup()booleanisParent(Group.Builder other)Is this group a parent of the other group ?voidmakeDimensionMap(Group.Builder parent, com.google.common.collect.Multimap<Dimension,Variable.Builder<?>> dimUsedMap)Make a multimap of Dimensions and all the variables that reference them, in this group and its nested groups.com.google.common.collect.ImmutableList<Dimension>makeDimensionsList(String dimString)Make list of dimensions by looking in this Group or parent groupsStringmakeFullName()Make the full name of the this group.booleanremoveDimension(String name)Remove dimension, if it exists.voidremoveDimensionFromAllGroups(Group.Builder group, Dimension remove)Remove the given dimension from this group and any subgroupsbooleanremoveGroup(String name)Remove group, if it exists.booleanremoveVariable(String name)Remove variable, if it exists.booleanreplaceDimension(Dimension dim)Replace dimension if it exists, else just add it.booleanreplaceVariable(Variable.Builder<?> vb)Replace variable of same name, if it exists, else just add it.Group.BuildersetName(String shortName)Group.BuildersetNcfile(NetcdfFile ncfile)Group.BuildersetParentGroup(Group.Builder parentGroup)
-
-
-
Field Detail
-
gbuilders
public List<Group.Builder> gbuilders
-
vbuilders
public List<Variable.Builder<?>> vbuilders
-
shortName
public String shortName
-
enumTypedefs
public List<EnumTypedef> enumTypedefs
-
-
Method Detail
-
setParentGroup
public Group.Builder setParentGroup(@Nullable Group.Builder parentGroup)
-
getParentGroup
@Nullable public Group.Builder getParentGroup()
-
addAttribute
public Group.Builder addAttribute(Attribute att)
-
addAttributes
public Group.Builder addAttributes(Iterable<Attribute> atts)
-
getAttributeContainer
public AttributeContainerMutable getAttributeContainer()
-
addDimension
public Group.Builder addDimension(Dimension dim)
Add Dimension with error if it already exists
-
addDimensionIfNotExists
public boolean addDimensionIfNotExists(Dimension dim)
Add Dimension if it doesnt already exist
-
addDimensions
public Group.Builder addDimensions(Collection<Dimension> dims)
Add Dimensions with error if any already exist
-
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)
Is the Dimension contained within this Group or a parent Group
-
findDimension
public Optional<Dimension> findDimension(String name)
Find Dimension in this Group or a parent Group
-
addGroup
public Group.Builder addGroup(Group.Builder nested)
Add a nested Group.
-
addGroups
public Group.Builder addGroups(Collection<Group.Builder> groups)
-
removeGroup
public boolean removeGroup(String name)
Remove group, if it exists.- Returns:
- true if there was an existing group of that name
-
findGroupLocal
public Optional<Group.Builder> findGroupLocal(String shortName)
-
findGroupNested
public Optional<Group.Builder> findGroupNested(String relativeName)
Find a subgroup of this Group, with the specified relative name. An embedded "/" separates group names. Can have a leading "/" only if this is the root group.- Parameters:
relativeName- 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 ?
-
commonParent
public Group.Builder commonParent(Group.Builder other)
Find the common parent with the other group ?
-
addEnumTypedef
public Group.Builder addEnumTypedef(EnumTypedef typedef)
-
addEnumTypedefs
public Group.Builder addEnumTypedefs(Collection<EnumTypedef> typedefs)
-
findOrAddEnumTypedef
public EnumTypedef findOrAddEnumTypedef(String name, Map<Integer,String> map)
Add a EnumTypedef if it does not already exist. Return new or existing.
-
findEnumTypedef
public Optional<EnumTypedef> findEnumTypedef(String name)
-
addVariable
public Group.Builder addVariable(Variable.Builder<?> variable)
Add a Variable, throw error if one of the same name if it exists.
-
addVariables
public Group.Builder addVariables(Collection<Variable.Builder<?>> vars)
Add Variables, 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
-
findVariableLocal
public Optional<Variable.Builder<?>> findVariableLocal(String name)
-
findVariableNested
public Optional<Variable.Builder<?>> findVariableNested(String relativeName)
Find a Variable, with the specified relative name. No structure members.- Parameters:
relativeName- eg "group/subgroup/varname".
-
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.
-
setNcfile
public Group.Builder setNcfile(NetcdfFile ncfile)
-
setName
public Group.Builder setName(String shortName)
-
getNcfile
@Deprecated public NetcdfFile getNcfile()
Deprecated.
-
makeDimensionsList
public com.google.common.collect.ImmutableList<Dimension> makeDimensionsList(String dimString) throws IllegalArgumentException
Make list of dimensions by looking in this Group or parent groups- Throws:
IllegalArgumentException
-
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
-
makeDimensionMap
public void makeDimensionMap(Group.Builder parent, com.google.common.collect.Multimap<Dimension,Variable.Builder<?>> dimUsedMap)
Make a multimap of Dimensions and all the variables that reference them, in this group and its nested groups.
-
build
public Group build()
Build the root group, with parent = null.
-
-