code: public double read(final DataType type) throws IOException {
          if (type == null) {
              throw new NullPointerException("type must not be null.");
          }
          switch (type) {
              case CHAR:
                  ensureAvailable(1);
                  return buffer.get();
              case UCHAR:
                  ensureAvailable(1);
                  return ( (int) buffer.get() ) & 0x000000FF;
              case SHORT:
                  ensureAvailable(2);
                  return buffer.getShort();
              case USHORT:
                  ensureAvailable(2);
                  return ( (int) buffer.getShort() ) & 0x0000FFFF;
              case INT:
                  ensureAvailable(4);
                  return buffer.getInt();
              case UINT:
                  ensureAvailable(4);
                  return ( (long) buffer.getShort() ) & 0x00000000FFFFFFFF;
              case FLOAT:
                  ensureAvailable(4);
                  return buffer.getFloat();
              case DOUBLE:
                  ensureAvailable(8);
                  return buffer.getDouble();
              default:
                  throw new IllegalArgumentException("Unsupported type: " + type);
          }
      }
docs: Reads a value from the stream.
  @param type Encoding of the value in the binary stream.
  @return Value casted to {@code double}.
  @throws IOException if reading the value fails.
  @throws NullPointerException if {@code type} is {@code null}.