Package opendap.dap
Class BaseTypePrimitiveVector
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.PrimitiveVector
-
- opendap.dap.BaseTypePrimitiveVector
-
- All Implemented Interfaces:
Serializable
,Cloneable
,ClientIO
public class BaseTypePrimitiveVector extends PrimitiveVector
A vector ofBaseType
.- See Also:
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
-
-
Constructor Summary
Constructors Constructor Description BaseTypePrimitiveVector(BaseType var)
Constructs a newBaseTypePrimitiveVector
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
clone()
Returns a clone of thisBaseTypePrimitiveVector
.void
deserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI)
Reads data from aDataInputStream
.void
externalize(DataOutputStream sink)
Writes data to aDataOutputStream
.void
externalize(DataOutputStream sink, int start, int stop, int stride)
Write a subset of the data to aDataOutputStream
.Object
getInternalStorage()
Returns (a reference to) the internal storage for this PrimitiveVector object.int
getLength()
Returns the number of elements in the array.String
getTypeName()
Returns the OPeNDAP type name of the class instance as aString
.BaseType
getValue(int i)
Return the i'th value as aBaseType
.void
printSingleVal(PrintWriter os, int index)
Prints the value of a single variable in this vector.void
printVal(PrintWriter os, String space)
Prints the value of all variables in this vector.void
printVal(PrintWriter os, String space, boolean print_decl_p)
Prints the value of the variable, with its declaration.void
setInternalStorage(Object o)
Set the internal storage for PrimitiveVector.void
setLength(int len)
Sets the number of elements in the array.void
setValue(int i, BaseType newVal)
Set the i'th value of the array.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.PrimitiveVector
cloneDAG, getTemplate, printDecl, printDecl
-
Methods inherited from class opendap.dap.DAPNode
cloneDAG, getClearName, getEncodedName, getParent, isProject, setClearName, setEncodedName, setParent, setProject, setProject, setProjected
-
-
-
-
Constructor Detail
-
BaseTypePrimitiveVector
public BaseTypePrimitiveVector(BaseType var)
Constructs a newBaseTypePrimitiveVector
.- Parameters:
var
- the templateBaseType
to use.
-
-
Method Detail
-
clone
public Object clone()
Returns a clone of thisBaseTypePrimitiveVector
. A deep copy is performed on all data inside the variable.
-
getLength
public int getLength()
Returns the number of elements in the array.- Specified by:
getLength
in classPrimitiveVector
- Returns:
- the number of elements in the array.
-
setLength
public 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.- Specified by:
setLength
in classPrimitiveVector
- Parameters:
len
- the number of elements in the array.
-
getValue
public final BaseType getValue(int i)
Return the i'th value as aBaseType
.- Parameters:
i
- the index of the value to return.- Returns:
- the i'th value.
-
setValue
public final void setValue(int i, BaseType newVal)
Set the i'th value of the array.- Parameters:
i
- the index of the value to set.newVal
- the new value.
-
printVal
public final 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.- Specified by:
printVal
in classPrimitiveVector
- 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 void printSingleVal(PrintWriter os, int index)
Prints the value of a single variable in this vector. method is used byDArray
'sprintVal
method.- Specified by:
printSingleVal
in classPrimitiveVector
- Parameters:
os
- thePrintWriter
on which to print the value.index
- the index of the variable to print.- See Also:
DArray.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
- Specified by:
deserialize
in classPrimitiveVector
- 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 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
- Specified by:
externalize
in classPrimitiveVector
- Parameters:
sink
- aDataOutputStream
to write to.- Throws:
IOException
- thrown on anyOutputStream
exception.
-
externalize
public void externalize(DataOutputStream sink, int start, int stop, int stride) throws IOException
Write a subset of the data to aDataOutputStream
.- Parameters:
sink
- aDataOutputStream
to write to.start
- starting index (i=start)stop
- ending index (i<=stop)stride
- index stride (i+=stride)- Throws:
IOException
- thrown on anyOutputStream
exception.
-
getInternalStorage
public Object getInternalStorage()
Returns (a reference to) the internal storage for this PrimitiveVector object.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.- Specified by:
getInternalStorage
in classPrimitiveVector
- Returns:
- The internal array of BaseTypes.
-
setInternalStorage
public 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.- Specified by:
setInternalStorage
in classPrimitiveVector
-
getTypeName
public String getTypeName()
Returns the OPeNDAP type name of the class instance as aString
.- Overrides:
getTypeName
in classPrimitiveVector
- Returns:
- the OPeNDAP type name of the class instance as a
String
.
-
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.- 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.
-
subset
public PrimitiveVector subset(int start, int stop, int stride)
Create a new primitive vector using a subset of the data.- Specified by:
subset
in classPrimitiveVector
- Parameters:
start
- starting index (i=start)stop
- ending index (i<=stop)stride
- index stride (i+=stride)- Returns:
- new primitive vector, of type BaseTypePrimitiveVector.
-
-