Package opendap.dap
Class BytePrimitiveVector
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.PrimitiveVector
-
- opendap.dap.BytePrimitiveVector
-
- All Implemented Interfaces:
Serializable,Cloneable,ClientIO
public class BytePrimitiveVector extends PrimitiveVector
A vector of bytes.- 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 BytePrimitiveVector(BaseType var)Constructs a newBytePrimitiveVector.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DAPNodecloneDAG(DAPNode.CloneMap map)Returns a clone of thisAttribute.voiddeserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI)Reads data from aDataInputStream.voidexternalize(DataOutputStream sink)Writes data to aDataOutputStream.voidexternalize(DataOutputStream sink, int start, int stop, int stride)Write a subset of the data to aDataOutputStream.ObjectgetInternalStorage()Returns (a reference to) the internal storage for this PrimitiveVector object.intgetLength()Returns the number of elements in the array.bytegetValue(int i)Return the i'th value as abyte.voidprintSingleVal(PrintWriter os, int index)Prints the value of a single variable in this vector.voidprintVal(PrintWriter os, String space)Prints the value of all variables in this vector.voidsetInternalStorage(Object o)Set the internal storage for PrimitiveVector.voidsetLength(int len)Sets the number of elements in the array.voidsetValue(int i, byte newVal)Set the i'th value of the array.PrimitiveVectorsubset(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
-
BytePrimitiveVector
public BytePrimitiveVector(BaseType var)
Constructs a newBytePrimitiveVector.- Parameters:
var- the templateBaseTypeto use.
-
-
Method Detail
-
getLength
public int getLength()
Returns the number of elements in the array.- Specified by:
getLengthin 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 ofdeserializemethod or in derived classes on server.- Specified by:
setLengthin classPrimitiveVector- Parameters:
len- the number of elements in the array.
-
getValue
public final byte getValue(int i)
Return the i'th value as abyte.- Parameters:
i- the index of the value to return.- Returns:
- the i'th value.
-
setValue
public final void setValue(int i, byte 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:
printValin classPrimitiveVector- Parameters:
os- thePrintWriteron which to print the value.space- this value is passed to theprintDeclmethod, 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'sprintValmethod.- Specified by:
printSingleValin classPrimitiveVector- Parameters:
os- thePrintWriteron 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:
deserializein interfaceClientIO- Specified by:
deserializein classPrimitiveVector- Parameters:
source- aDataInputStreamto read from.sv- TheServerVersionreturned by the server. (used byDSequenceto determine which protocol version was used).statusUI- TheStatusUIobject 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:
externalizein interfaceClientIO- Specified by:
externalizein classPrimitiveVector- Parameters:
sink- aDataOutputStreamto write to.- Throws:
IOException- thrown on anyOutputStreamexception.
-
externalize
public void externalize(DataOutputStream sink, int start, int stop, int stride) throws IOException
Write a subset of the data to aDataOutputStream.- Parameters:
sink- aDataOutputStreamto write to.start- starting index (i=start)stop- ending index (i<=stop)stride- index stride (i+=stride)- Throws:
IOException- thrown on anyOutputStreamexception.
-
subset
public PrimitiveVector subset(int start, int stop, int stride)
Create a new primitive vector using a subset of the data.- Specified by:
subsetin classPrimitiveVector- Parameters:
start- starting index (i=start)stop- ending index (i<=stop)stride- index stride (i+=stride)- Returns:
- new primitive vector, of type BytePrimitiveVector.
-
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:
getInternalStoragein classPrimitiveVector- Returns:
- The internal array of bytes.
-
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:
setInternalStoragein classPrimitiveVector
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisAttribute. See DAPNode.cloneDag()- Overrides:
cloneDAGin classPrimitiveVector- Parameters:
map- track previously cloned nodes- Returns:
- a clone of this
Attribute. - Throws:
CloneNotSupportedException
-
-