public abstract class IFD extends Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
_bigEndian
True if big-endian file.
|
protected RepInfo |
_info
Representation information.
|
protected long |
_next
Offset of next IFD.
|
protected long |
_offset
IFD offset.
|
protected int |
_version
TIFF version.
|
static int |
ASCII
TIFF ASCII type.
|
static int |
BYTE
TIFF BYTE (unsigned 8-bit) type.
|
static int |
DOUBLE
TIFF DOUBLE (64-bit IEEE floating point) type.
|
static int |
EXIF
Exif IFD.
|
static int |
FLOAT
TIFF FLOAT (32-bit IEEE floating point) type.
|
static int |
GLOBALPARAMETERS
Global parameters IFD.
|
static int |
GPSINFO
GPSInfo IFD.
|
static int |
IFD
TIFF IFD (LONG) type.
|
static int |
INTEROPERABILITY
Exif Interoperability IFD.
|
static int |
LONG
TIFF LONG (unsigned 32-bit) type.
|
static int |
NULL
Undefined value for integer tags.
|
static int |
RATIONAL
TIFF RATIONAL (two LONGs) type.
|
static int |
SBYTE
TIFF SBYTE (signed 8-bit) type.
|
static int |
SHORT
TIFF SHORT (unsigned 16-bit) type.
|
static int |
SLONG
TIFF SLONG (signed 32-bit) type.
|
static int |
SRATIONAL
TIFF SRATIONAL (two SLONGs) type.
|
static int |
SSHORT
TIFF SSHORT (signed 16-bit) type.
|
static int |
TIFF
Standard TIFF IFD.
|
static String[] |
TYPE
TIFF type labels.
|
static int |
UNDEFINED
TIFF UNDEFINED (unsigned 8-bit) type.
|
Constructor and Description |
---|
IFD(long offset,
RepInfo info,
RandomAccessFile raf,
boolean bigEndian)
Instantiate an
IFD object. |
Modifier and Type | Method and Description |
---|---|
protected Property |
addBitmaskProperty(String name,
long value,
String[] labels,
boolean rawOutput)
Returns a Property representing a bitmask.
|
protected Property |
addIntegerArrayProperty(String name,
int[] value,
String[] labels,
boolean rawOutput)
Returns an ARRAY Property representing an integer array.
|
protected Property |
addIntegerProperty(String name,
int value,
String[] labels,
boolean rawOutput)
Returns an Property representing an integer value.
|
protected Property |
addIntegerProperty(String name,
int value,
String[] labels,
int[] index,
boolean rawOutput)
Returns an Property representing an integer value.
|
protected Property |
addRationalArrayProperty(String name,
Rational[] r,
boolean rawOutput) |
protected Property |
addRationalProperty(String name,
Rational r,
boolean rawOutput)
Returns a property for a tag with a RATIONAL value.
|
protected static Rational |
average(Rational r1,
Rational r2) |
static long |
calcValueSize(int type,
long count)
Calculate how many bytes a given number of fields of a given
type will require.
|
protected static void |
checkCount(int tag,
long count,
int minCount)
Check the tag entry count.
|
protected static void |
checkType(int tag,
int type,
int expected)
Check the tag entry type.
|
protected static void |
checkType(int tag,
int type,
int type1,
int type2)
Check the tag entry type.
|
List<String> |
getErrors()
Get any errors discovered during parsing.
|
long |
getNext()
Get the offset of the next IFD.
|
long |
getOffset()
Get the IFD offset.
|
abstract Property |
getProperty(boolean rawOutput)
Get the IFD properties.
|
int |
getVersion()
Get the TIFF version.
|
boolean |
isBigEndian()
Returns
true if file is big-endian,
false if little-endian. |
boolean |
isFirst()
Return true if this is the first IFD.
|
boolean |
isThumbnail()
Return true if this is the thumbnail IFD.
|
abstract void |
lookupTag(int tag,
int type,
long count,
long value)
Lookup IFD tag.
|
long |
parse()
Parse the IFD.
|
long |
parse(boolean byteOffsetIsValid)
Parse the IFD.
|
long |
parse(boolean byteOffsetIsValid,
boolean suppressErrors)
Parse the IFD.
|
protected void |
postParseInitialization()
Perform initializations that have to wait until after the
IFD has been parsed.
|
protected Property |
propertyHeader(String type,
List entries)
Standard IFD property header.
|
protected String |
readASCII(long count,
long value)
Reads a string value from the TIFF file.
|
protected String[] |
readASCIIArray(long count,
long value)
Reads an array of strings from the TIFF file.
|
protected int |
readByte(int type,
long count,
long value)
Reads and returns a single unsigned 8-bit integer value.
|
protected int[] |
readByteArray(int type,
long count,
long value)
Reads an array of bytes and returns it as an int array.
|
protected double[] |
readDoubleArray(long count,
long value)
Reads a TIFF array of DOUBLE 64-bit values and returns
it as a double array.
|
protected long |
readLong(int type,
long count,
long value)
Reads and returns a single unsigned 32-bit integer value.
|
protected long[] |
readLongArray(int type,
long count,
long value)
Reads a TIFF array of signed 32-bit integer values and returns
it as a long array.
|
protected Rational |
readRational(long count,
long value)
Reads a RATIONAL value and returns it as a Rational.
|
protected Rational[] |
readRationalArray(long count,
long value)
Reads an array of RATIONAL values and returns it as an
array of Rational.
|
protected int |
readShort(int type,
long count,
long value)
Reads and returns a single unsigned 16-bit value.
|
protected int[] |
readShortArray(int type,
long count,
long value)
Reads a TIFF array of unsigned 16-bit values and returns
it as an int array.
|
protected Rational |
readSignedRational(long count,
long value)
Reads an SRATIONAL value and returns it as a Rational.
|
protected Rational[] |
readSignedRationalArray(long count,
long value)
Reads an array of SRATIONAL values and returns it as an
array of Rational.
|
protected int[] |
readSShortArray(int type,
long count,
long value)
Reads a TIFF array of signed 16-bit values and returns
it as an int array.
|
protected byte[] |
readTrueByteArray(int type,
long count,
long value)
Reads an array of bytes and returns it as a byte array.
|
long |
readUnsigned(int type)
Reads an unsigned number of any type.
|
void |
setFirst(boolean first)
Sets flag indicating whether this is the first IFD.
|
void |
setThumbnail(boolean thumbnail)
Sets flag indicating whether this is the "thumbnail" IFD.
|
public static final int TIFF
public static final int EXIF
public static final int INTEROPERABILITY
public static final int GPSINFO
public static final int GLOBALPARAMETERS
public static final int NULL
public static final int BYTE
public static final int ASCII
public static final int SHORT
public static final int LONG
public static final int RATIONAL
public static final int SBYTE
public static final int UNDEFINED
public static final int SSHORT
public static final int SLONG
public static final int SRATIONAL
public static final int FLOAT
public static final int DOUBLE
public static final int IFD
public static final String[] TYPE
protected boolean _bigEndian
protected RepInfo _info
protected long _next
protected long _offset
protected int _version
public IFD(long offset, RepInfo info, RandomAccessFile raf, boolean bigEndian)
IFD
object.offset
- IFD offsetinfo
- Representation informationraf
- TIFF filebigEndian
- True if big-endian filepublic long getNext()
public long getOffset()
public abstract Property getProperty(boolean rawOutput) throws TiffException
TiffException
public int getVersion()
public boolean isFirst()
public boolean isThumbnail()
public abstract void lookupTag(int tag, int type, long count, long value) throws TiffException
TiffException
public long parse() throws TiffException
TiffException
public long parse(boolean byteOffsetIsValid, boolean suppressErrors) throws TiffException
byteOffsetIsValid
- If true, allow offsets on odd byte boundariessuppressErrors
- If true, return IFD even with errorsTiffException
public long parse(boolean byteOffsetIsValid) throws TiffException
byteOffsetIsValid
- If true, allow offsets on odd byte boundariesTiffException
public void setFirst(boolean first)
public void setThumbnail(boolean thumbnail)
protected Property addBitmaskProperty(String name, long value, String[] labels, boolean rawOutput)
rawOutput
is true, returns a LIST
property whose elements are STRING properties. The
string values of these STRING properties are the
elements of labels
whose indices
correspond to 1 bits in the bitmask, counting
the low-order bit as bit 0.
if rawOutput
is false, returns a LONG
property whose numeric value is value
.protected Property addIntegerProperty(String name, int value, String[] labels, boolean rawOutput)
rawOutput
is true, returns
an INTEGER property, and labels
and
index
are unused. Otherwise,
returns a STRING property, with the
string being the element of labels
whose index is value
.protected Property addIntegerProperty(String name, int value, String[] labels, int[] index, boolean rawOutput)
rawOutput
is true, returns
an INTEGER property, and labels
and
index
are unused. Otherwise,
returns a STRING property, with the
string being the element of labels
whose index is the index of
value
in index
.protected Property addIntegerArrayProperty(String name, int[] value, String[] labels, boolean rawOutput)
rawOutput
is true, the elements of the property array
are INTEGER properties, and labels
is unused. Otherwise,
the elements of the array are STRING properties, with the
elements of value
used as indices into
labels
.protected Property addRationalProperty(String name, Rational r, boolean rawOutput)
protected Property addRationalArrayProperty(String name, Rational[] r, boolean rawOutput)
protected void postParseInitialization()
protected Property propertyHeader(String type, List entries)
protected String readASCII(long count, long value) throws IOException
count
- Length of stringvalue
- Offset of stringIOException
protected String[] readASCIIArray(long count, long value) throws IOException
count
- Number of strings to readvalue
- Offset from which to readIOException
protected int readByte(int type, long count, long value) throws IOException
type
- TIFF type to read; must be an 8-bit typecount
- Unusedvalue
- Offset from which to readIOException
protected int[] readByteArray(int type, long count, long value) throws IOException
type
- TIFF type to read; must be an 8-bit typecount
- Number of bytes to readvalue
- Offset from which to readIOException
protected byte[] readTrueByteArray(int type, long count, long value) throws IOException
type
- Unusedcount
- Number of bytes to readvalue
- Offset from which to readIOException
protected double[] readDoubleArray(long count, long value) throws IOException
count
- Number of values to readvalue
- Offset from which to readIOException
protected long readLong(int type, long count, long value) throws IOException
type
- TIFF type to read; must be a 32-bit typecount
- Unusedvalue
- Offset from which to readIOException
protected long[] readLongArray(int type, long count, long value) throws IOException
type
- TIFF type to read; must be a 32-bit typecount
- Number of values to readvalue
- Offset from which to readIOException
public long readUnsigned(int type) throws IOException
type
- TIFF type to readIOException
protected Rational readRational(long count, long value) throws IOException
IOException
protected Rational[] readRationalArray(long count, long value) throws IOException
IOException
protected Rational readSignedRational(long count, long value) throws IOException
IOException
protected Rational[] readSignedRationalArray(long count, long value) throws IOException
IOException
protected int readShort(int type, long count, long value) throws IOException
IOException
protected int[] readShortArray(int type, long count, long value) throws IOException
IOException
protected int[] readSShortArray(int type, long count, long value) throws IOException
IOException
public static long calcValueSize(int type, long count)
type
- Field typecount
- Field countpublic boolean isBigEndian()
true
if file is big-endian,
false
if little-endian.protected static void checkCount(int tag, long count, int minCount) throws TiffException
tag
- Tag entry valuecount
- Tag entry countminCount
- Tag countTiffException
protected static void checkType(int tag, int type, int expected) throws TiffException
tag
- Tag entry valuetype
- Tag entry typeexpected
- Tag typeTiffException
protected static void checkType(int tag, int type, int type1, int type2) throws TiffException
tag
- Tag entry valuetype
- Tag entry typetype1
- Tag typetype2
- Alternate tag typeTiffException
Copyright © 2008–2017 The Open Preservation Foundation. All rights reserved.