Package ucar.nc2
Class Dimension
java.lang.Object
ucar.nc2.CDMNode
ucar.nc2.Dimension
- All Implemented Interfaces:
Comparable<Dimension>
A Dimension is used to define the array shape of a Variable.
A Variable can be thought of as a sampled function with Domain its Dimensions.
A Dimension may be shared among Variables, which provides a simple yet powerful way of associating Variables.
When a Dimension is shared, it has a unique name within its Group.
It may have a coordinate Variable, which gives each index a coordinate value.
A private Dimension cannot have a coordinate Variable, so use shared dimensions with coordinates when possible.
The Dimension length must be > 0, except for an unlimited dimension which may have length = 0, and a vlen
Dimension which has a length known only when the variable is read.
Immutable if setImmutable() was called, except for an Unlimited Dimension, whose size can change.
Note: this class has a natural ordering that is inconsistent with equals. TODO Dimension will be immutable in 6. TODO Dimension will not extend CDMNode in 6. TODO Dimension will not have a reference to its owning Group in 6. TODO Dimension.getFullName() will not exist in 6.
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Dimension.Builderbuilder()static Dimension.BuilderA builder with the Dimension name and length setintDimensions with the same name are equal.booleanintGet the length of the Dimension.getName()Get the name of the Dimension.Get the name of the Dimension.inthashCode()Override Object.hashCode() to implement equals.booleanisShared()If this Dimension is shared, or is private to a Variable.booleanIf this is a NetCDF unlimited dimension.booleanIf variable length, then the length is unknown until the data is read.Turn into a mutable Builder, use toBuilder().build() to make a copy.toString()
-
Field Details
-
VLEN
A variable-length dimension: the length is not known until the data is read.
-
-
Constructor Details
-
Dimension
Constructor- Parameters:
name- name must be unique within grouplength- length of Dimension
-
Dimension
public Dimension(String name, int length, boolean isShared, boolean isUnlimited, boolean isVariableLength) Constructor- Parameters:
name- name must be unique within group. Can be null only if not shared.length- length, or UNLIMITED.length or UNKNOWN.lengthisShared- whether its shared or local to Variable.isUnlimited- whether the length can grow.isVariableLength- whether the length is unknown until the data is read.
-
-
Method Details
-
toBuilder
Turn into a mutable Builder, use toBuilder().build() to make a copy. -
getLength
public int getLength()Get the length of the Dimension. -
getName
Get the name of the Dimension. Same as getShortName. Not deprecated. -
getShortName
Get the name of the Dimension.- Overrides:
getShortNamein classucar.nc2.CDMNode
-
isUnlimited
public boolean isUnlimited()If this is a NetCDF unlimited dimension. The length might increase between invocations, but it remains fixed for the lifetime of the NetcdfFile. If you modify the file in a separate process, you must close and reopen the file.- Returns:
- if its an "unlimited" Dimension
-
isVariableLength
public boolean isVariableLength()If variable length, then the length is unknown until the data is read.- Returns:
- if its a "variable length" Dimension.
-
equals
-
hashCode
public int hashCode()Override Object.hashCode() to implement equals. -
toString
-
compareTo
Dimensions with the same name are equal. This method is inconsistent with equals()!- Specified by:
compareToin interfaceComparable<Dimension>- Parameters:
odim- compare to this Dimension- Returns:
- 0, 1, or -1
-
builder
-
builder
A builder with the Dimension name and length set
-