Package com.mcgath.jhove.module
Class PngModule
java.lang.Object
edu.harvard.hul.ois.jhove.ModuleBase
com.mcgath.jhove.module.PngModule
- All Implemented Interfaces:
Module
Module for validation and metadata extraction on PNG files.
- Author:
- Gary McGath An earlier PNG module was submitted by Gian Uberto Lauri. A few bits of code are copied from it. It validates files but doesn't do much metadata extraction. I noticed it only after making a significant start on my own version. -- GDM
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Checksummerprotected intprotected ChecksumInputStreamprotected DataInputStreamprotected PropertyFields 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, _sha256, _signature, _specification, _validityNote, _vendor, _verbosity, _wellFormedNoteFields inherited from interface edu.harvard.hul.ois.jhove.Module
MAXIMUM_VERBOSITY, MINIMUM_VERBOSITY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKeyword(String keywd, String val) Add a keyword and value.voidaddKeyword(String keywd, String translatedKeywd, String val, String language) Add a keyword, value, and language.voidAdd a suggested palettevoidcheckSignatures(File file, InputStream stream, RepInfo info) Check if the digital object conforms to this Module's internal signature information.voidThis lets the module skip over the remainder of a chunk, not including the name, length,and CRC.intGet the color type that was recorded from the IHDR chunk.protected voidInitializes the state of the module for parsing.booleanisChunkSeen(int chunkType) booleanReturn true if a non-IDAT chunk has been seen after an IDAT chunkbooleanReturn true if IDAT chunk has been seenbooleanReturns true if IHDR chunk has been seenbooleanReturn true if PLTE chunk has been seenintparse(InputStream stream, RepInfo info, int parseIndex) Parse the content of a purported JPEG stream digital object and store the results in RepInfo.voidsetChunkSeen(int chunkType) voidsetColorType(int ct) Set the color type.voidsetIdatSeen(boolean b) Note that an IDAT chunk has been seenvoidsetIendSeen(boolean b) Note that an IEND chunk has been seenvoidsetIhdrSeen(boolean b) Note that an IHDR chunk has been seenvoidsetPlteSeen(boolean b) Note that a PLTE chunk has been seenMethods inherited from class edu.harvard.hul.ois.jhove.ModuleBase
addIntegerProperty, addIntegerProperty, applyDefaultParams, calcRAChecksum, checkSignatures, checksumIfRafNotCopied, getApp, getBase, getBufferedDataStream, getCoverage, getCRC32, getDate, getDefaultParams, getFeatures, getFormat, getMimeType, getName, getNByte, getNote, getRelease, getRepInfoNote, getRights, getSignature, getSpecification, getValidityNote, getVendor, getWellFormedNote, hasFeature, init, initFeatures, initInfo, isBigEndian, isParamInDefaults, 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, setSHA256, setupDataStream, setValidityNote, setVerbosity, show, skipBytes, skipBytes, skipDstreamToEnd, vectorToPropArray
-
Field Details
-
_ckSummer
-
_propList
-
_keywordPropList
-
_spltList
-
_cstream
-
_dstream
-
_metadata
-
_colorType
protected int _colorType
-
-
Constructor Details
-
PngModule
public PngModule()Instantiate a PngModule object.
-
-
Method Details
-
checkSignatures
Check if the digital object conforms to this Module's internal signature information.- Specified by:
checkSignaturesin interfaceModule- Overrides:
checkSignaturesin classModuleBase- Parameters:
file- A RandomAccessFile, positioned at its beginning, which is generated from the object to be parsedstream- An InputStream, positioned at its beginning, which is generated from the object to be parsedinfo- A fresh RepInfo object which will be modified to reflect the results of the test
-
parse
Parse the content of a purported JPEG stream digital object and store the results in RepInfo. This function uses the JPEG-L method of detecting a marker following a data stream, checking for a 0 high bit rather than an entire 0 byte. So long at no JPEG markers are defined with a value from 0 through 7F, this is valid for all JPEG files.- Specified by:
parsein interfaceModule- Overrides:
parsein classModuleBase- Parameters:
stream- An InputStream, positioned at its beginning, which is generated from the object to be parsedinfo- A fresh RepInfo object which will be modified to reflect the results of the parsingparseIndex- Must be 0 in first call toparse. Ifparsereturns a nonzero value, it must be called again withparseIndexequal to that return value.- Throws:
IOException
-
eatChunk
This lets the module skip over the remainder of a chunk, not including the name, length,and CRC. It updates the CRC.- Throws:
IOException
-
addKeyword
Add a keyword and value. Creating arbitrary properties on the fly doesn't go well with JHOVE's approach, so we make each property a Map, with keys Keyword, Value, and optionally Language. -
addKeyword
Add a keyword, value, and language. -
addSplt
Add a suggested palette -
initParse
protected void initParse()Initializes the state of the module for parsing.- Overrides:
initParsein classModuleBase
-
setIhdrSeen
public void setIhdrSeen(boolean b) Note that an IHDR chunk has been seen -
isIhdrSeen
public boolean isIhdrSeen()Returns true if IHDR chunk has been seen -
setIdatSeen
public void setIdatSeen(boolean b) Note that an IDAT chunk has been seen -
setPlteSeen
public void setPlteSeen(boolean b) Note that a PLTE chunk has been seen -
setIendSeen
public void setIendSeen(boolean b) Note that an IEND chunk has been seen -
isIdatSeen
public boolean isIdatSeen()Return true if IDAT chunk has been seen -
isIdatFinished
public boolean isIdatFinished()Return true if a non-IDAT chunk has been seen after an IDAT chunk -
isPlteSeen
public boolean isPlteSeen()Return true if PLTE chunk has been seen -
setChunkSeen
public void setChunkSeen(int chunkType) -
isChunkSeen
public boolean isChunkSeen(int chunkType) -
setColorType
public void setColorType(int ct) Set the color type. The IHDR processing will set this for the benefit of chunks that need it. -
getColorType
public int getColorType()Get the color type that was recorded from the IHDR chunk.
-