ucar.nc2
Class Dimension

java.lang.Object
  extended by ucar.nc2.Dimension
All Implemented Interfaces:
java.lang.Comparable

public class Dimension
extends java.lang.Object
implements java.lang.Comparable

A Dimension is used to define the array shape of a Variable. It 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 has length = -1.

Immutable if setImmutable() was called, except for an Unlimited Dimension, whose size can change.

Author:
caron

Field Summary
static Dimension VLEN
          A variable-length dimension: the length is not known until the data is read.
 
Constructor Summary
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
 
Method Summary
 void addCoordinateVariable(Variable v)
          Deprecated. - do not use
 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.
 java.util.List<Variable> getCoordinateVariables()
          Deprecated. - do not use
 Group getGroup()
          Get the Group that owns this Dimension.
 int getLength()
          Get the length of the Dimension.
 java.lang.String getName()
          Returns the name of this Dimension; may be null.
 int hashCode()
          Override Object.hashCode() to implement equals.
 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.
 void setGroup(Group g)
          Set the group
 Dimension setImmutable()
          Make this immutable.
 void setLength(int n)
          Set the Dimension length.
 void setName(java.lang.String name)
          rename
 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.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

VLEN

public static Dimension VLEN
A variable-length dimension: the length is not known until the data is read.

Constructor Detail

Dimension

public Dimension(java.lang.String name,
                 int length)
Constructor

Parameters:
name - name must be unique within group
length - length of Dimension

Dimension

public Dimension(java.lang.String name,
                 int length,
                 boolean isShared)
Constructor

Parameters:
name - name must be unique within group
length - length, or UNLIMITED.length or UNKNOWN.length
isShared - whether its shared or local to Variable.

Dimension

public Dimension(java.lang.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.length
isShared - whether its shared or local to Variable.
isUnlimited - whether the length can grow.
isVariableLength - whether the length is unknown until the data is read.

Dimension

public Dimension(java.lang.String name,
                 Dimension from)
Copy Constructor. used to make global dimensions

Parameters:
name - name must be unique within group. Can be null only if not shared.
from - copy all other fields from here.
Method Detail

getName

public java.lang.String getName()
Returns the name of this Dimension; may be null. A Dimension with a null name is called "anonymous" and must be private. Dimension names are unique within a Group.

Returns:
name of Dimension, may be null for anonymous dimension

getLength

public int getLength()
Get the length of the Dimension.

Returns:
length of Dimension

isUnlimited

public boolean isUnlimited()
If unlimited, then the length can increase; otherwise it is immutable.

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.

isShared

public boolean isShared()
If this Dimension is shared, or is private to a Variable. All Dimensions in NetcdfFile.getDimensions() or Group.getDimensions() are shared. Dimensions in the Variable.getDimensions() may be shared or private.

Returns:
if its a "shared" Dimension.

getGroup

public Group getGroup()
Get the Group that owns this Dimension.

Returns:
owning group or null if !isShared

equals

public boolean equals(java.lang.Object oo)
Instances which have same contents are equal. Careful!! this is not object identity !!

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Override Object.hashCode() to implement equals.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
CDL representation, not strict.

Overrides:
toString in class java.lang.Object

compareTo

public int compareTo(java.lang.Object o)
Dimensions with the same name are equal.

Specified by:
compareTo in interface java.lang.Comparable
Parameters:
o - compare to this Dimension
Returns:
0, 1, or -1

writeCDL

public java.lang.String writeCDL(boolean strict)
CDL representation.

Parameters:
strict - if true, write in strict adherence to CDL definition.
Returns:
CDL representation.

setUnlimited

public void setUnlimited(boolean b)
Set whether this is unlimited, meaning length can increase.

Parameters:
b - true if unlimited

setVariableLength

public void setVariableLength(boolean b)
Set whether the length is variable.

Parameters:
b - true if variable length

setShared

public void setShared(boolean b)
Set whether this is shared.

Parameters:
b - true if shared

setLength

public void setLength(int n)
Set the Dimension length.

Parameters:
n - length of Dimension

setName

public void setName(java.lang.String name)
rename

Parameters:
name - new name of Dimension.

setGroup

public void setGroup(Group g)
Set the group

Parameters:
g - parent group

setImmutable

public Dimension setImmutable()
Make this immutable.

Returns:
this

addCoordinateVariable

public void addCoordinateVariable(Variable v)
Deprecated. - do not use

Parameters:
v - coord var

getCoordinateVariables

public java.util.List<Variable> getCoordinateVariables()
Deprecated. - do not use

Use Variable cv = ncfile.findVariable(dim.getName()); if ((cv != null) && cv.isCoordinateVariable()) ...

Returns:
an empty list