java.lang.Object
javax.imageio.plugins.tiff.TIFFTag
A class defining the notion of a TIFF tag.  A TIFF tag is a key
 that may appear in an Image File Directory (IFD).  In the IFD
 each tag has some data associated with it, which may consist of zero
 or more values of a given data type. The combination of a tag and a
 value is known as an IFD Entry or TIFF Field.
 
 The actual tag values used in the root IFD of a standard ("baseline")
 tiff stream are defined in the BaselineTIFFTagSet class.
- Since:
- 9
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intThe numerically largest constant representing a TIFF data type.static final intThe numerically smallest constant representing a TIFF data type.static final intFlag for null-terminated ASCII strings.static final intFlag for 8 bit unsigned integers.static final intFlag for 64 bit IEEE doubles.static final intFlag for 32 bit IEEE floats.static final intFlag for IFD pointer defined in TIFF Tech Note 1 in TIFF Specification Supplement 1.static final intFlag for 32 bit unsigned integers.static final intFlag for pairs of 32 bit unsigned integers.static final intFlag for 8 bit signed integers.static final intFlag for 16 bit unsigned integers.static final intFlag for 32 bit signed integers.static final intFlag for pairs of 32 bit signed integers.static final intFlag for 16 bit signed integers.static final intFlag for 8 bit uninterpreted bytes.static final StringThe name assigned to a tag with an unknown tag number.
- 
Constructor SummaryConstructorsConstructorDescriptionConstructs aTIFFTagwith a given name, tag number, and set of legal data types.Constructs aTIFFTagwith a given name, tag number, set of legal data types, and value count.TIFFTag(String name, int number, TIFFTagSet tagSet) Constructs aTIFFTagwith a given name, tag number andTIFFTagSetto which it refers.
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddValueName(int value, String name) Adds a mnemonic name for a particular value that this tag's data may take on.intgetCount()Returns the value count of this tag.intReturns a bit mask indicating the set of data types that may be used to store the data associated with the tag.getName()Returns the name of the tag, as it will appear in image metadata.int[]Returns an array of values for which mnemonic names are defined.intReturns the integer used to represent the tag.static intgetSizeOfType(int dataType) Returns the number of bytes used to store a value of the given data type.Returns theTIFFTagSetof which this tag is a part.getValueName(int value) Returns the mnemonic name associated with a particular value that this tag's data may take on, ornullif no name is present.booleanReturnstrueif there are mnemonic names associated with the set of legal values for the data associated with this tag.booleanisDataTypeOK(int dataType) Returnstrueif the given data type may be used for the data associated with this tag.booleanReturnstrueif this tag is used to point to an IFD structure containing additional tags.
- 
Field Details- 
TIFF_BYTEpublic static final int TIFF_BYTEFlag for 8 bit unsigned integers.- See Also:
 
- 
TIFF_ASCIIpublic static final int TIFF_ASCIIFlag for null-terminated ASCII strings.- See Also:
 
- 
TIFF_SHORTpublic static final int TIFF_SHORTFlag for 16 bit unsigned integers.- See Also:
 
- 
TIFF_LONGpublic static final int TIFF_LONGFlag for 32 bit unsigned integers.- See Also:
 
- 
TIFF_RATIONALpublic static final int TIFF_RATIONALFlag for pairs of 32 bit unsigned integers.- See Also:
 
- 
TIFF_SBYTEpublic static final int TIFF_SBYTEFlag for 8 bit signed integers.- See Also:
 
- 
TIFF_UNDEFINEDpublic static final int TIFF_UNDEFINEDFlag for 8 bit uninterpreted bytes.- See Also:
 
- 
TIFF_SSHORTpublic static final int TIFF_SSHORTFlag for 16 bit signed integers.- See Also:
 
- 
TIFF_SLONGpublic static final int TIFF_SLONGFlag for 32 bit signed integers.- See Also:
 
- 
TIFF_SRATIONALpublic static final int TIFF_SRATIONALFlag for pairs of 32 bit signed integers.- See Also:
 
- 
TIFF_FLOATpublic static final int TIFF_FLOATFlag for 32 bit IEEE floats.- See Also:
 
- 
TIFF_DOUBLEpublic static final int TIFF_DOUBLEFlag for 64 bit IEEE doubles.- See Also:
 
- 
TIFF_IFD_POINTERpublic static final int TIFF_IFD_POINTERFlag for IFD pointer defined in TIFF Tech Note 1 in TIFF Specification Supplement 1.- See Also:
 
- 
MIN_DATATYPEpublic static final int MIN_DATATYPEThe numerically smallest constant representing a TIFF data type.- See Also:
 
- 
MAX_DATATYPEpublic static final int MAX_DATATYPEThe numerically largest constant representing a TIFF data type.- See Also:
 
- 
UNKNOWN_TAG_NAMEThe name assigned to a tag with an unknown tag number. Such a tag may be created for example when reading an IFD and a tag number is encountered which is not in any of theTIFFTagSets known to the reader.- See Also:
 
 
- 
- 
Constructor Details- 
TIFFTagConstructs aTIFFTagwith a given name, tag number, set of legal data types, and value count. A negative value count signifies that either an arbitrary number of values is legal or the required count is determined by the values of other fields in the IFD. A non-negative count specifies the number of values which an associated field must contain. The tag will have no associatedTIFFTagSet.If there are mnemonic names to be associated with the legal data values for the tag, addValueName()should be called on the new instance for each name. Mnemonic names apply only to tags which have integral data type.See the documentation for getDataTypes()for an explanation of how the set of data types is to be converted into a bit mask.- Parameters:
- name- the name of the tag.
- number- the number used to represent the tag.
- dataTypes- a bit mask indicating the set of legal data types for this tag.
- count- the value count for this tag.
- Throws:
- NullPointerException- if name is null.
- IllegalArgumentException- if number is negative or dataTypes is negative or specifies an out of range type.
 
