Class ExifTag

  • All Implemented Interfaces:

    
    public class ExifTag
    
                        

    This class stores information of an EXIF tag. For more information about defined EXIF tags, please read the Jeita EXIF 2.2 standard. Tags should be instantiated using buildTag.

    • Constructor Detail

    • Method Detail

      • isValidIfd

         static boolean isValidIfd(int ifdId)

        Returns true if the given IFD is a valid IFD.

      • isValidType

         static boolean isValidType(short type)

        Returns true if a given type is a valid tag type.

      • getElementSize

         static int getElementSize(short type)

        Gets the element size of the given data type in bytes.

      • getIfd

         int getIfd()

        Returns the ID of the IFD this tag belongs to.

      • getTagId

         short getTagId()

        Gets the TID of this tag.

      • getDataType

         short getDataType()

        Gets the data type of this tag

      • getDataSize

         int getDataSize()

        Gets the total data size in bytes of the value of this tag.

      • hasValue

         boolean hasValue()

        Returns true if this ExifTag contains value; otherwise, this tag will contain an offset value that is determined when the tag is written.

      • setValue

         boolean setValue(Array<long> value)

        Sets long values into this tag. This method should be used for tags of type TYPE_UNSIGNED_LONG. This method will fail if:

        • The component type of this tag is not TYPE_UNSIGNED_LONG.
        • The value overflows.
        • The value.length does NOT match the component count in the definition for this tag.
      • setValue

         boolean setValue(long value)

        Sets long values into this tag. This method should be used for tags of type TYPE_UNSIGNED_LONG. This method will fail if:

        • The component type of this tag is not TYPE_UNSIGNED_LONG.
        • The value overflows.
        • The component count in the definition for this tag is not 1.
      • setValue

         boolean setValue(String value)

        Sets a string value into this tag. This method should be used for tags of type TYPE_ASCII. The string is converted to an ASCII string. Characters that cannot be converted are replaced with '?'. The length of the string must be equal to either (component count -1) or (component count). The final byte will be set to the string null terminator '\0', overwriting the last character in the string if the value.length is equal to the component count. This method will fail if:

        • The data type is not TYPE_ASCII or TYPE_UNDEFINED.
        • The length of the string is not equal to (component count -1) or (component count) in the definition for this tag.
      • setValue

         boolean setValue(Array<byte> value)

        Equivalent to setValue(value, 0, value.length).

      • setValue

         boolean setValue(Object obj)

        Sets the value for this tag using an appropriate setValue method for the given object. This method will fail if:

        • The corresponding setValue method for the class of the object passed in would fail.
        • There is no obvious way to cast the object passed in into an EXIF tag type.
      • setTimeValue

         boolean setTimeValue(long time)

        Sets a timestamp to this tag. The method converts the timestamp with the format of "yyyy:MM:dd kk:mm:ss" and calls setValue. This method will fail if the data type is not TYPE_ASCII or the component count of this tag is not 20 or undefined.

        Parameters:
        time - the number of milliseconds since Jan.
      • getValueAsString

         String getValueAsString(String defaultValue)

        Gets the value as a String. This method should be used for tags of type TYPE_ASCII.

        Parameters:
        defaultValue - the String to return if the tag's value does not exist or cannot be converted to a String.
      • getValueAsByte

         byte getValueAsByte(byte defaultValue)

        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 TYPE_UNDEFINED or TYPE_UNSIGNED_BYTE.

        Parameters:
        defaultValue - the byte to return if tag's value does not exist or cannot be converted to a byte.
      • getValueAsRational

         Rational getValueAsRational(Rational defaultValue)

        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 TYPE_RATIONAL or TYPE_UNSIGNED_RATIONAL.

        Parameters:
        defaultValue - the Rational to return if tag's value does not exist or cannot be converted to a Rational.
      • getValueAsRational

         Rational getValueAsRational(long defaultValue)

        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 TYPE_RATIONAL or TYPE_UNSIGNED_RATIONAL.

        Parameters:
        defaultValue - the numerator of the Rational to return if tag's value does not exist or cannot be converted to a Rational (the denominator will be 1).
      • getValueAsInt

         int getValueAsInt(int defaultValue)

        Gets the value as an int. If there are more than 1 ints in this value, gets the first one. This method should be used for tags of type TYPE_UNSIGNED_SHORT, TYPE_UNSIGNED_LONG.

        Parameters:
        defaultValue - the int to return if tag's value does not exist or cannot be converted to an int.
      • getValueAsLong

         long getValueAsLong(long defaultValue)

        Gets the value or null if none exists. If there are more than 1 longs in this value, gets the first one. This method should be used for tags of type TYPE_UNSIGNED_LONG.

        Parameters:
        defaultValue - the long to return if tag's value does not exist or cannot be converted to a long.
      • getValue

         Object getValue()

        Gets the tag's value or null if none exists.

      • forceGetValueAsLong

         long forceGetValueAsLong(long defaultValue)

        Gets a long representation of the value.

        Parameters:
        defaultValue - value to return if there is no value or value is a rational with a denominator of 0.