Object readDataPrimitive(Layout layout, DataType dataType, int[] shape, Object fillValue, int endian, boolean convertChar) throws java.io.IOException, InvalidRangeException {

    if (dataType == DataType.STRING) {
      int size = (int) layout.getTotalNelems();
      String[] sa = new String[size];
      int count = 0;
      while (layout.hasNext()) {
        Layout.Chunk chunk = layout.next();
        if (chunk == null) continue;
        for (int i = 0; i < chunk.getNelems(); i++) { // 16 byte "heap ids"
          sa[count++] = headerParser.readHeapString(chunk.getSrcPos() + layout.getElemSize() * i);
        }
      }
      return sa;
    }

    if (dataType == DataType.OPAQUE) {
      Array opArray = Array.factory(DataType.OPAQUE, shape);
      assert (new Section(shape).computeSize() == layout.getTotalNelems());

      int count = 0;
      while (layout.hasNext()) {
        Layout.Chunk chunk = layout.next();
        if (chunk == null) continue;
        int recsize = layout.getElemSize();
        for (int i = 0; i < chunk.getNelems(); i++) {
          byte[] pa = new byte[recsize];
          raf.seek(chunk.getSrcPos() + i * recsize);
          raf.readFully(pa, 0, recsize);
          opArray.setObject(count++, ByteBuffer.wrap(pa));
        }
      }
      return opArray;
    }

    // normal case
    return IospHelper.readDataFill(raf, layout, dataType, fillValue, endian, convertChar);
  }
Object readDataPrimitive(Layout layout, DataType dataType, int[] shape, Object fillValue, int endian, boolean convertChar) throws java.io.IOException, InvalidRangeException {

    if (dataType == DataType.STRING) {
      int size = (int) layout.getTotalNelems();
      String[] sa = new String[size];
      int count = 0;
      while (layout.hasNext()) {
        Layout.Chunk chunk = layout.next();
        if (chunk == null) continue;
        for (int i = 0; i < chunk.getNelems(); i++) { 
          sa[count++] = headerParser.readHeapString(chunk.getSrcPos() + layout.getElemSize() * i);
        }
      }
      return sa;
    }

    if (dataType == DataType.OPAQUE) {
      Array opArray = Array.factory(DataType.OPAQUE, shape);
      assert (new Section(shape).computeSize() == layout.getTotalNelems());

      int count = 0;
      while (layout.hasNext()) {
        Layout.Chunk chunk = layout.next();
        if (chunk == null) continue;
        int recsize = layout.getElemSize();
        for (int i = 0; i < chunk.getNelems(); i++) {
          byte[] pa = new byte[recsize];
          raf.seek(chunk.getSrcPos() + i * recsize);
          raf.readFully(pa, 0, recsize);
          opArray.setObject(count++, ByteBuffer.wrap(pa));
        }
      }
      return opArray;
    }

    
    return IospHelper.readDataFill(raf, layout, dataType, fillValue, endian, convertChar);
  }
Object readDataPrimitive ( Layout layout , DataType dataType , int [ ] shape , Object fillValue , int endian , boolean convertChar ) throws java . io . IOException , InvalidRangeException { if ( dataType == DataType . STRING ) { int size = ( int ) layout . getTotalNelems ( ) ; String [ ] sa = new String [ size ] ; int count = 0 ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; if ( chunk == null ) continue ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) { // 16 byte "heap ids" sa [ count ++ ] = headerParser . readHeapString ( chunk . getSrcPos ( ) + layout . getElemSize ( ) * i ) ; } } return sa ; } if ( dataType == DataType . OPAQUE ) { Array opArray = Array . factory ( DataType . OPAQUE , shape ) ; assert ( new Section ( shape ) . computeSize ( ) == layout . getTotalNelems ( ) ) ; int count = 0 ; while ( layout . hasNext ( ) ) { Layout . Chunk chunk = layout . next ( ) ; if ( chunk == null ) continue ; int recsize = layout . getElemSize ( ) ; for ( int i = 0 ; i < chunk . getNelems ( ) ; i ++ ) { byte [ ] pa = new byte [ recsize ] ; raf . seek ( chunk . getSrcPos ( ) + i * recsize ) ; raf . readFully ( pa , 0 , recsize ) ; opArray . setObject ( count ++ , ByteBuffer . wrap ( pa ) ) ; } } return opArray ; } // normal case return IospHelper . readDataFill ( raf , layout , dataType , fillValue , endian , convertChar ) ; }
/*
Read data subset from file for a variable, create primitive array.

@param layout     handles skipping around in the file.
@param dataType  dataType of the variable
@param shape     the shape of the output
@param fillValue fill value as a wrapped primitive
@param endian byte order
@return primitive array with data read in
@throws java.io.IOException            if read error
@throws ucar.ma2.InvalidRangeException if invalid section
/ * Read data subset from file for a variable create primitive array .