Package opendap.dap
Class PrimitiveVector
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.PrimitiveVector
-
- All Implemented Interfaces:
Serializable
,Cloneable
,ClientIO
- Direct Known Subclasses:
BaseTypePrimitiveVector
,BooleanPrimitiveVector
,BytePrimitiveVector
,Float32PrimitiveVector
,Float64PrimitiveVector
,Int16PrimitiveVector
,Int32PrimitiveVector
public abstract class PrimitiveVector extends DAPNode implements ClientIO
A helper class forDVector
. It allowsDVector
, and by extension,DArray
andDList
, to use more efficient primitive types to hold large arrays of data. APrimitiveVector
class is defined for each primitive type supported in OPeNDAP, and aBaseTypePrimitiveVector
class handlesDArray
s andDList
s of compound types.- See Also:
BaseType
,DVector
, 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
-
-
Constructor Summary
Constructors Constructor Description PrimitiveVector(BaseType var)
Constructs a newPrimitiveVector
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description DAPNode
cloneDAG(DAPNode.CloneMap map)
Returns a clone of thisPrimitiveVector
.abstract void
deserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI)
Reads data from aDataInputStream
.abstract void
externalize(DataOutputStream sink)
Writes data to aDataOutputStream
.abstract Object
getInternalStorage()
Returns (a reference to) the internal storage for PrimitiveVector.abstract int
getLength()
Returns the number of elements in the array.BaseType
getTemplate()
Returns the template variable 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)
Write the variable's declaration in a C-style syntax.void
printDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)
Write the variable's declaration in a C-style syntax.abstract void
printSingleVal(PrintWriter os, int index)
Prints the value of a single variable in this vector.abstract void
printVal(PrintWriter os, String space)
Prints the value of all variables in this vector.abstract void
setInternalStorage(Object o)
Set the internal storage for PrimitiveVector.abstract void
setLength(int len)
Sets the number of elements in the array.abstract PrimitiveVector
subset(int start, int stop, int stride)
Create a new primitive vector using a subset of the data.-
Methods inherited from class opendap.dap.DAPNode
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setClearName, setEncodedName, setParent, setProject, setProject, setProjected
-
-
-
-
Constructor Detail
-
PrimitiveVector
public PrimitiveVector(BaseType var)
Constructs a newPrimitiveVector
.- Parameters:
var
- the templateBaseType
to use.
-
-
Method Detail
-
getTemplate
public final BaseType getTemplate()
Returns the template variable for this vector.- Returns:
- the template variable for this vector.
- See Also:
BaseTypePrimitiveVector.deserialize(DataInputStream, ServerVersion, StatusUI)
-
getLength
public abstract int getLength()
Returns the number of elements in the array.- Returns:
- the number of elements in the array.
-
setLength
public abstract void setLength(int len)
Sets the number of elements in the array. Allocates a new primitive 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.
-
deserialize
public abstract 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. (used byDSequence
to determine which protocol version was used).statusUI
- TheStatusUI
object to use for GUI updates and user cancellation notification (may be null).- Throws:
DataReadException
- when invalid data is read, or if the user cancels the download.EOFException
- if EOF is found before the variable is completely deserialized.IOException
- thrown on any other InputStream exception.- See Also:
ClientIO.deserialize(DataInputStream, ServerVersion, StatusUI)
-
externalize
public abstract 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.
-
printDecl
public final void printDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)
Write the variable's declaration in a C-style syntax. This method is used to create textual representation of the Data Descriptor Structure (DDS).- 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, boolean)
-
printDecl
public final void printDecl(PrintWriter os, String space, boolean print_semi)
Write the variable's declaration in a C-style syntax. This method is used to create textual representation of the Data Descriptor Structure (DDS).- 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.- See Also:
BaseType.printDecl(PrintWriter, String, boolean)
-
getTypeName
public String getTypeName()
Returns the OPeNDAP type name of the class instance as aString
.- Returns:
- the OPeNDAP type name of the class instance as a
String
.
-
printVal
public abstract void printVal(PrintWriter os, String space)
Prints the value of all variables in this vector. This method is primarily intended for debugging OPeNDAP applications and text-based clients such as geturl.- 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.- See Also:
BaseType.printVal(PrintWriter, String, boolean)
-
printSingleVal
public abstract void printSingleVal(PrintWriter os, int index)
Prints the value of a single variable in this vector. method is used byDArray
'sprintVal
method.- Parameters:
os
- thePrintWriter
on which to print the value.index
- the index of the variable to print.- See Also:
DArray.printVal(PrintWriter, String, boolean)
-
getInternalStorage
public abstract Object getInternalStorage()
Returns (a reference to) the internal storage for PrimitiveVector.WARNING:
Because this method breaks encapsulation rules the user must beware! If we (the OPeNDAP prgramming team) choose to change the internal representation(s) of these types your code will probably break. This method is provided as an optimization to eliminate massive copying of data.
-
setInternalStorage
public abstract void setInternalStorage(Object o)
Set the internal storage for PrimitiveVector.WARNING:
Because this method breaks encapsulation rules the user must beware! If we (the OPeNDAP prgramming team) choose to change the internal representation(s) of these types your code will probably break. This method is provided as an optimization to eliminate massive copying of data.
-
subset
public abstract PrimitiveVector subset(int start, int stop, int stride)
Create a new primitive vector using a subset of the data.- Parameters:
start
- starting index (i=start)stop
- ending index (i<=stop)stride
- index stride (i+=stride)- Returns:
- new primitive vector
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisPrimitiveVector
. See DAPNode.cloneDag()- Overrides:
cloneDAG
in classDAPNode
- Parameters:
map
- track previously cloned nodes- Returns:
- a clone of this
PrimitiveVector
. - Throws:
CloneNotSupportedException
-
-