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
public class PngModule extends ModuleBase
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
Fields Modifier and Type Field Description protected Checksummer_ckSummerprotected int_colorTypeprotected ChecksumInputStream_cstreamprotected DataInputStream_dstreamprotected List<Property>_keywordPropListprotected Property_metadataprotected List<Property>_propListprotected List<Property>_spltList-
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, _sha256, _signature, _specification, _validityNote, _vendor, _verbosity, _wellFormedNote
-
Fields inherited from interface edu.harvard.hul.ois.jhove.Module
MAXIMUM_VERBOSITY, MINIMUM_VERBOSITY
-
-
Constructor Summary
Constructors Constructor Description PngModule()Instantiate a PngModule object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddKeyword(String keywd, String val)Add a keyword and value.voidaddKeyword(String keywd, String translatedKeywd, String val, String language)Add a keyword, value, and language.voidaddSplt(String name, int sampleDepth, int numSamples)Add a suggested palettevoidcheckSignatures(File file, InputStream stream, RepInfo info)Check if the digital object conforms to this Module's internal signature information.voideatChunk(PNGChunk chnk)This lets the module skip over the remainder of a chunk, not including the name, length,and CRC.intgetColorType()Get the color type that was recorded from the IHDR chunk.protected voidinitParse()Initializes the state of the module for parsing.booleanisChunkSeen(int chunkType)booleanisIdatFinished()Return true if a non-IDAT chunk has been seen after an IDAT chunkbooleanisIdatSeen()Return true if IDAT chunk has been seenbooleanisIhdrSeen()Returns true if IHDR chunk has been seenbooleanisPlteSeen()Return 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 seen-
Methods 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 Detail
-
_ckSummer
protected Checksummer _ckSummer
-
_cstream
protected ChecksumInputStream _cstream
-
_dstream
protected DataInputStream _dstream
-
_metadata
protected Property _metadata
-
_colorType
protected int _colorType
-
-
Method Detail
-
checkSignatures
public void checkSignatures(File file, InputStream stream, RepInfo info)
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
public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException
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
public void eatChunk(PNGChunk chnk) throws IOException
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
public void addKeyword(String keywd, String val)
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
public void addKeyword(String keywd, String translatedKeywd, String val, String language)
Add a keyword, value, and language.
-
addSplt
public void addSplt(String name, int sampleDepth, int numSamples)
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.
-
-