opendap/src/main/java/opendap/dap/Int16PrimitiveVector.java
public void externalize(DataOutputStream sink, int start, int stop, int stride) throws IOException {
        for (int i = start; i <= stop; i += stride)
            sink.writeInt((int) vals[i]);
    }

    /**
     * Returns (a reference to) the internal storage for this PrimitiveVector
     * object.
     * <h2>WARNING:</h2>
     * Because this method breaks encapsulation rules the user must beware!
     * If we (the OPeNDAP prgramming team) choose to change the internal
     * representation(s) of these types your code will probably break.
     * <p/>
     * This method is provided as an optimization to eliminate massive
     * copying of data.
     *
     * @return The internal array of shorts.
     */
    public Object getInternalStorage() {
        return (vals);
    }

    /**
     * Set the internal storage for PrimitiveVector.
     * <h2><i>WARNING:</i></h2>
     * Because this method breaks encapsulation rules the user must beware!
     * If we (the OPeNDAP prgramming team) choose to change the internal
     * representation(s) of these types your code will probably break.
     * <p/>
     * This method is provided as an optimization to eliminate massive
     * copying of data.
     */
    public void setInternalStorage(Object o) {
        vals = (short []) o;
    }

    /**
     * Create a new primitive vector using a subset of the data.
     *
     * @param start  starting index (i=start)
     * @param stop   ending index (i<=stop)
     * @param stride index stride (i+=stride)
     * @return new primitive vector, of type Int16PrimitiveVector.
     */
    public PrimitiveVector subset(int start, int stop, int stride) {
        Int16PrimitiveVector n = new Int16PrimitiveVector(getTemplate());
        stride = Math.max(stride, 1);
        stop = Math.max(start, stop);
        int length = 1 + (stop - start) / stride;
        n.setLength(length);

        int count = 0;
        for (int i = start; i <= stop; i += stride) {
            n.setValue(count, vals[i]);
            count++;
        }
        return n;
    }

/**
   * 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.
   *
   * @param os           the <code>PrintWriter</code> on which to print the value.
   * @param space        this value is passed to the <code>printDecl</code> method,
   *                     and controls the leading spaces of the output.
   * @param print_decl_p a boolean value controlling whether the
   *                     variable declaration is printed as well as the value.
   */
   public void printVal(PrintWriter os, String space,
                                boolean print_decl_p) {}

    /**
     * Returns a clone of this <code>Int16PrimitiveVector</code>.
     * See DAPNode.cloneDag()
     *
     * @param map track previously cloned nodes
     * @return a clone of this <code>Int16PrimitiveVector</code>.
     */
    public DAPNode cloneDAG(CloneMap map)
        throws CloneNotSupportedException
    {
        Int16PrimitiveVector v = (Int16PrimitiveVector) super.cloneDAG(map);
        if (vals != null) {
            v.vals = new short[vals.length];
            System.arraycopy(vals, 0, v.vals, 0, vals.length);
        }
        return v;
    }


}
public void externalize(DataOutputStream sink, int start, int stop, int stride) throws IOException {
        for (int i = start; i <= stop; i += stride)
            sink.writeInt((int) vals[i]);
    }

    /**
     * Returns (a reference to) the internal storage for this PrimitiveVector
     * object.
     * <h2>WARNING:</h2>
     * Because this method breaks encapsulation rules the user must beware!
     * If we (the OPeNDAP prgramming team) choose to change the internal
     * representation(s) of these types your code will probably break.
     * <p/>
     * This method is provided as an optimization to eliminate massive
     * copying of data.
     *
     * @return The internal array of shorts.
     */
    public Object getInternalStorage() {
        return (vals);
    }

    /**
     * Set the internal storage for PrimitiveVector.
     * <h2><i>WARNING:</i></h2>
     * Because this method breaks encapsulation rules the user must beware!
     * If we (the OPeNDAP prgramming team) choose to change the internal
     * representation(s) of these types your code will probably break.
     * <p/>
     * This method is provided as an optimization to eliminate massive
     * copying of data.
     */
    public void setInternalStorage(Object o) {
        vals = (short []) o;
    }

    /**
     * Create a new primitive vector using a subset of the data.
     *
     * @param start  starting index (i=start)
     * @param stop   ending index (i<=stop)
     * @param stride index stride (i+=stride)
     * @return new primitive vector, of type Int16PrimitiveVector.
     */
    public PrimitiveVector subset(int start, int stop, int stride) {
        Int16PrimitiveVector n = new Int16PrimitiveVector(getTemplate());
        stride = Math.max(stride, 1);
        stop = Math.max(start, stop);
        int length = 1 + (stop - start) / stride;
        n.setLength(length);

        int count = 0;
        for (int i = start; i <= stop; i += stride) {
            n.setValue(count, vals[i]);
            count++;
        }
        return n;
    }

