code: public long getAsLong(int index) {
          switch (type) {
          case TIFF_BYTE: case TIFF_UNDEFINED:
              return ((byte[])data)[index] & 0xff;
          case TIFF_SBYTE:
              return ((byte[])data)[index];
          case TIFF_SHORT:
              return ((char[])data)[index] & 0xffff;
          case TIFF_SSHORT:
              return ((short[])data)[index];
          case TIFF_SLONG:
              return ((int[])data)[index];
          case TIFF_LONG:
              return ((long[])data)[index];
          default:
              throw new ClassCastException();
          }
      }
docs: Returns data in TIFF_BYTE, TIFF_SBYTE, TIFF_UNDEFINED, TIFF_SHORT,
  TIFF_SSHORT, TIFF_SLONG, or TIFF_LONG format as a long.
  
  <p> TIFF_BYTE and TIFF_UNDEFINED data are treated as unsigned;
  that is, no sign extension will take place and the returned
  value will be in the range [0, 255].  TIFF_SBYTE data will
  be returned in the range [-128, 127].
  
  <p> A ClassCastException will be thrown if the field is not of
  type TIFF_BYTE, TIFF_SBYTE, TIFF_UNDEFINED, TIFF_SHORT,
  TIFF_SSHORT, TIFF_SLONG, or TIFF_LONG.