public abstract class ModuleBase extends Object implements Module
parse (InputStream stream, RepInfo info, int parseIndex)
if it is not random access, or
parse (RandomAccessFile file, RepInfo info)
if it is random access.Modifier and Type | Field and Description |
---|---|
protected App |
_app
The application object
|
protected boolean |
_bigEndian
The dominant "endianness" of the Module.
|
protected boolean |
_checksumFinished
Flag indicating valid checksum information set
|
protected boolean |
_countStream
Flag to indicate read routines should count the stream
|
protected String |
_coverage
Coverage information
|
protected CRC32 |
_crc32
CRC32 calculated on content object
|
protected Date |
_date
Module last modification date
|
protected List<String> |
_defaultParams
List of default parameters.
|
protected List<String> |
_features
The list of supported features.
|
protected String[] |
_format
Formats recognized by this Module
|
protected String |
_init
Initialization value.
|
protected boolean |
_isRandomAccess
Random access flag
|
protected JhoveBase |
_je
JHOVE engine.
|
protected Logger |
_logger
Logger for a module class.
|
protected MessageDigest |
_md5
MD5 digest calculated on content object
|
protected String[] |
_mimeType
MIME types supported by this Module
|
protected String |
_name
Module name
|
protected long |
_nByte
Byte count of content object
|
protected String |
_note
Module note
|
protected String |
_param
Module-specific parameter.
|
protected String |
_release
Module release description
|
protected String |
_repInfoNote
RepInfo note
|
protected String |
_rights
Copyright notice
|
protected MessageDigest |
_sha1
SHA-1 digest calculated on content object
|
protected List<Signature> |
_signature
Module Signature list
|
protected List<Document> |
_specification
Module specification document list
|
protected String |
_validityNote
Validity criteria
|
protected Agent |
_vendor
Module vendor
|
protected int |
_verbosity
Indicator of how much data to report
|
protected String |
_wellFormedNote
Well-formedness criteria
|
MAXIMUM_VERBOSITY, MINIMUM_VERBOSITY
Modifier | Constructor and Description |
---|---|
protected |
ModuleBase(String name,
String release,
int[] date,
String[] format,
String coverage,
String[] mimeType,
String wellFormedNote,
String validityNote,
String repInfoNote,
String note,
String rights,
boolean isRandomAccess)
Constructors of all subclasses of ModuleBase should call
this as a
super constructor. |
Modifier and Type | Method and Description |
---|---|
Property |
addIntegerProperty(String name,
int value,
String[] labels)
Returns an Property representing an integer value.
|
Property |
addIntegerProperty(String name,
int value,
String[] labels,
int[] index)
Returns an Property representing an integer value.
|
void |
applyDefaultParams()
Applies the default parameters.
|
protected void |
calcRAChecksum(Checksummer ckSummer,
RandomAccessFile raf)
Calculates the checksums for a module that uses a
random access file.
|
void |
checkSignatures(File file,
InputStream stream,
RepInfo info)
Check if the digital object conforms to this Module's
internal signature information.
|
void |
checkSignatures(File file,
RandomAccessFile raf,
RepInfo info)
Check if the digital object conforms to this Module's
internal signature information.
|
App |
getApp()
Returns the App object.
|
JhoveBase |
getBase()
Returns the JHOVE engine object.
|
static DataInputStream |
getBufferedDataStream(InputStream stream,
int size)
A convenience method for getting a buffered DataInputStream
from a module's InputStream.
|
String |
getCoverage()
Return details as to the specific format versions or
variants that are supported by this module
|
protected String |
getCRC32()
Returns the hex string representation of the CRC32 result.
|
Date |
getDate()
Return the last modification date of this Module, as a
Java Date object
|
List<String> |
getDefaultParams()
Returns the list of default parameters.
|
List<String> |
getFeatures()
Returns the full list of features.
|
String[] |
getFormat()
Return the array of format names supported by this Module
|
String[] |
getMimeType()
Return the array of MIME type strings for formats supported
by this Module
|
String |
getName()
Return the module name
|
long |
getNByte()
Returns the value of _nByte.
|
String |
getNote()
Return the module note
|
String |
getRelease()
Return the release identifier
|
String |
getRepInfoNote()
Return the RepInfo note
|
String |
getRights()
Return the copyright information string
|
List<Signature> |
getSignature()
Return the List of Signatures recognized by this Module
|
List<Document> |
getSpecification()
Returns a list of
Document objects (one for each
specification document of the format). |
String |
getValidityNote()
Return the string describing validity criteria
|
Agent |
getVendor()
Return the vendor information
|
String |
getWellFormedNote()
Return the string describing well-formedness criteria
|
boolean |
hasFeature(String feature)
Returns
true if the module supports a given
named feature, and false if the feature is
unsupported or unknown. |
void |
init(String init)
Per-instantiation initialization.
|
void |
initFeatures()
Initializes the feature list.
|
protected void |
initParse()
Initializes the state of the module for parsing.
|
boolean |
isBigEndian()
Returns
true if the dominant "endianness" of the
module, or the current file being processed,
is big-endian, otherwise false. |
boolean |
isRandomAccess()
Return the random access flag (true if the module operates
on random access files, false if it operates on streams)
|
void |
param(String param)
Per-action initialization.
|
int |
parse(InputStream stream,
RepInfo info,
int parseIndex)
Parse the content of a stream digital object and store the
results in RepInfo.
|
void |
parse(RandomAccessFile file,
RepInfo info)
Parse the content of a random access digital object and store the
results in RepInfo.
|
static int |
readByteBuf(DataInputStream stream,
byte[] buf,
ModuleBase counted)
Reads into a byte buffer from a DataInputStream.
|
static double |
readDouble(DataInputStream stream,
boolean endian) |
static double |
readDouble(DataInputStream stream,
boolean endian,
ModuleBase counted) |
static double |
readDouble(RandomAccessFile file,
boolean endian) |
static float |
readFloat(DataInputStream stream,
boolean endian,
ModuleBase counted) |
static float |
readFloat(RandomAccessFile file,
boolean endian) |
static int |
readSignedByte(DataInputStream stream) |
static int |
readSignedByte(DataInputStream stream,
ModuleBase counted) |
static int |
readSignedByte(RandomAccessFile file) |
static int |
readSignedInt(DataInputStream stream,
boolean endian) |
static int |
readSignedInt(DataInputStream stream,
boolean endian,
ModuleBase counted) |
static int |
readSignedInt(RandomAccessFile file,
boolean endian) |
static long |
readSignedLong(DataInputStream stream,
boolean bigEndian,
ModuleBase counted)
Reads eight bytes as a signed 64-bit value from a
DataInputStream.
|
static Rational |
readSignedRational(DataInputStream stream,
boolean endian,
ModuleBase counted) |
static Rational |
readSignedRational(RandomAccessFile file,
boolean endian) |
static int |
readSignedShort(DataInputStream stream,
boolean endian) |
static int |
readSignedShort(DataInputStream stream,
boolean endian,
ModuleBase counted) |
static int |
readSignedShort(RandomAccessFile file,
boolean endian) |
static int |
readUnsignedByte(DataInputStream stream)
Reads an unsigned byte from a DataInputStream.
|
static int |
readUnsignedByte(DataInputStream stream,
ModuleBase counted)
Reads an unsigned byte from a DataInputStream.
|
static int |
readUnsignedByte(RandomAccessFile file)
Reads an unsigned byte from a RandomAccessFile.
|
static long |
readUnsignedInt(DataInputStream stream,
boolean bigEndian)
Reads four bytes as an unsigned 32-bit value from a
DataInputStream.
|
static long |
readUnsignedInt(DataInputStream stream,
boolean bigEndian,
ModuleBase counted)
Reads four bytes as an unsigned 32-bit value from a
DataInputStream.
|
static long |
readUnsignedInt(RandomAccessFile file,
boolean bigEndian)
Reads four bytes as an unsigned 32-bit value from a
RandomAccessFile.
|
static Rational |
readUnsignedRational(DataInputStream stream,
boolean endian) |
static Rational |
readUnsignedRational(DataInputStream stream,
boolean endian,
ModuleBase counted) |
static Rational |
readUnsignedRational(RandomAccessFile file,
boolean endian) |
static int |
readUnsignedShort(DataInputStream stream,
boolean bigEndian)
Reads two bytes as an unsigned short value from a DataInputStream.
|
static int |
readUnsignedShort(DataInputStream stream,
boolean bigEndian,
ModuleBase counted)
Reads two bytes as an unsigned short value from a DataInputStream.
|
static int |
readUnsignedShort(RandomAccessFile file,
boolean bigEndian)
Reads two bytes as an unsigned short value from a
RandomAccessFile.
|
void |
resetParams()
Reset parameter settings.
|
void |
setApp(App app)
Pass the associated App object to this Module.
|
void |
setBase(JhoveBase je)
Pass the JHOVE engine object to this Module.
|
protected void |
setChecksums(Checksummer ckSummer,
RepInfo info)
Set the checksum values.
|
void |
setCRC32(CRC32 crc32)
Set the value of the CRC32 calculated for the content object.
|
void |
setDefaultParams(List<String> params)
Set a a List of default parameters for the module.
|
void |
setMD5(MessageDigest md5)
Sets the MD5 calculated digest for the content object, and sets
the checksumFinished flag.
|
void |
setNByte(long nByte)
Sets the byte count for the content object, and sets
the checksumFinished flag.
|
void |
setSHA1(MessageDigest sha1)
Sets the SHA-1 calculated digest for the content object, and sets
the checksumFinished flag.
|
void |
setValidityNote(String validityNote)
Set the value of the validityNote property, which
briefly explains the validity criteria of this Module.
|
void |
setVerbosity(int verbosity)
Set the degree of verbosity desired from the module.
|
void |
show(OutputHandler handler)
Generates information about this Module.
|
long |
skipBytes(DataInputStream stream,
long bytesToSkip) |
long |
skipBytes(DataInputStream stream,
long bytesToSkip,
ModuleBase counted) |
protected Property[] |
vectorToPropArray(Vector vec)
A utility for converting a Vector of Properties to an
Array.
|
protected App _app
protected String _coverage
protected Date _date
protected String[] _format
protected String _init
protected JhoveBase _je
protected String[] _mimeType
protected String _name
protected String _note
protected String _param
protected String _release
protected String _repInfoNote
protected String _rights
protected Agent _vendor
protected String _wellFormedNote
protected String _validityNote
protected boolean _isRandomAccess
protected long _nByte
protected CRC32 _crc32
protected MessageDigest _md5
protected MessageDigest _sha1
protected boolean _checksumFinished
protected int _verbosity
protected boolean _countStream
protected boolean _bigEndian
protected Logger _logger
protected ModuleBase(String name, String release, int[] date, String[] format, String coverage, String[] mimeType, String wellFormedNote, String validityNote, String repInfoNote, String note, String rights, boolean isRandomAccess)
super
constructor.name
- Name of the modulerelease
- Release identifierdate
- Last modification date of the module code,
in the form of an array of three numbers.
date[0]
is the year,
date[1]
the month, and
date[2]
the day.format
- Array of format names supported by the modulecoverage
- Details as to the specific format versions or
variants that are supported by the modulemimeType
- Array of MIME type strings for formats
supported by the modulewellFormedNote
- Brief explanation of what constitutes
well-formed contentvalidityNote
- Brief explanation of what constitutes
valid contentrepInfoNote
- Note pertaining to RepInfo (may be null)note
- Additional information about the module
(may be null)rights
- Copyright notice for the moduleisRandomAccess
- true
if the module treats content as
random-access data, public void initFeatures()
public void init(String init) throws Exception
public void setDefaultParams(List<String> params)
setDefaultParams
in interface Module
params
- A List whose elements are Strings.
May be empty.public void applyDefaultParams() throws Exception
applyDefaultParams
in interface Module
Exception
public void resetParams() throws Exception
resetParams
in interface Module
Exception
public void param(String param) throws Exception
public App getApp()
public JhoveBase getBase()
public long getNByte()
public boolean isBigEndian()
true
if the dominant "endianness" of the
module, or the current file being processed,
is big-endian, otherwise false. This does not guarantee
that all numbers in the module follow the dominant endianness,
particularly as formats sometimes incorporate data stored in
a previously defined format. For some formats, e.g., TIFF, the
endianness depends on the file being processed.
Every module must initialize the value of _bigEndian for this
function, or else assign its value when parsing a file,
to return a meaningful result. For some modules (e.g.,
ASCII, endianness has no meaning.public final String getCoverage()
getCoverage
in interface Module
public final Date getDate()
public final String[] getFormat()
public final String[] getMimeType()
getMimeType
in interface Module
public final String getName()
public final String getNote()
public final String getRelease()
getRelease
in interface Module
public final String getRepInfoNote()
getRepInfoNote
in interface Module
public final String getRights()
public final List<Signature> getSignature()
getSignature
in interface Module
public final List<Document> getSpecification()
Document
objects (one for each
specification document of the format). The specification
list is generated by the Module, and specifications cannot
be added by callers.getSpecification
in interface Module
Document
public final Agent getVendor()
public final String getWellFormedNote()
getWellFormedNote
in interface Module
public final String getValidityNote()
getValidityNote
in interface Module
public final boolean isRandomAccess()
isRandomAccess
in interface Module
public boolean hasFeature(String feature)
true
if the module supports a given
named feature, and false
if the feature is
unsupported or unknown. Feature names are case sensitive.
It is recommended that features be named using package
nomenclature. The following features are, by default,
supported by the modules developed by OIS:
hasFeature
in interface Module
public List<String> getFeatures()
getFeatures
in interface Module
public List<String> getDefaultParams()
getDefaultParams
in interface Module
public final void setApp(App app)
public final void setBase(JhoveBase je)
public final void setValidityNote(String validityNote)
public final void setCRC32(CRC32 crc32)
public void setVerbosity(int verbosity)
param
can override the verbosity setting.
It does not affect whether raw data are reported or not, only
which data are reported.setVerbosity
in interface Module
verbosity
- The requested verbosity value. Recognized
values are Module.MINIMUM_VERBOSITY and Module.MAXIMUM_VERBOSITY.
The interpretation of the value depends on the module, and
the module may choose not to use this setting. However,
modules should treat MAXIMUM_VERBOSITY as a request for
all the data available from the module.public final void setNByte(long nByte)
public final void setMD5(MessageDigest md5)
public final void setSHA1(MessageDigest sha1)
public int parse(InputStream stream, RepInfo info, int parseIndex) throws IOException
parse
in interface Module
stream
- An InputStream, positioned at its beginning,
which is generated from the object to be parsed.
If multiple calls to parse
are made
on the basis of a nonzero value being returned,
a new InputStream must be provided each time.info
- A fresh (on the first call) RepInfo object
which will be modified
to reflect the results of the parsing
If multiple calls to parse
are made
on the basis of a nonzero value being returned,
the same RepInfo object should be passed with each
call.parseIndex
- Must be 0 in first call to parse
. If
parse
returns a nonzero value, it must be
called again with parseIndex
equal to that return value.IOException
public void parse(RandomAccessFile file, RepInfo info) throws IOException
parse
in interface Module
file
- A RandomAccessFile, 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 parsingIOException
public void checkSignatures(File file, InputStream stream, RepInfo info) throws IOException
checkSignatures
in interface Module
file
- A File object for the object being 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 testIOException
public void checkSignatures(File file, RandomAccessFile raf, RepInfo info) throws IOException
checkSignatures
in interface Module
file
- A File object representing the object to be
parsedraf
- A RandomAccessFile, 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 testIOException
protected void initParse()
protected void calcRAChecksum(Checksummer ckSummer, RandomAccessFile raf) throws IOException
IOException
protected void setChecksums(Checksummer ckSummer, RepInfo info)
ckSummer
- Checksummer objectinfo
- RepInfo objectpublic void show(OutputHandler handler)
protected String getCRC32()
public Property addIntegerProperty(String name, int value, String[] labels, int[] index)
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
.public Property addIntegerProperty(String name, int value, String[] labels)
labels
and
index
are unused. Otherwise,
returns a STRING property, with the
string being the element of labels
whose index is value
.public static int readUnsignedByte(DataInputStream stream) throws IOException
stream
- Stream to readIOException
public static int readUnsignedByte(DataInputStream stream, ModuleBase counted) throws IOException
stream
- Stream to readcounted
- If non-null, module for which value of _nByte
shall be incremented appropriatelyIOException
public static int readUnsignedByte(RandomAccessFile file) throws IOException
IOException
public static int readByteBuf(DataInputStream stream, byte[] buf, ModuleBase counted) throws IOException
stream
- Stream to read frombuf
- Byte buffer to fill upcounted
- If non-null, module for which value of _nByte
shall be incremented appropriatelyIOException
public static int readUnsignedShort(DataInputStream stream, boolean bigEndian) throws IOException
stream
- The stream to read from.bigEndian
- If true, interpret the first byte as the high
byte, otherwise interpret the first byte as
the low byte.IOException
public static int readUnsignedShort(DataInputStream stream, boolean bigEndian, ModuleBase counted) throws IOException
stream
- The stream to read from.bigEndian
- If true, interpret the first byte as the high
byte, otherwise interpret the first byte as
the low byte.IOException
public static int readUnsignedShort(RandomAccessFile file, boolean bigEndian) throws IOException
file
- The file to read from.bigEndian
- If true, interpret the first byte as the high
byte, otherwise interpret the first byte as
the low byte.IOException
public static long readUnsignedInt(DataInputStream stream, boolean bigEndian) throws IOException
stream
- The stream to read from.bigEndian
- If true, interpret the first byte as the high
byte, otherwise interpret the first byte as
the low byte.IOException
public static long readUnsignedInt(DataInputStream stream, boolean bigEndian, ModuleBase counted) throws IOException
stream
- The stream to read from.bigEndian
- If true, interpret the first byte as the high
byte, otherwise interpret the first byte as
the low byte.IOException
public static long readUnsignedInt(RandomAccessFile file, boolean bigEndian) throws IOException
file
- The file to read from.bigEndian
- If true, interpret the first byte as the high
byte, otherwise interpret the first byte as
the low byte.IOException
public static long readSignedLong(DataInputStream stream, boolean bigEndian, ModuleBase counted) throws IOException
stream
- The stream to read from.bigEndian
- If true, interpret the first byte as the high
byte, otherwise interpret the first byte as
the low byte.IOException
public static Rational readUnsignedRational(DataInputStream stream, boolean endian) throws IOException
IOException
public static Rational readUnsignedRational(DataInputStream stream, boolean endian, ModuleBase counted) throws IOException
IOException
public static Rational readUnsignedRational(RandomAccessFile file, boolean endian) throws IOException
IOException
public static Rational readSignedRational(DataInputStream stream, boolean endian, ModuleBase counted) throws IOException
IOException
public static Rational readSignedRational(RandomAccessFile file, boolean endian) throws IOException
IOException
public static int readSignedByte(RandomAccessFile file) throws IOException
IOException
public static int readSignedShort(RandomAccessFile file, boolean endian) throws IOException
IOException
public static int readSignedInt(RandomAccessFile file, boolean endian) throws IOException
IOException
public static int readSignedByte(DataInputStream stream) throws IOException
IOException
public static int readSignedByte(DataInputStream stream, ModuleBase counted) throws IOException
IOException
public static int readSignedShort(DataInputStream stream, boolean endian) throws IOException
IOException
public static int readSignedShort(DataInputStream stream, boolean endian, ModuleBase counted) throws IOException
IOException
public static int readSignedInt(DataInputStream stream, boolean endian) throws IOException
IOException
public static int readSignedInt(DataInputStream stream, boolean endian, ModuleBase counted) throws IOException
IOException
public static float readFloat(RandomAccessFile file, boolean endian) throws IOException
IOException
public static float readFloat(DataInputStream stream, boolean endian, ModuleBase counted) throws IOException
IOException
public static double readDouble(RandomAccessFile file, boolean endian) throws IOException
IOException
public static double readDouble(DataInputStream stream, boolean endian) throws IOException
IOException
public static double readDouble(DataInputStream stream, boolean endian, ModuleBase counted) throws IOException
IOException
public long skipBytes(DataInputStream stream, long bytesToSkip) throws IOException
IOException
public long skipBytes(DataInputStream stream, long bytesToSkip, ModuleBase counted) throws IOException
IOException
public static DataInputStream getBufferedDataStream(InputStream stream, int size)
protected Property[] vectorToPropArray(Vector vec)
Copyright © 2008–2017 The Open Preservation Foundation. All rights reserved.