/**
   * 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.
   *
   * @param os           the <code>PrintWriter</code> on which to print the value.
   * @param space        this value is passed to the <code>printDecl</code> method,
   *                     and controls the leading spaces of the output.
   * @param print_decl_p a boolean value controlling whether the
   *                     variable declaration is printed as well as the value.
   */
   public void printVal(PrintWriter os, String space,
                                boolean print_decl_p) {}

    /**
     * Returns a clone of this <code>Int16PrimitiveVector</code>.
     * See DAPNode.cloneDag()
     *
     * @param map track previously cloned nodes
     * @return a clone of this <code>Int16PrimitiveVector</code>.
     */
    public DAPNode cloneDAG(CloneMap map)
        throws CloneNotSupportedException
    {
        Int16PrimitiveVector v = (Int16PrimitiveVector) super.cloneDAG(map);
        if (vals != null) {
            v.vals = new short[vals.length];
            System.arraycopy(vals, 0, v.vals, 0, vals.length);
        }
        return v;
    }


}
public void externalize ( DataOutputStream sink , int start , int stop , int stride ) throws IOException { for ( int i = start ; i <= stop ; i += stride ) sink . writeInt ( ( int ) vals [ i ] ) ; } /**
     * Returns (a reference to) the internal storage for this PrimitiveVector
     * object.
     * <h2>WARNING:</h2>
     * Because this method breaks encapsulation rules the user must beware!
     * If we (the OPeNDAP prgramming team) choose to change the internal
     * representation(s) of these types your code will probably break.
     * <p/>
     * This method is provided as an optimization to eliminate massive
     * copying of data.
     *
     * @return The internal array of shorts.
     */ public Object getInternalStorage ( ) { return ( vals ) ; } /**
     * Set the internal storage for PrimitiveVector.
     * <h2><i>WARNING:</i></h2>
     * Because this method breaks encapsulation rules the user must beware!
     * If we (the OPeNDAP prgramming team) choose to change the internal
     * representation(s) of these types your code will probably break.
     * <p/>
     * This method is provided as an optimization to eliminate massive
     * copying of data.
     */ public void setInternalStorage ( Object o ) { vals = ( short [ ] ) o ; } /**
     * Create a new primitive vector using a subset of the data.
     *
     * @param start  starting index (i=start)
     * @param stop   ending index (i<=stop)
     * @param stride index stride (i+=stride)
     * @return new primitive vector, of type Int16PrimitiveVector.
     */ public PrimitiveVector subset ( int start , int stop , int stride ) { Int16PrimitiveVector n = new Int16PrimitiveVector ( getTemplate ( ) ) ; stride = Math . max ( stride , 1 ) ; stop = Math . max ( start , stop ) ; int length = 1 + ( stop - start ) / stride ; n . setLength ( length ) ; int count = 0 ; for ( int i = start ; i <= stop ; i += stride ) { n . setValue ( count , vals [ i ] ) ; count ++ ; } return n ; } /**
   * 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.
   *
   * @param os           the <code>PrintWriter</code> on which to print the value.
   * @param space        this value is passed to the <code>printDecl</code> method,
   *                     and controls the leading spaces of the output.
   * @param print_decl_p a boolean value controlling whether the
   *                     variable declaration is printed as well as the value.
   */ public void printVal ( PrintWriter os , String space , boolean print_decl_p ) { } /**
     * Returns a clone of this <code>Int16PrimitiveVector</code>.
     * See DAPNode.cloneDag()
     *
     * @param map track previously cloned nodes
     * @return a clone of this <code>Int16PrimitiveVector</code>.
     */ public DAPNode cloneDAG ( CloneMap map ) throws CloneNotSupportedException { Int16PrimitiveVector v = ( Int16PrimitiveVector ) super . cloneDAG ( map ) ; if ( vals != null ) { v . vals = new short [ vals . length ] ; System . arraycopy ( vals , 0 , v . vals , 0 , vals . length ) ; } return v ; } }
Write a subset of the data to a <code>DataOutputStream</code>.

@param sink    a <code>DataOutputStream</code> to write to.
@param start  starting index (i=start)
@param stop   ending index (i<=stop)
@param stride index stride (i+=stride)
@throws IOException thrown on any <code>OutputStream</code> exception.
Write a subset of the data to a <code > DataOutputStream< / code > .