Package opendap.dap

Class DSequence

  • All Implemented Interfaces:
    Serializable, Cloneable, ClientIO

    public class DSequence
    extends DConstructor
    implements ClientIO
    A 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.

    See Also:
    BaseType, DConstructor, Serialized Form
    • 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 this DSequence, stored in a Vector of BaseType objects and used as a template for deserialize.
      • allValues

        protected Vector allValues
        The values in this DSequence, stored as a Vector of Vector of BaseType objects.
    • Constructor Detail

      • DSequence

        public DSequence()
        Constructs a new DSequence.
      • DSequence

        public DSequence​(String n)
        Constructs a new DSequence with name n.
        Parameters:
        n - the name of the variable.
    • Method Detail

      • getTypeName

        public String getTypeName()
        Returns the OPeNDAP type name of the class instance as a String.
        Specified by:
        getTypeName in class BaseType
        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, set leaves to true.
        Overrides:
        elementCount in class BaseType
        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:
        addVariable in class DConstructor
        Parameters:
        v - the variable to add.
        part - ignored for DSequence.
      • addRow

        public final void addRow​(Vector row)
        Adds a row to the container. This is assumed to contain a Vector of variables of the same type and in the same order as the variable template added with the addVariable method.
        Parameters:
        row - the Vector to add.
      • getRow

        public final Vector getRow​(int row)
        Gets a row from the container. This returns a Vector of variables of the same type and in the same order as the variable template added with the addVariable method.
        Parameters:
        row - the row number to retrieve.
        Returns:
        the Vector of BaseType variables.
      • 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 this Sequence.
        Returns:
        the number of rows currently in this Sequence.
      • getVariable

        public BaseType getVariable​(String name)
                             throws NoSuchVariableException
        Returns the named variable. Note: In 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.
        Specified by:
        getVariable in class DConstructor
        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 the BaseType from the indexth column from the internal map Vector.
        Specified by:
        getVar in class DConstructor
        Parameters:
        index - the index of the variable in the Vector Vars.
        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:
        getVarCount in class DConstructor
        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:
        getVariables in class DConstructor
        Returns:
        An Enumeration
      • 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:
        printDecl in class BaseType
        Parameters:
        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.
        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:
        printVal in class BaseType
        Parameters:
        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.
        See Also:
        BaseType.printVal(PrintWriter, String, boolean)
      • externalize

        public void externalize​(DataOutputStream sink)
                         throws IOException
        Writes data to a 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.
        Specified by:
        externalize in interface ClientIO
        Parameters:
        sink - a DataOutputStream to write to.
        Throws:
        IOException - thrown on any OutputStream exception.