Java Code Examples for ucar.ma2.DataType#unsignedIntToLong()

The following examples show how to use ucar.ma2.DataType#unsignedIntToLong() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: H5headerNew.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public long readVariableSizeUnsigned(int size) throws IOException {
  long vv;
  if (size == 1) {
    vv = DataType.unsignedByteToShort(raf.readByte());
  } else if (size == 2) {
    if (debugPos) {
      log.debug("position={}", raf.getFilePointer());
    }
    short s = raf.readShort();
    vv = DataType.unsignedShortToInt(s);
  } else if (size == 4) {
    vv = DataType.unsignedIntToLong(raf.readInt());
  } else if (size == 8) {
    vv = raf.readLong();
  } else {
    vv = readVariableSizeN(size);
  }
  return vv;
}
 
Example 2
Source File: H4header.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private long readDDH(List<Tag> alltags, long start) throws IOException {
  raf.seek(start);

  int ndd = DataType.unsignedShortToInt(raf.readShort()); // number of DD blocks
  long link = DataType.unsignedIntToLong(raf.readInt()); // point to the next DDH; link == 0 means no more
  if (debugDD)
    System.out.println(" DDHeader ndd=" + ndd + " link=" + link);

  long pos = raf.getFilePointer();
  for (int i = 0; i < ndd; i++) {
    raf.seek(pos);
    Tag tag = factory();
    pos += 12; // tag usually changed the file pointer
    if (tag.code > 1)
      alltags.add(tag);
  }
  memTracker.add("DD block", start, raf.getFilePointer());
  return link;
}