public class DSequence extends DConstructor implements ClientIO
DSequence
in OPeNDAP can hold N sequentially accessed
instances of a set of variables. In relation to the DStructure
datatype, a DSequence
is a table
of N instances of a DStructure
. Data in a
DSequence
is accessed row by row.
Unlike its C++ counterpart, this class reads all of its rows on a
deserialize
, which gives DSequence
the same
semantics as the other BaseType
classes, eliminating the need
to worry about DSequence
as a special case.BaseType
,
DConstructor
,
Serialized FormDAPNode.CloneMap
Modifier and Type | Field and Description |
---|---|
protected java.util.Vector |
allValues
The values in this
DSequence , stored as a
Vector of Vector of BaseType
objects. |
protected static byte |
END_OF_SEQUENCE
The end of sequence byte marker
|
protected static byte |
START_OF_INSTANCE
The start of instance byte marker
|
protected java.util.Vector |
varTemplate
The variables in this
DSequence , stored in a
Vector of BaseType objects
and used as a template for deserialize . |
_nameClear, _nameEncoded, log
Constructor and Description |
---|
DSequence()
Constructs a new
DSequence . |
DSequence(java.lang.String n)
Constructs a new
DSequence with name n . |
Modifier and Type | Method and Description |
---|---|
void |
addRow(java.util.Vector row)
Adds a row to the container.
|
void |
addVariable(BaseType v,
int part)
Adds a variable to the container.
|
void |
checkSemantics(boolean all)
Checks for internal consistency.
|
DAPNode |
cloneDAG(DAPNode.CloneMap map)
Returns a clone of this
Sequence . |
void |
delRow(int row)
Deletes a row from the container.
|
void |
deserialize(java.io.DataInputStream source,
ServerVersion sv,
StatusUI statusUI)
Reads data from a
DataInputStream . |
int |
elementCount(boolean leaves)
Returns the number of variables contained in this object.
|
void |
externalize(java.io.DataOutputStream sink)
Writes data to a
DataOutputStream . |
protected int |
getLevel()
Returns the level of this sequence.
|
java.util.Vector |
getRow(int row)
Gets a row from the container.
|
int |
getRowCount()
Returns the number of rows in this
Sequence . |
java.lang.String |
getTypeName()
Returns the OPeNDAP type name of the class instance as a
String . |
BaseType |
getVar(int index)
Gets the indexed variable.
|
int |
getVarCount()
Get the number of contained variables (for use with getVar()
|
BaseType |
getVariable(int row,
java.lang.String name)
Returns the named variable in the given row of the sequence.
|
BaseType |
getVariable(java.lang.String name)
Returns the named variable.
|
java.util.Enumeration |
getVariables()
Return an Enumeration that can be used to iterate over the members of
a Sequence.
|
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.
|
void |
printVal(java.io.PrintWriter os,
java.lang.String space,
boolean print_decl_p)
Prints the value of the variable, with its declaration.
|
protected void |
setLevel(int level)
Sets the level of this sequence.
|
protected void |
writeMarker(java.io.DataOutputStream sink,
byte marker)
Writes a marker byte to the output stream.
|
addVariable, printXML, someChildHasAttributes
addAttributeAlias, addAttributeContainer, appendAttribute, appendAttribute, appendAttributeContainer, checkSemantics, delAttribute, delAttribute, elementCount, getAttribute, getAttribute, getAttributeNames, getAttributeTable, getLongName, hasAttributes, newPrimitiveVector, printAttributes, printAttributes, printAttributes, printAttributes, printConstraint, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printVal, printVal, printVal, printXML, printXML, printXML, printXML, setClearName
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setEncodedName, setParent, setProject, setProject, setProjected
protected static byte START_OF_INSTANCE
protected static byte END_OF_SEQUENCE
protected java.util.Vector varTemplate
DSequence
, stored in a
Vector
of BaseType
objects
and used as a template for deserialize
.protected java.util.Vector allValues
DSequence
, stored as a
Vector
of Vector
of BaseType
objects.public DSequence()
DSequence
.public DSequence(java.lang.String n)
DSequence
with name n
.n
- the name of the variable.public java.lang.String getTypeName()
String
.getTypeName
in class BaseType
String
.protected final void setLevel(int level)
level
- the new level.protected final int getLevel()
public int elementCount(boolean leaves)
leaves
to true
.elementCount
in class BaseType
leaves
- If true, count all the simple types in the `tree' of
variables rooted at this variable.public void addVariable(BaseType v, int part)
addVariable
in class DConstructor
v
- the variable to add.part
- ignored for DSequence
.public final void addRow(java.util.Vector row)
Vector
of variables of the same type and in the same order
as the variable template added with the addVariable
method.row
- the Vector
to add.public final java.util.Vector getRow(int row)
Vector
of
variables of the same type and in the same order as the variable template
added with the addVariable
method.row
- the row number to retrieve.Vector
of BaseType
variables.public final void delRow(int row)
row
- the row number to delete.java.lang.ArrayIndexOutOfBoundsException
- if the index was invalid.public int getRowCount()
Sequence
.Sequence
.public BaseType getVariable(java.lang.String name) throws NoSuchVariableException
DSequence
,
this method returns the template variable, which holds no data. If you
need to get a variable containing data, use getRow
or the
getVariable
method which takes a row number parameter.getVariable
in class DConstructor
name
- the name of the variable.NoSuchVariableException
- if the named variable does not
exist in this container.getVariable(int, String)
public BaseType getVar(int index) throws NoSuchVariableException
BaseType
from the index
th column from the internal map Vector
.getVar
in class DConstructor
index
- the index of the variable in the Vector
Vars.NoSuchVariableException
- if the named variable does not
exist in this container.public int getVarCount()
getVarCount
in class DConstructor
public BaseType getVariable(int row, java.lang.String name) throws NoSuchVariableException
row
- the row number to retrieve.name
- the name of the variable.NoSuchVariableException
- if the named variable does not
exist in this container.public java.util.Enumeration getVariables()
getVariables
in class DConstructor
public void checkSemantics(boolean all) throws BadSemanticsException
DSequence
, verify that
the variables have unique names.checkSemantics
in class BaseType
all
- for complex constructor types, this flag indicates whether to
check the semantics of the member variables, too.BadSemanticsException
- if semantics are bad, explains why.BaseType.checkSemantics(boolean)
public void printDecl(java.io.PrintWriter os, java.lang.String space, boolean print_semi, boolean constrained)
printDecl
in class BaseType
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)
public void printVal(java.io.PrintWriter os, java.lang.String space, boolean print_decl_p)
printVal
in class BaseType
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.print_decl_p
- a boolean value controlling whether the
variable declaration is printed as well as the value.BaseType.printVal(PrintWriter, String, boolean)
public void deserialize(java.io.DataInputStream source, ServerVersion sv, StatusUI statusUI) throws java.io.IOException, 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.statusUI
- the StatusUI
object to use for GUI updates
and user cancellation notification (may be null).java.io.EOFException
- if EOF is found before the variable is completely
deserialized.java.io.IOException
- thrown on any other InputStream exception.DataReadException
- if an unexpected value was read.ClientIO.deserialize(DataInputStream, ServerVersion, StatusUI)
protected void writeMarker(java.io.DataOutputStream sink, byte marker) throws java.io.IOException
java.io.IOException
public 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 DAPNode cloneDAG(DAPNode.CloneMap map) throws java.lang.CloneNotSupportedException
Sequence
.
See DAPNode.cloneDag()