edu.harvard.hul.ois.jhove.module
Class TiffModule

java.lang.Object
  extended by edu.harvard.hul.ois.jhove.ModuleBase
      extended by edu.harvard.hul.ois.jhove.module.TiffModule
All Implemented Interfaces:
Module

public class TiffModule
extends ModuleBase

Module for identification and validation of TIFF files.


Field Summary
protected  boolean _byteOffsetIsValid
           
protected  boolean _dngRawFlag
          Special flag for DNG profiles; is raw IFD profile satisfied
protected  boolean _dngThumbnailFlag
          Special flag for DNG profiles; is "thumbnail" (IFD 0) profile satisfied
protected  boolean _exifFirstFlag
          Special flag for Exif profiles: Is main IFD profile satisfied
protected  boolean _exifThumbnailFlag
          Special flag for Exif profiles: Is thumbnail IFD profile satisfied
protected  java.util.List<TiffProfile> _profile
          List of profile checkers.
protected  java.io.RandomAccessFile _raf
          Open TIFF file.
protected  int _version
          TIFF version.
static java.lang.String[] defaultConfigParams
          Value to write as module params to the default config file.
 
Fields inherited from class edu.harvard.hul.ois.jhove.ModuleBase
_app, _bigEndian, _checksumFinished, _countStream, _coverage, _crc32, _date, _defaultParams, _features, _format, _init, _isRandomAccess, _je, _logger, _md5, _mimeType, _name, _nByte, _note, _param, _release, _repInfoNote, _rights, _sha1, _signature, _specification, _validityNote, _vendor, _verbosity, _wellFormedNote
 
Fields inherited from interface edu.harvard.hul.ois.jhove.Module
MAXIMUM_VERBOSITY, MINIMUM_VERBOSITY
 
Constructor Summary
TiffModule()
          Instantiate a object.
 
Method Summary
protected  void buildProfileList()
          Build list of profiles to check.
protected  void checkValidity(java.util.List<IFD> ifds, RepInfo info)
          Go through all the IFD's, calling checkIFDValidity on each one that is a standard IFD.
protected  void checkValidity(TiffIFD ifd, RepInfo info)
          Check the validity of the IFD.
 java.util.List<IFD> exifParse(java.io.RandomAccessFile raf, RepInfo info)
          Special-purpose, limited parser for embedded Exif files.
protected  void initParse()
          Initializes the state of the module for parsing.
 void parse(java.io.RandomAccessFile raf, RepInfo info)
          Parse the TIFF for well-formedness and validity, accumulating representation information.
protected  IFD parseIFDChain(long next, RepInfo info, int type, java.util.List<IFD> list, boolean suppressErrors)
           
protected  java.util.List<IFD> parseIFDs(long offset, RepInfo info)
          Parse all IFDs in the file, accumulating representation information.
protected  java.util.List<IFD> parseIFDs(long offset, RepInfo info, boolean suppressErrors, int ifdType)
          Parse all IFDs in the file, accumulating representation information.
protected  void reportInvalid(java.lang.String s, RepInfo info)
          Report an instance of invalidity.
protected  int selectMimeTypeIndex()
          Return the index into _mimeType which should be used for the MIME type property.
 void setByteOffsetValid(boolean v)
          Allow odd offsets in values
 
Methods inherited from class edu.harvard.hul.ois.jhove.ModuleBase
addIntegerProperty, addIntegerProperty, applyDefaultParams, calcRAChecksum, checkSignatures, checkSignatures, getApp, getBase, getBufferedDataStream, getCoverage, getCRC32, getDate, getDefaultParams, getFeatures, getFormat, getMimeType, getName, getNByte, getNote, getRelease, getRepInfoNote, getRights, getSignature, getSpecification, getValidityNote, getVendor, getWellFormedNote, hasFeature, init, initFeatures, isBigEndian, isRandomAccess, param, parse, readByteBuf, readDouble, readDouble, readDouble, readFloat, readFloat, readSignedByte, readSignedByte, readSignedByte, readSignedInt, readSignedInt, readSignedInt, readSignedLong, readSignedRational, readSignedRational, readSignedShort, readSignedShort, readSignedShort, readUnsignedByte, readUnsignedByte, readUnsignedByte, readUnsignedInt, readUnsignedInt, readUnsignedInt, readUnsignedRational, readUnsignedRational, readUnsignedRational, readUnsignedShort, readUnsignedShort, readUnsignedShort, resetParams, setApp, setBase, setChecksums, setCRC32, setDefaultParams, setMD5, setNByte, setSHA1, setValidityNote, setVerbosity, show, skipBytes, skipBytes, vectorToPropArray
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultConfigParams

