/** * Gets the value as a Rational. If there are more than 1 Rationals in this * value, gets the first one. This method should be used for tags of type * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}. * * @param defaultValue the Rational to return if tag's value does not exist * or cannot be converted to a Rational. * @return the tag's value as a Rational, or the defaultValue. */ public Rational getValueAsRational( Rational defaultValue ) { Rational[] r = getValueAsRationals(); if( r == null || r.length < 1 ) { return defaultValue; } return r[0]; }
/** * Gets the value as a Rational. If there are more than 1 Rationals in this * value, gets the first one. This method should be used for tags of type * {@link #TYPE_RATIONAL} or {@link #TYPE_UNSIGNED_RATIONAL}. * * @param defaultValue the Rational to return if tag's value does not exist * or cannot be converted to a Rational. * @return the tag's value as a Rational, or the defaultValue. */ public Rational getValueAsRational( Rational defaultValue ) { Rational[] r = getValueAsRationals(); if( r == null || r.length < 1 ) { return defaultValue; } return r[0]; }
/** * @see #getTagValue */ public Rational[] getTagRationalValues( int tagId, int ifdId ) { ExifTag t = getTag( tagId, ifdId ); if( t == null ) { return null; } return t.getValueAsRationals(); }
/** * @see #getTagValue */ public Rational[] getTagRationalValues( int tagId, int ifdId ) { ExifTag t = getTag( tagId, ifdId ); if( t == null ) { return null; } return t.getValueAsRationals(); }
/** * 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; }