public abstract class PrimitiveVector extends DAPNode implements ClientIO
DVector
. It allows DVector
,
and by extension, DArray
and DList
, to use more
efficient primitive types to hold large arrays of data.
A PrimitiveVector
class is defined for each
primitive type supported in OPeNDAP, and a
BaseTypePrimitiveVector
class handles DArray
s
and DList
s of compound types.BaseType
,
DVector
,
Serialized FormDAPNode.CloneMap
_nameClear, _nameEncoded, log
Constructor and Description |
---|
PrimitiveVector(BaseType var)
Constructs a new
PrimitiveVector . |
Modifier and Type | Method and Description |
---|---|
DAPNode |
cloneDAG(DAPNode.CloneMap map)
Returns a clone of this
PrimitiveVector . |
abstract void |
deserialize(java.io.DataInputStream source,
ServerVersion sv,
StatusUI statusUI)
Reads data from a
DataInputStream . |
abstract void |
externalize(java.io.DataOutputStream sink)
Writes data to a
DataOutputStream . |
abstract java.lang.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.
|
java.lang.String |
getTypeName()
Returns the OPeNDAP type name of the class instance as a
String . |
void |
printDecl(java.io.PrintWriter os,
java.lang.String space,
boolean print_semi)
Write the variable's declaration in a C-style syntax.
|
void |
printDecl(java.io.PrintWriter os,
java.lang.String space,
boolean print_semi,
boolean constrained)
Write the variable's declaration in a C-style syntax.
|
abstract void |
printSingleVal(java.io.PrintWriter os,
int index)
Prints the value of a single variable in this vector.
|
abstract void |
printVal(java.io.PrintWriter os,
java.lang.String space)
Prints the value of all variables in this vector.
|
abstract void |
setInternalStorage(java.lang.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.
|
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setClearName, setEncodedName, setParent, setProject, setProject, setProjected
public PrimitiveVector(BaseType var)
PrimitiveVector
.var
- the template BaseType
to use.public final BaseType getTemplate()
BaseTypePrimitiveVector.deserialize(DataInputStream, ServerVersion, StatusUI)
public abstract int getLength()
public abstract void setLength(int len)
deserialize
method or in derived
classes on server.len
- the number of elements in the array.public abstract void deserialize(java.io.DataInputStream source, ServerVersion sv, StatusUI statusUI) throws java.io.IOException, java.io.EOFException, DataReadException
DataInputStream
. This method is only used
on the client side of the OPeNDAP client/server connection.deserialize
in interface ClientIO
source
- a DataInputStream
to read from.sv
- The ServerVersion
returned by the server.
(used by DSequence
to determine which protocol version was
used).statusUI
- The StatusUI
object to use for GUI updates
and user cancellation notification (may be null).DataReadException
- when invalid data is read, or if the user
cancels the download.java.io.EOFException
- if EOF is found before the variable is completely
deserialized.java.io.IOException
- thrown on any other InputStream exception.ClientIO.deserialize(DataInputStream, ServerVersion, StatusUI)
public abstract void externalize(java.io.DataOutputStream sink) throws java.io.IOException
DataOutputStream
. 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.externalize
in interface ClientIO
sink
- a DataOutputStream
to write to.java.io.IOException
- thrown on any OutputStream
exception.public final void printDecl(java.io.PrintWriter os, java.lang.String space, boolean print_semi, boolean constrained)
os
- The PrintWriter
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.BaseType.printDecl(PrintWriter, String, boolean, boolean)
public final void printDecl(java.io.PrintWriter os, java.lang.String space, boolean print_semi)
os
- The PrintWriter
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.BaseType.printDecl(PrintWriter, String, boolean)
public java.lang.String getTypeName()
String
.String
.public abstract void printVal(java.io.PrintWriter os, java.lang.String space)
os
- the PrintWriter
on which to print the value.space
- this value is passed to the printDecl
method,
and controls the leading spaces of the output.BaseType.printVal(PrintWriter, String, boolean)
public abstract void printSingleVal(java.io.PrintWriter os, int index)
DArray
's printVal
method.os
- the PrintWriter
on which to print the value.index
- the index of the variable to print.DArray.printVal(PrintWriter, String, boolean)
public abstract java.lang.Object getInternalStorage()
public abstract void setInternalStorage(java.lang.Object o)
public abstract PrimitiveVector subset(int start, int stop, int stride)
start
- starting index (i=start)stop
- ending index (i<=stop)stride
- index stride (i+=stride)public DAPNode cloneDAG(DAPNode.CloneMap map) throws java.lang.CloneNotSupportedException
PrimitiveVector
.
See DAPNode.cloneDag()