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 bothDListandDArray. This class uses aPrimitiveVectorto 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 voidaddVariable(BaseType v)Adds a variable to the container.DAPNodecloneDAG(DAPNode.CloneMap map)Returns a clone of thisVector.voiddeserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI)Reads data from aDataInputStream.voidexternalize(DataOutputStream sink)Writes data to aDataOutputStream.BaseTypegetContainerVar()intgetLength()Returns the number of elements in the vector.PrimitiveVectorgetPrimitiveVector()Returns thePrimitiveVectorfor this vector.StringgetTypeName()Returns the OPeNDAP type name of the class instance as aString.voidprintDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)Write the variable's declaration in a C-style syntax.voidprintVal(PrintWriter os, String space, boolean print_decl_p)Prints the value of the variable, with its declaration.voidsetContainerVar(BaseType var)voidsetLength(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 newDVectorwith 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:
getTypeNamein 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 ofdeserializemethod 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 thePrimitiveVectorfor 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:
printDeclin classBaseType- Parameters:
os- ThePrintWriteron 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:
printValin classBaseType- Parameters:
os- thePrintWriteron which to print the value.space- this value is passed to theprintDeclmethod, 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:
deserializein interfaceClientIO- Parameters:
source- aDataInputStreamto read from.sv- theServerVersionreturned by the server.statusUI- theStatusUIobject 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:
externalizein interfaceClientIO- Parameters:
sink- aDataOutputStreamto write to.- Throws:
IOException- thrown on anyOutputStreamexception.
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisVector. See DAPNode.cloneDag()- Overrides:
cloneDAGin classBaseType- Parameters:
map- track previously cloned nodes- Returns:
- a clone of this object.
- Throws:
CloneNotSupportedException
-
-