Package opendap.dap
Class Int32PrimitiveVector
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.PrimitiveVector
-
- opendap.dap.Int32PrimitiveVector
-
- All Implemented Interfaces:
Serializable
,Cloneable
,ClientIO
- Direct Known Subclasses:
UInt32PrimitiveVector
public class Int32PrimitiveVector extends PrimitiveVector
A vector of ints.- 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 Int32PrimitiveVector(BaseType var)
Constructs a newInt32PrimitiveVector
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DAPNode
cloneDAG(DAPNode.CloneMap map)
Returns a clone of thisInt32PrimitiveVector
.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.int
getValue(int i)
Return the i'th value as anint
.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, int 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
getTemplate, getTypeName, printDecl, printDecl
-
Methods inherited from class opendap.dap.DAPNode
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setClearName, setEncodedName, setParent, setProject, setProject, setProjected
-
-
-
-
Constructor Detail
-
Int32PrimitiveVector
public Int32PrimitiveVector(BaseType var)
Constructs a newInt32PrimitiveVector
.- Parameters:
var
- the templateBaseType
to use.
-
-
Method Detail
-
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 int getValue(int i)
Return the i'th value as anint
.- Parameters:
i
- the index of the value to return.- Returns:
- the i'th value.
-
setValue
public final void setValue(int i, int newVal)
Set the i'th value of the array.- Parameters:
i
- the index of the value to set.newVal
- the new value.
-
printVal
public 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 ints.
-
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
-
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 Int32PrimitiveVector.
-
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.
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisInt32PrimitiveVector
. See DAPNode.cloneDag()- Overrides:
cloneDAG
in classPrimitiveVector
- Parameters:
map
- track previously cloned nodes- Returns:
- a clone of this
Int32PrimitiveVector
. - Throws:
CloneNotSupportedException
-
-