Class TIFFTag

  • All Implemented Interfaces:
    TIFFConstants

    public class TIFFTag
    extends Object
    implements TIFFConstants
    This encapsulates the data stored in a TIFF tag (a single image file directory entry). That includes the following items:
    • identification number, 254 or higher; see the many TAG_xyz constants in TIFFConstants for a list of allowed values
    • type; the allowed types include integer and floating point numbers, Strings etc.; see the TAG_TYPE_xyz constants in TIFFConstants
    • count; the number of values of the given type that are stored in this tag; 1 or higher
    • offset; if count is 1 and the type fits into four bytes, this is the complete value of this tag; otherwise, it is an offset into the file to the position that will hold the value(s)
    See the TIFF specification manual linked in the description of TIFFCodec for more details.
    Author:
    Marco Schmidt
    See Also:
    TIFFImageFileDirectory
    • Field Detail

      • id

        private int id
      • type

        private int type
      • count

        private int count
      • offset

        private int offset
      • objects

        private Vector objects
    • Constructor Detail

      • TIFFTag

        public TIFFTag​(int id,
                       int type,
                       int count,
                       int offset)
        Creates a new tag with the given ID, type, number of objects / primitives stored in it and offset value.
      • TIFFTag

        public TIFFTag​(int id,
                       int type,
                       int count,
                       int offset,
                       Vector vector)
    • Method Detail

      • getCount

        public int getCount()
        Returns the number of items stored in this tag.
      • getElementAsInt

        public int getElementAsInt​(int index)
        Returns an item stored in this tag an int value.
        Parameters:
        index - zero-based index of the integer item to be returned
      • getId

        public int getId()
        Returns the ID of this tag, which may be one of the TAG_xyz constants.
      • getObject

        public Object getObject​(int index)
        Returns an object from this tag's Vector of items, or null if no such Vector exists.
      • getOffset

        public int getOffset()
        Returns the offset value stored in this tag.
      • getString

        public String getString()
        If this tag has a Vector of items and if the first item is a String, that String is returned, null otherwise.
      • getType

        public int getType()
        Returns the type of this tag's content as a TAG_TYPE_xyz constant.
      • isInt

        public boolean isInt()
        Returns if the value(s) stored in this tag are of type BYTE, SHORT or LONG. Note that BYTE and SHORT have the same meaning as in Java (one and two bytes large) while LONG is a 32-bit-value, just like int in Java.
        Returns:
        if this tag's contains integer values <= 32 bits
      • setVector

        public void setVector​(Vector vector)
        If this tag encapsulates more than one item or a single item that does not fit into four bytes, this Vector will store all elements in it. The size() method called on that Vector object returns the same value as getCount().
        Parameters:
        vector - the Vector with the items to be encapsulated by this tag
        See Also:
        getVector()