Package opendap.dap
Class DVector
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.BaseType
-
- opendap.dap.DVector
-
- All Implemented Interfaces:
Serializable
,Cloneable
,ClientIO
public abstract class DVector extends BaseType implements ClientIO
This class holds a one-dimensional array of OPeNDAP data types. It is the parent of bothDList
andDArray
. This class uses aPrimitiveVector
to hold the data and deserialize it, thus allowing more efficient storage to be used for the primitive types.- See Also:
BaseType
,DArray
,PrimitiveVector
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class opendap.dap.DAPNode
DAPNode.CloneMap
-
-
Field Summary
-
Fields inherited from class opendap.dap.DAPNode
_nameClear, _nameEncoded, log
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addVariable(BaseType v)
Adds a variable to the container.DAPNode
cloneDAG(DAPNode.CloneMap map)
Returns a clone of thisVector
.void
deserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI)
Reads data from aDataInputStream
.void
externalize(DataOutputStream sink)
Writes data to aDataOutputStream
.BaseType
getContainerVar()
int
getLength()
Returns the number of elements in the vector.PrimitiveVector
getPrimitiveVector()
Returns thePrimitiveVector
for this vector.String
getTypeName()
Returns the OPeNDAP type name of the class instance as aString
.void
printDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)
Write the variable's declaration in a C-style syntax.void
printVal(PrintWriter os, String space, boolean print_decl_p)
Prints the value of the variable, with its declaration.void
setContainerVar(BaseType var)
void
setLength(int len)
Sets the number of elements in the vector.-
Methods inherited from class opendap.dap.BaseType
addAttributeAlias, addAttributeContainer, appendAttribute, appendAttribute, appendAttributeContainer, checkSemantics, checkSemantics, delAttribute, delAttribute, elementCount, elementCount, getAttribute, getAttribute, getAttributeNames, getAttributeTable, getLongName, hasAttributes, newPrimitiveVector, printAttributes, printAttributes, printAttributes, printAttributes, printConstraint, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printVal, printVal, printVal, printXML, printXML, printXML, printXML, printXML, setClearName
-
Methods inherited from class opendap.dap.DAPNode
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setEncodedName, setParent, setProject, setProject, setProjected
-
-
-
-
Constructor Detail
-
DVector
public DVector()
Constructs a newDVector
.
-
DVector
public DVector(String n)
Constructs a newDVector
with namen
.- Parameters:
n
- the name of the variable.
-
-
Method Detail
-
getTypeName
public String getTypeName()
Returns the OPeNDAP type name of the class instance as aString
.- Specified by:
getTypeName
in classBaseType
- Returns:
- the OPeNDAP type name of the class instance as a
String
.
-
getContainerVar
public BaseType getContainerVar()
-
setContainerVar
public void setContainerVar(BaseType var)
-
getLength
public int getLength()
Returns the number of elements in the vector.- Returns:
- the number of elements in the vector.
-
setLength
public void setLength(int len)
Sets the number of elements in the vector. Allocates a new array of the desired size. Note that if this is called multiple times, the old array and its contents will be lost! Only called inside ofdeserialize
method or in derived classes on server.- Parameters:
len
- the number of elements in the array.
-
addVariable
public void addVariable(BaseType v)
Adds a variable to the container.- Parameters:
v
- the variable to add.
-
getPrimitiveVector
public PrimitiveVector getPrimitiveVector()
Returns thePrimitiveVector
for this vector. This can be cast to the appropriate type and used by a OPeNDAP client to read or set individual values in the vector.- Returns:
- the attached
PrimitiveVector
.
-
printDecl
public void printDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)
Write the variable's declaration in a C-style syntax. This function is used to create textual representation of the Data Descriptor Structure (DDS). See The OPeNDAP User Manual for information about this structure.- Overrides:
printDecl
in classBaseType
- Parameters:
os
- ThePrintWriter
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.- See Also:
BaseType.printDecl(PrintWriter, String, boolean)
-
printVal
public void printVal(PrintWriter os, String space, boolean print_decl_p)
Prints the value of the variable, with its declaration. This function is primarily intended for debugging OPeNDAP applications and text-based clients such as geturl.- Specified by:
printVal
in classBaseType
- Parameters:
os
- thePrintWriter
on which to print the value.space
- this value is passed to theprintDecl
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.- See Also:
BaseType.printVal(PrintWriter, String, boolean)
-
deserialize
public void deserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI) throws IOException, EOFException, DataReadException
Reads data from aDataInputStream
. This method is only used on the client side of the OPeNDAP client/server connection.- Specified by:
deserialize
in interfaceClientIO
- Parameters:
source
- aDataInputStream
to read from.sv
- theServerVersion
returned by the server.statusUI
- theStatusUI
object to use for GUI updates and user cancellation notification (may be null).- Throws:
EOFException
- if EOF is found before the variable is completely deserialized.IOException
- thrown on any other InputStream exception.DataReadException
- if an unexpected value was read.- See Also:
ClientIO.deserialize(DataInputStream, ServerVersion, StatusUI)
-
externalize
public void externalize(DataOutputStream sink) throws IOException
Writes data to aDataOutputStream
. This method is used primarily by GUI clients which need to download OPeNDAP data, manipulate it, and then re-save it as a binary file.- Specified by:
externalize
in interfaceClientIO
- Parameters:
sink
- aDataOutputStream
to write to.- Throws:
IOException
- thrown on anyOutputStream
exception.
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisVector
. See DAPNode.cloneDag()- Overrides:
cloneDAG
in classBaseType
- Parameters:
map
- track previously cloned nodes- Returns:
- a clone of this object.
- Throws:
CloneNotSupportedException
-
-