/** * Gets the value as a byte. If there are more than 1 bytes in this value, * gets the first byte. This method should be used for tags of type * {@link #TYPE_UNDEFINED} or {@link #TYPE_UNSIGNED_BYTE}. * * @param defaultValue the byte to return if tag's value does not exist or * cannot be converted to a byte. * @return the tag's value as a byte, or the defaultValue. */ public byte getValueAsByte( byte defaultValue ) { byte[] b = getValueAsBytes(); if( b == null || b.length < 1 ) { return defaultValue; } return b[0]; }
/** * Gets the value as a byte. If there are more than 1 bytes in this value, * gets the first byte. This method should be used for tags of type * {@link #TYPE_UNDEFINED} or {@link #TYPE_UNSIGNED_BYTE}. * * @param defaultValue the byte to return if tag's value does not exist or * cannot be converted to a byte. * @return the tag's value as a byte, or the defaultValue. */ public byte getValueAsByte( byte defaultValue ) { byte[] b = getValueAsBytes(); if( b == null || b.length < 1 ) { return defaultValue; } return b[0]; }
/** * @see #getTagValue */ public byte[] getTagByteValues( int tagId, int ifdId ) { ExifTag t = getTag( tagId, ifdId ); if( t == null ) { return null; } return t.getValueAsBytes(); }
/** * @see #getTagValue */ public byte[] getTagByteValues( int tagId, int ifdId ) { ExifTag t = getTag( tagId, ifdId ); if( t == null ) { return null; } return t.getValueAsBytes(); }
/** * Gets a long representation of the value. * * @param defaultValue value to return if there is no value or value is a * rational with a denominator of 0. * @return the tag's value as a long, or defaultValue if no representation * exists. */ public long forceGetValueAsLong( long defaultValue ) { long[] l = getValueAsLongs(); if( l != null && l.length >= 1 ) { return l[0]; } byte[] b = getValueAsBytes(); if( b != null && b.length >= 1 ) { return b[0]; } Rational[] r = getValueAsRationals(); if( r != null && r.length >= 1 && r[0].getDenominator() != 0 ) { return (long) r[0].toDouble(); } return defaultValue; }
/** * Gets a long representation of the value. * * @param defaultValue value to return if there is no value or value is a * rational with a denominator of 0. * @return the tag's value as a long, or defaultValue if no representation * exists. */ public long forceGetValueAsLong( long defaultValue ) { long[] l = getValueAsLongs(); if( l != null && l.length >= 1 ) { return l[0]; } byte[] b = getValueAsBytes(); if( b != null && b.length >= 1 ) { return b[0]; } Rational[] r = getValueAsRationals(); if( r != null && r.length >= 1 && r[0].getDenominator() != 0 ) { return (long) r[0].toDouble(); } return defaultValue; }