public class Dimension extends CDMNode implements java.lang.Comparable
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.
Modifier and Type | Field and Description |
---|---|
static Dimension |
VLEN
A variable-length dimension: the length is not known until the data is read.
|
annotations, dodsname, group, immutable, parentstruct, shortName, sort
Constructor and Description |
---|
Dimension(java.lang.String name,
Dimension from)
Copy Constructor.
|
Dimension(java.lang.String name,
int length)
Constructor
|
Dimension(java.lang.String name,
int length,
boolean isShared)
Constructor
|
Dimension(java.lang.String name,
int length,
boolean isShared,
boolean isUnlimited,
boolean isVariableLength)
Constructor
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(java.lang.Object o)
Dimensions with the same name are equal.
|
boolean |
equals(java.lang.Object oo)
Instances which have same contents are equal.
|
Group |
getGroup()
Get the Group that owns this Dimension.
|
int |
getLength()
Get the length of the Dimension.
|
int |
hashCode()
Override Object.hashCode() to implement equals.
|
void |
hashCodeShow(Indent indent) |
boolean |
isShared()
If this Dimension is shared, or is private to a Variable.
|
boolean |
isUnlimited()
If unlimited, then the length can increase; otherwise it is immutable.
|
boolean |
isVariableLength()
If variable length, then the length is unknown until the data is read.
|
static java.util.List<Dimension> |
makeDimensionsAnon(int[] shape) |
static java.util.List<Dimension> |
makeDimensionsList(Group parentGroup,
java.lang.String dimString)
Create a dimension list using the dimensions names.
|
static java.lang.String |
makeDimensionsString(java.util.List<Dimension> dimensions)
Make a space-delineated String from a list of Dimension names.
|
java.lang.String |
makeFullName() |
void |
setGroup(Group g)
Set the group
|
Dimension |
setImmutable()
Make this immutable.
|
void |
setLength(int n)
Set the Dimension length.
|
java.lang.String |
setName(java.lang.String name)
Set the name, converting to valid CDM object name if needed.
|
void |
setShared(boolean b)
Set whether this is shared.
|
void |
setUnlimited(boolean b)
Set whether this is unlimited, meaning length can increase.
|
void |
setVariableLength(boolean b)
Set whether the length is variable.
|
java.lang.String |
toString()
CDL representation, not strict.
|
java.lang.String |
writeCDL(boolean strict)
CDL representation.
|
protected void |
writeCDL(java.util.Formatter out,
Indent indent,
boolean strict) |
annotate, getAnnotation, getAnnotations, getDODSName, getFullName, getFullNameEscaped, getImmutable, getName, getParentGroup, getParentStructure, getShortName, getSort, isMemberOfStructure, localhash, setDODSName, setImmutable, setParentGroup, setParentStructure, setShortName, setSort, unwrap
public static Dimension VLEN
public Dimension(java.lang.String name, int length)
name
- name must be unique within grouplength
- length of Dimensionpublic Dimension(java.lang.String name, int length, boolean isShared)
name
- name must be unique within grouplength
- length, or UNLIMITED.length or UNKNOWN.lengthisShared
- whether its shared or local to Variable.public Dimension(java.lang.String name, int length, boolean isShared, boolean isUnlimited, boolean isVariableLength)
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.public Dimension(java.lang.String name, Dimension from)
name
- name must be unique within group. Can be null only if not shared.from
- copy all other fields from here.public static java.lang.String makeDimensionsString(java.util.List<Dimension> dimensions)
public static java.util.List<Dimension> makeDimensionsList(Group parentGroup, java.lang.String dimString) throws java.lang.IllegalArgumentException
parentGroup
- containing group, may not be nulldimString
- : whitespace separated list of dimension names, or '*' for Dimension.UNKNOWN, or number for anon dimension. null or empty String is a scalar.java.lang.IllegalArgumentException
- if cant find dimension or parse error.public static java.util.List<Dimension> makeDimensionsAnon(int[] shape)
public int getLength()
public boolean isUnlimited()
public boolean isVariableLength()
public boolean isShared()
public Group getGroup()
public java.lang.String makeFullName()
public boolean equals(java.lang.Object oo)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void hashCodeShow(Indent indent)
hashCodeShow
in class CDMNode
public java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
- compare to this Dimensionpublic java.lang.String writeCDL(boolean strict)
strict
- if true, write in strict adherence to CDL definition.protected void writeCDL(java.util.Formatter out, Indent indent, boolean strict)
public void setUnlimited(boolean b)
b
- true if unlimitedpublic void setVariableLength(boolean b)
b
- true if variable lengthpublic void setShared(boolean b)
b
- true if sharedpublic void setLength(int n)
n
- length of Dimensionpublic java.lang.String setName(java.lang.String name)
name
- set to this valuepublic void setGroup(Group g)
g
- parent grouppublic Dimension setImmutable()