Package opendap.dap
Class DSequence
- java.lang.Object
-
- opendap.dap.DAPNode
-
- opendap.dap.BaseType
-
- opendap.dap.DConstructor
-
- opendap.dap.DSequence
-
- All Implemented Interfaces:
Serializable,Cloneable,ClientIO
public class DSequence extends DConstructor implements ClientIO
ADSequencein OPeNDAP can hold N sequentially accessed instances of a set of variables. In relation to theDStructuredatatype, aDSequenceis a table of N instances of aDStructure. Data in aDSequenceis accessed row by row. Unlike its C++ counterpart, this class reads all of its rows on adeserialize, which givesDSequencethe same semantics as the otherBaseTypeclasses, eliminating the need to worry aboutDSequenceas a special case.- See Also:
BaseType,DConstructor, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class opendap.dap.DAPNode
DAPNode.CloneMap
-
-
Field Summary
Fields Modifier and Type Field Description protected VectorallValuesThe values in thisDSequence, stored as aVectorofVectorofBaseTypeobjects.protected static byteEND_OF_SEQUENCEThe end of sequence byte markerprotected static byteSTART_OF_INSTANCEThe start of instance byte markerprotected VectorvarTemplateThe variables in thisDSequence, stored in aVectorofBaseTypeobjects and used as a template fordeserialize.-
Fields inherited from class opendap.dap.DAPNode
_nameClear, _nameEncoded, log
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRow(Vector row)Adds a row to the container.voidaddVariable(BaseType v, int part)Adds a variable to the container.voidcheckSemantics(boolean all)Checks for internal consistency.DAPNodecloneDAG(DAPNode.CloneMap map)Returns a clone of thisSequence.voiddelRow(int row)Deletes a row from the container.voiddeserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI)Reads data from aDataInputStream.intelementCount(boolean leaves)Returns the number of variables contained in this object.voidexternalize(DataOutputStream sink)Writes data to aDataOutputStream.protected intgetLevel()Returns the level of this sequence.VectorgetRow(int row)Gets a row from the container.intgetRowCount()Returns the number of rows in thisSequence.StringgetTypeName()Returns the OPeNDAP type name of the class instance as aString.BaseTypegetVar(int index)Gets the indexed variable.intgetVarCount()Get the number of contained variables (for use with getVar()BaseTypegetVariable(int row, String name)Returns the named variable in the given row of the sequence.BaseTypegetVariable(String name)Returns the named variable.EnumerationgetVariables()Return an Enumeration that can be used to iterate over the members of a Sequence.voidprintDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)Write the variable's declaration in a C-style syntax.voidprintVal(PrintWriter os, String space, boolean print_decl_p)Prints the value of the variable, with its declaration.protected voidsetLevel(int level)Sets the level of this sequence.protected voidwriteMarker(DataOutputStream sink, byte marker)Writes a marker byte to the output stream.-
Methods inherited from class opendap.dap.DConstructor
addVariable, printXML, someChildHasAttributes
-
Methods inherited from class opendap.dap.BaseType
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
-
Methods inherited from class opendap.dap.DAPNode
clone, cloneDAG, getClearName, getEncodedName, getParent, isProject, setEncodedName, setParent, setProject, setProject, setProjected
-
-
-
-
Field Detail
-
START_OF_INSTANCE
protected static byte START_OF_INSTANCE
The start of instance byte marker
-
END_OF_SEQUENCE
protected static byte END_OF_SEQUENCE
The end of sequence byte marker
-
varTemplate
protected Vector varTemplate
The variables in thisDSequence, stored in aVectorofBaseTypeobjects and used as a template fordeserialize.
-
allValues
protected Vector allValues
The values in thisDSequence, stored as aVectorofVectorofBaseTypeobjects.
-
-
Constructor Detail
-
DSequence
public DSequence()
Constructs a newDSequence.
-
DSequence
public DSequence(String n)
Constructs a newDSequencewith namen.- Parameters:
n- the name of the variable.
-
-
Method Detail
-
getTypeName
public String getTypeName()
Returns the OPeNDAP type name of the class instance as aString.- Specified by:
getTypeNamein classBaseType- Returns:
- the OPeNDAP type name of the class instance as a
String.
-
setLevel
protected final void setLevel(int level)
Sets the level of this sequence.- Parameters:
level- the new level.
-
getLevel
protected final int getLevel()
Returns the level of this sequence.- Returns:
- the level of this sequence.
-
elementCount
public int elementCount(boolean leaves)
Returns the number of variables contained in this object. For simple and vector type variables, it always returns 1. To count the number of simple-type variable in the variable tree rooted at this variable, setleavestotrue.- Overrides:
elementCountin classBaseType- Parameters:
leaves- If true, count all the simple types in the `tree' of variables rooted at this variable.- Returns:
- the number of contained variables.
-
addVariable
public void addVariable(BaseType v, int part)
Adds a variable to the container.- Specified by:
addVariablein classDConstructor- Parameters:
v- the variable to add.part- ignored forDSequence.
-
addRow
public final void addRow(Vector row)
Adds a row to the container. This is assumed to contain aVectorof variables of the same type and in the same order as the variable template added with theaddVariablemethod.- Parameters:
row- theVectorto add.
-
getRow
public final Vector getRow(int row)
Gets a row from the container. This returns aVectorof variables of the same type and in the same order as the variable template added with theaddVariablemethod.- Parameters:
row- the row number to retrieve.- Returns:
- the
VectorofBaseTypevariables.
-
delRow
public final void delRow(int row)
Deletes a row from the container.- Parameters:
row- the row number to delete.- Throws:
ArrayIndexOutOfBoundsException- if the index was invalid.
-
getRowCount
public int getRowCount()
Returns the number of rows in thisSequence.- Returns:
- the number of rows currently in this
Sequence.
-
getVariable
public BaseType getVariable(String name) throws NoSuchVariableException
Returns the named variable. Note: InDSequence, this method returns the template variable, which holds no data. If you need to get a variable containing data, usegetRowor thegetVariablemethod which takes a row number parameter.- Specified by:
getVariablein classDConstructor- Parameters:
name- the name of the variable.- Returns:
- the named variable.
- Throws:
NoSuchVariableException- if the named variable does not exist in this container.- See Also:
getVariable(int, String)
-
getVar
public BaseType getVar(int index) throws NoSuchVariableException
Gets the indexed variable. For a DSrquence this returns theBaseTypefrom theindexth column from the internal mapVector.- Specified by:
getVarin classDConstructor- Parameters:
index- the index of the variable in theVectorVars.- Returns:
- the indexed variable.
- Throws:
NoSuchVariableException- if the named variable does not exist in this container.
-
getVarCount
public int getVarCount()
Get the number of contained variables (for use with getVar()- Specified by:
getVarCountin classDConstructor- Returns:
- the number of contained variables
-
getVariable
public BaseType getVariable(int row, String name) throws NoSuchVariableException
Returns the named variable in the given row of the sequence.- Parameters:
row- the row number to retrieve.name- the name of the variable.- Returns:
- the named variable.
- Throws:
NoSuchVariableException- if the named variable does not exist in this container.
-
getVariables
public Enumeration getVariables()
Return an Enumeration that can be used to iterate over the members of a Sequence. This implementation provides access to the template elements of the Sequence, not the entire sequence. Each Object returned by the Enumeration can be cast to a BaseType.- Specified by:
getVariablesin classDConstructor- Returns:
- An Enumeration
-
checkSemantics
public void checkSemantics(boolean all) throws BadSemanticsExceptionChecks for internal consistency. ForDSequence, verify that the variables have unique names.- Overrides:
checkSemanticsin classBaseType- Parameters:
all- for complex constructor types, this flag indicates whether to check the semantics of the member variables, too.- Throws:
BadSemanticsException- if semantics are bad, explains why.- See Also:
BaseType.checkSemantics(boolean)
-
printDecl
public void printDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)
Write the variable's declaration in a C-style syntax. This function is used to create textual representation of the Data Descriptor Structure (DDS). See The OPeNDAP User Manual for information about this structure.- Overrides:
printDeclin classBaseType- Parameters:
os- ThePrintWriteron 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.- See Also:
BaseType.printDecl(PrintWriter, String, boolean)
-
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.- Specified by:
printValin classBaseType- Parameters:
os- thePrintWriteron which to print the value.space- this value is passed to theprintDeclmethod, 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.- See Also:
BaseType.printVal(PrintWriter, String, boolean)
-
deserialize
public void deserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI) throws IOException, DataReadException
Reads data from aDataInputStream. This method is only used on the client side of the OPeNDAP client/server connection.- Specified by:
deserializein interfaceClientIO- Parameters:
source- aDataInputStreamto read from.sv- theServerVersionreturned by the server.statusUI- theStatusUIobject to use for GUI updates and user cancellation notification (may be null).- Throws:
EOFException- if EOF is found before the variable is completely deserialized.IOException- thrown on any other InputStream exception.DataReadException- if an unexpected value was read.- See Also:
ClientIO.deserialize(DataInputStream, ServerVersion, StatusUI)
-
writeMarker
protected void writeMarker(DataOutputStream sink, byte marker) throws IOException
Writes a marker byte to the output stream.- Throws:
IOException
-
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- Parameters:
sink- aDataOutputStreamto write to.- Throws:
IOException- thrown on anyOutputStreamexception.
-
cloneDAG
public DAPNode cloneDAG(DAPNode.CloneMap map) throws CloneNotSupportedException
Returns a clone of thisSequence. See DAPNode.cloneDag()- Overrides:
cloneDAGin classBaseType- Parameters:
map- track previously cloned nodes- Returns:
- a clone of this object.
- Throws:
CloneNotSupportedException
-
-