## dods.dap
Class DVector

    java.lang.Object
      dods.dap.BaseType
          dods.dap.DVector

All Implemented Interfaces:
  ClientIO, Cloneable

Direct Known Subclasses:
  DArray, DList

public abstract class DVector
extends BaseType
implements ClientIO

This class holds a one-dimensional array of DODS data types. It is the parent of both `DList` and `DArray`. This class uses a `PrimitiveVector` to hold the data and deserialize it, thus allowing more efficient storage to be used for the primitive types.

See Also:
  `BaseType`, `DArray`, `DList`, `PrimitiveVector`

Constructor Summary
`DVector()` Constructs a new `DVector`.
`DVector(String n)` Constructs a new `DVector` with name `n`.

Method Summary
`void` `addVariable(BaseType v)` Adds a variable to the container.
`Object` `clone()` Returns a clone of this `DVector`.
`void` `deserialize(DataInputStream source, ServerVersion sv, StatusUI statusUI)` Reads data from a `DataInputStream`.
`void` `externalize(DataOutputStream sink)` Writes data to a `DataOutputStream`.
`int` `getLength()` Returns the number of elements in the vector.
`PrimitiveVector` `getPrimitiveVector()` Returns the `PrimitiveVector` for this vector.
`String` `getTypeName()` Returns the DODS type name of the class instance as a `String`.
`void` `printDecl(PrintWriter os, String space, boolean print_semi, boolean constrained)` Write the variable's declaration in a C-style syntax.
`void` `printVal(PrintWriter os, String space, boolean print_decl_p)` Prints the value of the variable, with its declaration.
`void` `setLength(int len)` Sets the number of elements in the vector.

Methods inherited from class dods.dap.BaseType
`checkSemantics, checkSemantics, elementCount, elementCount, getLongName, getName, getParent, newPrimitiveVector, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printDecl, printVal, printVal, printVal, setName, setParent`

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### DVector

    public DVector()

  Constructs a new `DVector`.

### DVector

    public DVector(String n)

  Constructs a new `DVector` with name `n`.

Parameters:
  `n` - the name of the variable.

Method Detail

### getTypeName

    public String getTypeName()

  Returns the DODS type name of the class instance as a `String`.

  Specified by:
    `getTypeName` in class `BaseType`
  Returns:
    the DODS type name of the class instance as a `String`.

### clone

    public Object clone()

  Returns a clone of this `DVector`. A deep copy is performed on all variables inside the `DVector`.

  Overrides:
    `clone` in class `BaseType`
  Returns:
    a clone of this `DVector`.

### getLength

    public int getLength()

  Returns the number of elements in the vector.

  Returns:
    the number of elements in the vector.

### setLength

    public void setLength(int len)

  Sets the number of elements in the vector. Allocates a new 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 of `deserialize` method or in derived classes on server.

  Parameters:
    `len` - the number of elements in the array.

### addVariable

    public void addVariable(BaseType v)

  Adds a variable to the container.

  Parameters:
    `v` - the variable to add.

### getPrimitiveVector

    public PrimitiveVector getPrimitiveVector()

  Returns the `PrimitiveVector` for this vector. This can be cast to the appropriate type and used by a DODS client to read or set individual values in the vector.

  Returns:
    the attached `PrimitiveVector`.

### 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 DODS 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 DODS 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)`

### deserialize

    public void deserialize(DataInputStream source,
                            ServerVersion sv,
                            StatusUI statusUI)
                     throws IOException,
                            EOFException,
                            DataReadException

  Reads data from a `DataInputStream`. This method is only used on the client side of the DODS client/server connection.

  Specified by:
    `deserialize` in interface `ClientIO`
  Parameters:
    `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).
  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)`

### 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 DODS 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.