/** * Gets the {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL} data. * * @throws IllegalArgumentException If the type is NOT * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}. */ protected Rational getRational( int index ) { if( ( mDataType != TYPE_RATIONAL ) && ( mDataType != TYPE_UNSIGNED_RATIONAL ) ) { throw new IllegalArgumentException( "Cannot get RATIONAL value from " + convertTypeToString( mDataType ) ); } return ( (Rational[]) mValue )[index]; }
/** * Gets the {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL} data. * * @throws IllegalArgumentException If the type is NOT * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}. */ protected Rational getRational( int index ) { if( ( mDataType != TYPE_RATIONAL ) && ( mDataType != TYPE_UNSIGNED_RATIONAL ) ) { throw new IllegalArgumentException( "Cannot get RATIONAL value from " + convertTypeToString( mDataType ) ); } return ( (Rational[]) mValue )[index]; }
/** * Gets the {@link #TYPE_ASCII} data. * * @throws IllegalArgumentException If the type is NOT * {@link #TYPE_ASCII}. */ protected String getString() { if( mDataType != TYPE_ASCII ) { throw new IllegalArgumentException( "Cannot get ASCII value from " + convertTypeToString( mDataType ) ); } return new String( (byte[]) mValue, US_ASCII ); }
/** * Gets the {@link #TYPE_ASCII} data. * * @throws IllegalArgumentException If the type is NOT * {@link #TYPE_ASCII}. */ protected String getString() { if( mDataType != TYPE_ASCII ) { throw new IllegalArgumentException( "Cannot get ASCII value from " + convertTypeToString( mDataType ) ); } return new String( (byte[]) mValue, US_ASCII ); }
/** * Gets the value for type {@link #TYPE_ASCII}, {@link #TYPE_LONG}, * {@link #TYPE_UNDEFINED}, {@link #TYPE_UNSIGNED_BYTE}, * {@link #TYPE_UNSIGNED_LONG}, or {@link #TYPE_UNSIGNED_SHORT}. For * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}, call * {@link #getRational(int)} instead. * * @throws IllegalArgumentException if the data type is * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}. */ protected long getValueAt( int index ) { if( mValue instanceof long[] ) { return ( (long[]) mValue )[index]; } else if( mValue instanceof byte[] ) { return ( (byte[]) mValue )[index]; } throw new IllegalArgumentException( "Cannot get integer value from " + convertTypeToString( mDataType ) ); }
/** * Gets the value for type {@link #TYPE_ASCII}, {@link #TYPE_LONG}, * {@link #TYPE_UNDEFINED}, {@link #TYPE_UNSIGNED_BYTE}, * {@link #TYPE_UNSIGNED_LONG}, or {@link #TYPE_UNSIGNED_SHORT}. For * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}, call * {@link #getRational(int)} instead. * * @throws IllegalArgumentException if the data type is * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}. */ protected long getValueAt( int index ) { if( mValue instanceof long[] ) { return ( (long[]) mValue )[index]; } else if( mValue instanceof byte[] ) { return ( (byte[]) mValue )[index]; } throw new IllegalArgumentException( "Cannot get integer value from " + convertTypeToString( mDataType ) ); }
/** * Gets the {@link #TYPE_UNDEFINED} or {@link #TYPE_UNSIGNED_BYTE} data. * * @param buf the byte array in which to store the bytes read. * @param offset the initial position in buffer to store the bytes. * @param length the maximum number of bytes to store in buffer. If length > * component count, only the valid bytes will be stored. * @throws IllegalArgumentException If the type is NOT * {@link #TYPE_UNDEFINED} or {@link #TYPE_UNSIGNED_BYTE}. */ protected void getBytes( byte[] buf, int offset, int length ) { if( ( mDataType != TYPE_UNDEFINED ) && ( mDataType != TYPE_UNSIGNED_BYTE ) ) { throw new IllegalArgumentException( "Cannot get BYTE value from " + convertTypeToString( mDataType ) ); } System.arraycopy( mValue, 0, buf, offset, ( length > mComponentCountActual ) ? mComponentCountActual : length ); }
/** * Gets the {@link #TYPE_UNDEFINED} or {@link #TYPE_UNSIGNED_BYTE} data. * * @param buf the byte array in which to store the bytes read. * @param offset the initial position in buffer to store the bytes. * @param length the maximum number of bytes to store in buffer. If length > * component count, only the valid bytes will be stored. * @throws IllegalArgumentException If the type is NOT * {@link #TYPE_UNDEFINED} or {@link #TYPE_UNSIGNED_BYTE}. */ protected void getBytes( byte[] buf, int offset, int length ) { if( ( mDataType != TYPE_UNDEFINED ) && ( mDataType != TYPE_UNSIGNED_BYTE ) ) { throw new IllegalArgumentException( "Cannot get BYTE value from " + convertTypeToString( mDataType ) ); } System.arraycopy( mValue, 0, buf, offset, ( length > mComponentCountActual ) ? mComponentCountActual : length ); }
@Override public String toString() { return String.format( "tag id: %04X\n", mTagId ) + "ifd id: " + mIfd + "\ntype: " + convertTypeToString( mDataType ) + "\ncount: " + mComponentCountActual + "\noffset: " + mOffset + "\nvalue: " + forceGetValueAsString() + "\n"; }
@Override public String toString() { return String.format( "tag id: %04X\n", mTagId ) + "ifd id: " + mIfd + "\ntype: " + convertTypeToString( mDataType ) + "\ncount: " + mComponentCountActual + "\noffset: " + mOffset + "\nvalue: " + forceGetValueAsString() + "\n"; }