opendap/src/main/java/ucar/nc2/dods/ConvertD2N.java
public Array convert(DodsV dataV) throws IOException, DAP2Exception {

    // scalars
    if (dataV.darray == null) {

      if (dataV.bt instanceof DStructure) {
        ArrayStructure structArray = makeArrayStructure( dataV);
        iconvertDataStructure( (DStructure) dataV.bt, structArray.getStructureMembers());
        return structArray;

      } else if (dataV.bt instanceof DGrid) {
        throw new IllegalStateException( "DGrid without a darray");

      } else if (dataV.bt instanceof DSequence) {
        ArrayStructure structArray = makeArrayStructure( dataV);
        iconvertDataSequenceArray( (DSequence) dataV.bt, structArray.getStructureMembers());
        return structArray;

      } else { // scalar
        DataType dtype = dataV.getDataType();
        Array scalarData = Array.factory(  dtype, new int[0]);
        IndexIterator scalarIndex = scalarData.getIndexIterator();
        iconvertDataPrimitiveScalar( dataV.bt, scalarIndex);
        return scalarData;
      }
    }

    // arrays
    if (dataV.darray != null) {

      if (dataV.bt instanceof DStructure) {
        ArrayStructure structArray = makeArrayStructure( dataV);
        iconvertDataStructureArray( dataV.darray, structArray.getStructureMembers());
        return structArray;

      } else if (dataV.bt instanceof DString) {
        return convertStringArray(dataV.darray);

      } else {
        // the DGrid case comes here also
        // create the array, using  DODS internal array so there's no copying
        opendap.dap.PrimitiveVector pv = dataV.darray.getPrimitiveVector();
        Object storage = pv.getInternalStorage();
        DataType dtype = dataV.getDataType();
        return Array.factory( dtype, makeShape( dataV.darray), storage);
      }
    }

    String mess = "Unknown baseType "+dataV.bt.getClass().getName()+" name="+ dataV.getEncodedName();
    logger.error(mess);
    throw new IllegalStateException(mess);
  }
public Array convert(DodsV dataV) throws IOException, DAP2Exception {

    // scalars
    if (dataV.darray == null) {

      if (dataV.bt instanceof DStructure) {
        ArrayStructure structArray = makeArrayStructure( dataV);
        iconvertDataStructure( (DStructure) dataV.bt, structArray.getStructureMembers());
        return structArray;

      } else if (dataV.bt instanceof DGrid) {
        throw new IllegalStateException( "DGrid without a darray");

      } else if (dataV.bt instanceof DSequence) {
        ArrayStructure structArray = makeArrayStructure( dataV);
        iconvertDataSequenceArray( (DSequence) dataV.bt, structArray.getStructureMembers());
        return structArray;

      } else { // scalar
        DataType dtype = dataV.getDataType();
        Array scalarData = Array.factory(  dtype, new int[0]);
        IndexIterator scalarIndex = scalarData.getIndexIterator();
        iconvertDataPrimitiveScalar( dataV.bt, scalarIndex);
        return scalarData;
      }
    }

    // arrays
    if (dataV.darray != null) {

      if (dataV.bt instanceof DStructure) {
        ArrayStructure structArray = makeArrayStructure( dataV);
        iconvertDataStructureArray( dataV.darray, structArray.getStructureMembers());
        return structArray;

      } else if (dataV.bt instanceof DString) {
        return convertStringArray(dataV.darray);

      } else {
        // the DGrid case comes here also
        // create the array, using  DODS internal array so there's no copying
        opendap.dap.PrimitiveVector pv = dataV.darray.getPrimitiveVector();
        Object storage = pv.getInternalStorage();
        DataType dtype = dataV.getDataType();
        return Array.factory( dtype, makeShape( dataV.darray), storage);
      }
    }

    String mess = "Unknown baseType "+dataV.bt.getClass().getName()+" name="+ dataV.getEncodedName();
    logger.error(mess);
    throw new IllegalStateException(mess);
  }
Convert a DataDDS into an Array

@param dataV the dataDDS has been parsed into this dodsV
@return the data as as Array
@throws IOException on io error
@throws DAP2Exception on bad