public class DArray extends DVector
DArray
is used as part of the DGrid
class,
where the dimension names are crucial to its structure. The dimension names
correspond to "Map" vectors, holding the actual values for that column of
the array.
Each array dimension carries with it its own projection information. The
projection inforamtion takes the form of three integers: the start, stop,
and stride values. This is clearest with an example. Consider a
one-dimensional array 10 elements long. If the start value of the
dimension constraint is 3, then the constrained array appears to be seven
elements long. If the stop value is changed to 7, then the array appears
to be five elements long. If the stride is changed to two, the array will
appear to be 3 elements long. Array constraints are written as
[start:stride:stop]
.
A = [1 2 3 4 5 6 7 8 9 10]
A[3::] = [4 5 6 7 8 9 10]
A[3::7] = [4 5 6 7 8]
A[3:2:7] = [4 6 8]
A[0:3:9] = [1 4 7 10]
NB: OPeNDAP uses zero-based indexing.DGrid
,
DVector
,
BaseType
,
Serialized FormDAPNode.CloneMap
Modifier and Type | Field and Description |
---|---|
protected java.util.Vector<DArrayDimension> |
dimVector
A Vector of DArrayDimension information (i.e.
|
_nameClear, _nameEncoded, log
Constructor and Description |
---|
DArray()
Constructs a new
DArray . |
DArray(java.lang.String n)
Constructs a new
DArray with name n . |
Modifier and Type | Method and Description |
---|---|
void |
appendDim(int size)
Add a dimension to the array.
|
void |
appendDim(int size,
java.lang.String name)
Given a size and a name, this function adds a dimension to the
array.
|
void |
checkSemantics(boolean all)
Checks for internal consistency.
|
DAPNode |
cloneDAG(DAPNode.CloneMap map)
Returns a clone of this
Array . |
DArrayDimension |
getDimension(int dimension)
Returns the
DArrayDimension object for
the dimension requested. |
java.util.Enumeration |
getDimensions()
Returns an
Enumeration of DArrayDimension s
in this array. |
DArrayDimension |
getFirstDimension()
Returns the
DArrayDimension object for
the first dimension. |
java.lang.String |
getTypeName()
Returns the OPeNDAP type name of the class instance as a
String . |
int |
numDimensions()
Returns the number of dimensions in this array.
|
void |
printAsMapXML(java.io.PrintWriter pw,
java.lang.String pad,
boolean constrained) |
void |
printConstraint(java.io.PrintWriter os) |
void |
printDecl(java.io.PrintWriter os,
java.lang.String space,
boolean print_semi,
boolean constrained)
Write the variable's declaration in a C-style syntax.
|
void |
printVal(java.io.PrintWriter pw,
java.lang.String space,
boolean print_decl_p)
Prints the value of the variable, with its declaration.
|
void |
printXML(java.io.PrintWriter pw,
java.lang.String pad,
boolean constrained) |
void |
squeeze()
Use this method to "squeeze" out all of the array dimensions whose
size is equal to 1.
|
addVariable, deserialize, externalize, getContainerVar, getLength, getPrimitiveVector, setContainerVar, setLength
addAttributeAlias, addAttributeContainer, appendAttribute, appendAttribute, appendAttributeContainer, checkSemantics, delAttribute, delAttribute, elementCount, elementCount, getAttribute, getAttribute, getAttributeNames, getAttributeTable, getLongName, hasAttributes, newPrimitiveVector, printAttributes, printAttributes, printAttributes, printAttributes, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printVal, printVal, printVal, printXML, printXML, printXML, printXML, setClearName
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setEncodedName, setParent, setProject, setProject, setProjected
protected java.util.Vector<DArrayDimension> dimVector
public DArray()
DArray
.public DArray(java.lang.String n)
DArray
with name n
.n
- the name of the variable.public java.lang.String getTypeName()
String
.getTypeName
in class DVector
String
.public void checkSemantics(boolean all) throws BadSemanticsException
DArray
, verify that
the dimension vector is not empty.checkSemantics
in class BaseType
all
- for complex constructor types, this flag indicates whether to
check the semantics of the member variables, too.BadSemanticsException
- if semantics are bad, explains why.BaseType.checkSemantics(boolean)
public void printDecl(java.io.PrintWriter os, java.lang.String space, boolean print_semi, boolean constrained)
printDecl
in class DVector
os
- The PrintWriter
on which to print the
declaration.space
- Each line of the declaration will begin with the
characters in this string. Usually used for leading spaces.print_semi
- a boolean value indicating whether to print a
semicolon at the end of the declaration.constrained
- a boolean value indicating whether to print
the declartion dependent on the projection information. This
is only used by Server side code.BaseType.printDecl(PrintWriter, String, boolean)
public void printVal(java.io.PrintWriter pw, java.lang.String space, boolean print_decl_p)
printVal
in class DVector
pw
- the PrintWriter
on which to print the value.space
- this value is passed to the printDecl
method,
and controls the leading spaces of the output.print_decl_p
- a boolean value controlling whether the
variable declaration is printed as well as the value.BaseType.printVal(PrintWriter, String, boolean)
public void appendDim(int size, java.lang.String name)
DArray
is already 10 elements
long, calling appendDim
with a size of 5 will transform the
array into a 10x5 matrix. Calling it again with a size of 2 will
create a 10x5x2 array, and so on.size
- the size of the desired new dimension.name
- the name of the new dimension.public void appendDim(int size)
appendDim(size, null)
.size
- the size of the desired new dimension.appendDim(int, String)
public final java.util.Enumeration getDimensions()
Enumeration
of DArrayDimension
s
in this array.Enumeration
of DArrayDimension
s
in this array.public final int numDimensions()
public void squeeze()
public DArrayDimension getDimension(int dimension) throws InvalidDimensionException
DArrayDimension
object for
the dimension requested. It makes sure that the dimension requested
exists.InvalidDimensionException
public DArrayDimension getFirstDimension()
DArrayDimension
object for
the first dimension.public void printXML(java.io.PrintWriter pw, java.lang.String pad, boolean constrained)
public void printAsMapXML(java.io.PrintWriter pw, java.lang.String pad, boolean constrained)
pw
- pad
- constrained
- public void printConstraint(java.io.PrintWriter os)
printConstraint
in class BaseType
public DAPNode cloneDAG(DAPNode.CloneMap map) throws java.lang.CloneNotSupportedException
Array
.
See DAPNode.cloneDag()