public static final java.lang.String[] defaultConfigParams
Value to write as module params to the default config file.


_profile

protected java.util.List<TiffProfile> _profile
List of profile checkers.


_exifFirstFlag

protected boolean _exifFirstFlag
Special flag for Exif profiles: Is main IFD profile satisfied


_exifThumbnailFlag

protected boolean _exifThumbnailFlag
Special flag for Exif profiles: Is thumbnail IFD profile satisfied


_dngThumbnailFlag

protected boolean _dngThumbnailFlag
Special flag for DNG profiles; is "thumbnail" (IFD 0) profile satisfied


_dngRawFlag

protected boolean _dngRawFlag
Special flag for DNG profiles; is raw IFD profile satisfied


_raf

protected java.io.RandomAccessFile _raf
Open TIFF file.


_version

protected int _version
TIFF version.


_byteOffsetIsValid

protected boolean _byteOffsetIsValid
Constructor Detail

TiffModule

public TiffModule()
Instantiate a object.

Method Detail

parse

public final void parse(java.io.RandomAccessFile raf,
                        RepInfo info)
                 throws java.io.IOException
Parse the TIFF for well-formedness and validity, accumulating representation information.

Specified by:
parse in interface Module
Overrides:
parse in class ModuleBase
Parameters:
raf - Open TIFF file
info - Representation informatino
Throws:
java.io.IOException

setByteOffsetValid

public void setByteOffsetValid(boolean v)
Allow odd offsets in values


exifParse

public final java.util.List<IFD> exifParse(java.io.RandomAccessFile raf,
                                           RepInfo info)
                                    throws java.io.IOException
Special-purpose, limited parser for embedded Exif files.

Parameters:
raf - Open TIFF file
info - Representation informatino
Throws:
java.io.IOException

buildProfileList

protected void buildProfileList()
Build list of profiles to check. Profile checking is, for the most part, done per IFD rather than per file. Exif profile checking is an exception, since it requires the coordination of multiple IFD's. Hence, the Exif profiles aren't added to the list, but treated elsewhere.


checkValidity

protected void checkValidity(java.util.List<IFD> ifds,
                             RepInfo info)
Go through all the IFD's, calling checkIFDValidity on each one that is a standard IFD. (Private IFD's have different requirements, and for the moment aren't checked here.) If any of them are invalid, set info's valid field to false. Validity problems are non-fatal, and more information is better, so we keep going with all IFDs even if we find problems.


checkValidity

protected void checkValidity(TiffIFD ifd,
                             RepInfo info)
                      throws TiffException
Check the validity of the IFD.

Parameters:
ifd - IFD
Throws:
TiffException

reportInvalid

protected void reportInvalid(java.lang.String s,
                             RepInfo info)
Report an instance of invalidity.


parseIFDs

protected java.util.List<IFD> parseIFDs(long offset,
                                        RepInfo info)
                                 throws TiffException
Parse all IFDs in the file, accumulating representation information.

Parameters:
offset - Starting byte offset
info - Representation information
Throws:
TiffException

parseIFDs

protected java.util.List<IFD> parseIFDs(long offset,
                                        RepInfo info,
                                        boolean suppressErrors,
                                        int ifdType)
                                 throws TiffException
Parse all IFDs in the file, accumulating representation information.

Parameters:
offset - Starting byte offset
info - Representation information
suppressErrors - If true, use IFD even if it has errors
Throws:
TiffException

parseIFDChain

protected IFD parseIFDChain(long next,
                            RepInfo info,
                            int type,
                            java.util.List<IFD> list,
                            boolean suppressErrors)
                     throws TiffException
Throws:
TiffException

initParse

protected void initParse()
Initializes the state of the module for parsing. This overrides the superclass method to reset all the profile flags.

Overrides:
initParse in class ModuleBase

selectMimeTypeIndex

protected int selectMimeTypeIndex()
Return the index into _mimeType which should be used for the MIME type property. This must be called after all the profiles have been checked. An index of 0 is dominant; if any profiles return 0 from their getMimeClass method, or if conflicting values are returned by different satisfied profiles, then we return 0.