cdm/src/main/java/ucar/nc2/stream/NcStreamDataCol.java
public Array decode(NcStreamProto.DataCol dproto, Section parentSection) throws IOException {

    ByteOrder bo = dproto.getBigend() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;

    DataType dataType = NcStream.convertDataType(dproto.getDataType());
    Section section = (dataType == DataType.SEQUENCE) ? new Section() : NcStream.decodeSection(dproto.getSection());
    if (!dproto.getIsVlen()) {
      assert dproto.getNelems() == section.computeSize();
    }

    // special cases
    if (dproto.getIsVlen()) {
      if (parentSection == null)
        return decodeVlenData(dproto);
      else
        return decodeVlenData(dproto, parentSection);

    } else if (dataType == DataType.STRING) {
      Array data = Array.factory(dataType, section.getShape());
      IndexIterator ii = data.getIndexIterator();
      for (String s : dproto.getStringdataList()) {
        ii.setObjectNext(s);
      }
      return data;

    } else if (dataType == DataType.STRUCTURE) {
      return decodeStructureData(dproto, parentSection);

    } else if (dataType == DataType.OPAQUE) {
      Array data = Array.factory(dataType, section.getShape());
      IndexIterator ii = data.getIndexIterator();
      for (ByteString s : dproto.getOpaquedataList()) {
        ii.setObjectNext(s.asReadOnlyByteBuffer());
      }
      return data;

    } else { // common case
      ByteBuffer bb = dproto.getPrimdata().asReadOnlyByteBuffer();
      bb.order(bo);
      return Array.factory(dataType, section.getShape(), bb);
    }

  }
public Array decode(NcStreamProto.DataCol dproto, Section parentSection) throws IOException {

    ByteOrder bo = dproto.getBigend() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;

    DataType dataType = NcStream.convertDataType(dproto.getDataType());
    Section section = (dataType == DataType.SEQUENCE) ? new Section() : NcStream.decodeSection(dproto.getSection());
    if (!dproto.getIsVlen()) {
      assert dproto.getNelems() == section.computeSize();
    }

    // special cases
    if (dproto.getIsVlen()) {
      if (parentSection == null)
        return decodeVlenData(dproto);
      else
        return decodeVlenData(dproto, parentSection);

    } else if (dataType == DataType.STRING) {
      Array data = Array.factory(dataType, section.getShape());
      IndexIterator ii = data.getIndexIterator();
      for (String s : dproto.getStringdataList()) {
        ii.setObjectNext(s);
      }
      return data;

    } else if (dataType == DataType.STRUCTURE) {
      return decodeStructureData(dproto, parentSection);

    } else if (dataType == DataType.OPAQUE) {
      Array data = Array.factory(dataType, section.getShape());
      IndexIterator ii = data.getIndexIterator();
      for (ByteString s : dproto.getOpaquedataList()) {
        ii.setObjectNext(s.asReadOnlyByteBuffer());
      }
      return data;

    } else { // common case
      ByteBuffer bb = dproto.getPrimdata().asReadOnlyByteBuffer();
      bb.order(bo);
      return Array.factory(dataType, section.getShape(), bb);
    }

  }
public Array decode ( NcStreamProto . DataCol dproto , Section parentSection ) throws IOException { ByteOrder bo = dproto . getBigend ( ) ? ByteOrder . BIG_ENDIAN : ByteOrder . LITTLE_ENDIAN ; DataType dataType = NcStream . convertDataType ( dproto . getDataType ( ) ) ; Section section = ( dataType == DataType . SEQUENCE ) ? new Section ( ) : NcStream . decodeSection ( dproto . getSection ( ) ) ; if ( ! dproto . getIsVlen ( ) ) { assert dproto . getNelems ( ) == section . computeSize ( ) ; } // special cases if ( dproto . getIsVlen ( ) ) { if ( parentSection == null ) return decodeVlenData ( dproto ) ; else return decodeVlenData ( dproto , parentSection ) ; } else if ( dataType == DataType . STRING ) { Array data = Array . factory ( dataType , section . getShape ( ) ) ; IndexIterator ii = data . getIndexIterator ( ) ; for ( String s : dproto . getStringdataList ( ) ) { ii . setObjectNext ( s ) ; } return data ; } else if ( dataType == DataType . STRUCTURE ) { return decodeStructureData ( dproto , parentSection ) ; } else if ( dataType == DataType . OPAQUE ) { Array data = Array . factory ( dataType , section . getShape ( ) ) ; IndexIterator ii = data . getIndexIterator ( ) ; for ( ByteString s : dproto . getOpaquedataList ( ) ) { ii . setObjectNext ( s . asReadOnlyByteBuffer ( ) ) ; } return data ; } else { // common case ByteBuffer bb = dproto . getPrimdata ( ) . asReadOnlyByteBuffer ( ) ; bb . order ( bo ) ; return Array . factory ( dataType , section . getShape ( ) , bb ) ; } }
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////