- 
TIFFTagConstructs aTIFFTagwith a given name, tag number andTIFFTagSetto which it refers. The legal data types are set to includeTIFF_LONGandTIFF_IFD_POINTERand the value count is unity. TheTIFFTagSetwill represent the set ofTIFFTags which appear in the IFD pointed to. ATIFFTagrepresents an IFD pointer if and only iftagSetis non-nullor the data typeTIFF_IFD_POINTERis legal.- Parameters:
- name- the name of the tag.
- number- the number used to represent the tag.
- tagSet- the- TIFFTagSetto which this tag belongs.
- Throws:
- NullPointerException- if name or tagSet is null.
- IllegalArgumentException- if number is negative.
- See Also:
 
- 
TIFFTagConstructs aTIFFTagwith a given name, tag number, and set of legal data types. The value count of the tag will be undefined and it will have no associatedTIFFTagSet.- Parameters:
- name- the name of the tag.
- number- the number used to represent the tag.
- dataTypes- a bit mask indicating the set of legal data types for this tag.
- Throws:
- NullPointerException- if name is null.
- IllegalArgumentException- if number is negative or dataTypes is negative or specifies an out of range type.
- See Also:
 
 
- 
- 
Method Details- 
getSizeOfTypepublic static int getSizeOfType(int dataType) Returns the number of bytes used to store a value of the given data type.- Parameters:
- dataType- the data type to be queried.
- Returns:
- the number of bytes used to store the given data type.
- Throws:
- IllegalArgumentException- if- datatypeis less than- MIN_DATATYPEor greater than- MAX_DATATYPE.
 
- 
getNameReturns the name of the tag, as it will appear in image metadata.- Returns:
- the tag name, as a String.
 
- 
getNumberpublic int getNumber()Returns the integer used to represent the tag.- Returns:
- the tag number, as an int.
 
- 
getDataTypespublic int getDataTypes()Returns a bit mask indicating the set of data types that may be used to store the data associated with the tag. For example, a tag that can store both SHORT and LONG values would return a value of:(1 << TIFFTag.TIFF_SHORT) | (1 << TIFFTag.TIFF_LONG) - Returns:
- an intcontaining a bitmask encoding the set of valid data types.
 
- 
getCountpublic int getCount()Returns the value count of this tag. If this value is positive, it represents the required number of values for aTIFFFieldwhich has this tag. If the value is negative, the count is undefined. In the latter case the count may be derived, e.g., the number of values of theBitsPerSamplefield isSamplesPerPixel, or it may be variable as in the case of mostUS-ASCIIfields.- Returns:
- the value count of this tag.
 
- 
isDataTypeOKpublic boolean isDataTypeOK(int dataType) Returnstrueif the given data type may be used for the data associated with this tag.- Parameters:
- dataType- the data type to be queried, one of- TIFF_BYTE,- TIFF_SHORT, etc.
- Returns:
- a booleanindicating whether the given data type may be used with this tag.
- Throws:
- IllegalArgumentException- if- datatypeis less than- MIN_DATATYPEor greater than- MAX_DATATYPE.
 
- 
getTagSetReturns theTIFFTagSetof which this tag is a part.- Returns:
- the containing TIFFTagSet.
 
- 
isIFDPointerpublic boolean isIFDPointer()Returnstrueif this tag is used to point to an IFD structure containing additional tags. ATIFFTagrepresents an IFD pointer if and only if itsTIFFTagSetis non-nullor the data typeTIFF_IFD_POINTERis legal. This condition will be satisfied if and only if eithergetTagSet() != nullorisDataTypeOK(TIFF_IFD_POINTER) == true.Many TIFF extensions use the IFD mechanism in order to limit the number of new tags that may appear in the root IFD. - Returns:
- trueif this tag points to an IFD.
 
- 
hasValueNamespublic boolean hasValueNames()Returnstrueif there are mnemonic names associated with the set of legal values for the data associated with this tag. Mnemonic names apply only to tags which have integral data type.- Returns:
- trueif mnemonic value names are available.
 
- 
addValueNameAdds a mnemonic name for a particular value that this tag's data may take on. Mnemonic names apply only to tags which have integral data type.- Parameters:
- value- the data value.
- name- the name to associate with the value.
 
- 
getValueNameReturns the mnemonic name associated with a particular value that this tag's data may take on, ornullif no name is present. Mnemonic names apply only to tags which have integral data type.- Parameters:
- value- the data value.
- Returns:
- the mnemonic name associated with the value, as a
 String.
 
- 
getNamedValuespublic int[] getNamedValues()Returns an array of values for which mnemonic names are defined. The methodgetValueName()will return non-nullonly for values contained in the returned array. Mnemonic names apply only to tags which have integral data type.- Returns:
- the values for which there is a mnemonic name.
 
 
-