1269
1270 /**
1271 * Returns a TIFFTag.TIFF_RATIONAL data item as a two-element array
1272 * of ints.
1273 *
1274 * @param index The index of the data.
1275 * @return The data at the given index as an unsigned rational.
1276 * @throws ClassCastException if the field is not of type
1277 * {@code TIFF_RATIONAL}.
1278 */
1279 public long[] getAsRational(int index) {
1280 return ((long[][])data)[index];
1281 }
1282
1283
1284 /**
1285 * Returns a {@code String} containing a human-readable
1286 * version of the data item. Data of type
1287 * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} are
1288 * represented as a pair of integers separated by a
1289 * {@code '/'} character.
1290 *
1291 * @param index The index of the data.
1292 * @return The data at the given index as a {@code String}.
1293 * @throws ClassCastException if the field is not of one of the
1294 * legal field types.
1295 */
1296 public String getValueAsString(int index) {
1297 switch (type) {
1298 case TIFFTag.TIFF_ASCII:
1299 return ((String[])data)[index];
1300 case TIFFTag.TIFF_BYTE:
1301 case TIFFTag.TIFF_UNDEFINED:
1302 return Integer.toString(((byte[])data)[index] & 0xff);
1303 case TIFFTag.TIFF_SBYTE:
1304 return Integer.toString(((byte[])data)[index]);
1305 case TIFFTag.TIFF_SHORT:
1306 return Integer.toString(((char[])data)[index] & 0xffff);
1307 case TIFFTag.TIFF_SSHORT:
1308 return Integer.toString(((short[])data)[index]);
1309 case TIFFTag.TIFF_SLONG:
|
1269
1270 /**
1271 * Returns a TIFFTag.TIFF_RATIONAL data item as a two-element array
1272 * of ints.
1273 *
1274 * @param index The index of the data.
1275 * @return The data at the given index as an unsigned rational.
1276 * @throws ClassCastException if the field is not of type
1277 * {@code TIFF_RATIONAL}.
1278 */
1279 public long[] getAsRational(int index) {
1280 return ((long[][])data)[index];
1281 }
1282
1283
1284 /**
1285 * Returns a {@code String} containing a human-readable
1286 * version of the data item. Data of type
1287 * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} are
1288 * represented as a pair of integers separated by a
1289 * {@code '/'} character. If the numerator of a
1290 * {@code TIFFTag.TIFF_RATIONAL} or {@code TIFF_SRATIONAL} is an integral
1291 * multiple of the denominator, then the value is represented as
1292 * {@code "q/1"} where {@code q} is the quotient of the numerator and
1293 * denominator.
1294 *
1295 * @param index The index of the data.
1296 * @return The data at the given index as a {@code String}.
1297 * @throws ClassCastException if the field is not of one of the
1298 * legal field types.
1299 */
1300 public String getValueAsString(int index) {
1301 switch (type) {
1302 case TIFFTag.TIFF_ASCII:
1303 return ((String[])data)[index];
1304 case TIFFTag.TIFF_BYTE:
1305 case TIFFTag.TIFF_UNDEFINED:
1306 return Integer.toString(((byte[])data)[index] & 0xff);
1307 case TIFFTag.TIFF_SBYTE:
1308 return Integer.toString(((byte[])data)[index]);
1309 case TIFFTag.TIFF_SHORT:
1310 return Integer.toString(((char[])data)[index] & 0xffff);
1311 case TIFFTag.TIFF_SSHORT:
1312 return Integer.toString(((short[])data)[index]);
1313 case TIFFTag.TIFF_SLONG:
|