public class JhoveBase extends Object
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
_abort
Flag for aborting activity.
|
protected int |
_bufferSize
Buffer size for buffered I/O.
|
protected boolean |
_checksum |
protected String |
_configFile
Configuration file pathname.
|
protected URLConnection |
_conn
Current URL connection.
|
protected Thread |
_currentThread
Thread currently parsing a document.
|
protected String |
_encoding
Selected encoding.
|
protected Map<String,String> |
_extensions
Associate map of configuration extensions.
|
protected List<OutputHandler> |
_handlerList
Ordered list of output handlers.
|
protected Map<String,OutputHandler> |
_handlerMap
Map of output handlers (for fast access by name).
|
protected String |
_jhoveHome
JHOVE home directory.
|
protected Logger |
_logger
Logger for this class.
|
protected String |
_logLevel
Logger resource bundle.
|
protected String |
_mixVsn
MIX version.
|
protected List<Module> |
_moduleList
Ordered list of modules.
|
protected Map<String,Module> |
_moduleMap
Map of modules (for fast access by name).
|
static String |
_name |
protected long |
_nByte
Byte count for digital object
|
protected String |
_outputFile |
protected File |
_saveDir
Directory for saving files.
|
protected String |
_saxClass
SAX parser class.
|
protected boolean |
_showRaw |
protected int |
_sigBytes
Number of bytes for fake signature checking.
|
protected boolean |
_signature |
protected String |
_tempDir
Temporary directory.
|
| Constructor and Description |
|---|
JhoveBase()
Class constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
abort()
Aborts an activity.
|
File |
connToTempFile(URLConnection conn,
RepInfo info)
Saves a URLConnection's data stream to a temporary file.
|
void |
dispatch(App app,
Module module,
OutputHandler aboutHandler,
OutputHandler handler,
String outputFile,
String[] dirFileOrUri)
Processes a file or directory, or outputs information.
|
boolean |
getAbort()
Returns the abort flag.
|
int |
getBufferSize()
Returns buffer size.
|
boolean |
getChecksumFlag()
Returns
true if checksums are requested. |
String |
getConfigFile()
Returns the configuration file.
|
static String |
getConfigFileFromProperties()
Uses the user.home property to locate the configuration file.
|
Date |
getDate()
Returns the engine date (the date at which this instance was created).
|
String |
getEncoding()
Returns the output encoding.
|
Map<String,String> |
getExtension()
Returns the JHOVE configuration extensions.
|
String |
getExtension(String name)
Returns the JHOVE configuration extension by name.
|
static String |
getFromProperties(String name)
Returns a named value from the properties file.
|
OutputHandler |
getHandler(String name)
Returns a handler by name.
|
List<OutputHandler> |
getHandlerList()
Returns the list of handlers.
|
Map<String,OutputHandler> |
getHandlerMap()
Returns map of handler names to handlers.
|
String |
getJhoveHome()
Returns the JHOVE home directory.
|
String |
getMixVersion()
Returns the requested MIX schema version.
|
Module |
getModule(String name)
Returns a module by name.
|
List<Module> |
getModuleList()
Returns the list of modules.
|
Map<String,Module> |
getModuleMap()
Returns the map of module names to modules.
|
String |
getName()
Returns the engine name.
|
String |
getOuputFile()
Returns the output file.
|
String |
getRelease()
Returns the engine release.
|
String |
getRights()
Returns the engine rights statement.
|
File |
getSaveDirectory()
Returns the directory designated for saving files.
|
String |
getSaxClass()
Returns the SAX class.
|
static String |
getSaxClassFromProperties()
Returns the value of the property
edu.harvard.hul.ois.jhove.saxClass, which should be the name
of the main SAX class. |
boolean |
getShowRawFlag()
Returns
true if raw output is requested. |
int |
getSigBytes()
Returns the maximum number of bytes to check, for modules that look for
an indefinitely positioned signature or check the first sigBytes bytes
in lieu of a signature.
|
boolean |
getSignatureFlag()
Returns the "check signature only" flag.
|
String |
getTempDirectory()
Returns the temporary directory path.
|
void |
init(String configFile,
String saxClass)
Initializes the JHOVE engine.
|
protected static PrintWriter |
makeWriter(String outputFile,
String encoding)
Creates an output PrintWriter.
|
File |
newTempFile()
Creates a temporary file with a unique name.
|
boolean |
process(App app,
Module module,
OutputHandler handler,
String dirFileOrUri)
Returns
false if processing should be aborted. |
boolean |
processFile(App app,
Module module,
boolean verbose,
File file,
RepInfo info)
Processes the file.
|
void |
resetAbort()
Resets the abort flag.
|
void |
setBufferSize(int bufferSize)
Sets the buffer size.
|
void |
setCallback(Callback callback)
Sets a callback object for tracking progress.
|
void |
setChecksumFlag(boolean checksum)
Sets the value to be returned by
doChecksum. |
void |
setCurrentThread(Thread t)
Sets the current thread for parsing.
|
void |
setEncoding(String encoding)
Sets the output encoding.
|
void |
setLogLevel(String level)
Sets the log level.
|
void |
setSaveDirectory(File dir)
Sets the default directory for subsequent save operations.
|
void |
setShowRawFlag(boolean raw)
Sets the value to be returned by
getShowRawFlag, which
determines if only raw numeric values should be output. |
void |
setSignatureFlag(boolean signature)
Sets the "check signature only" flag.
|
void |
setTempDirectory(String tempDir)
Sets the temporary directory path.
|
File |
tempFile()
Creates a temporary file with a unique name.
|
public static final String _name
protected boolean _abort
protected int _bufferSize
protected boolean _checksum
protected String _configFile
protected String _encoding
protected List<OutputHandler> _handlerList
protected Map<String,OutputHandler> _handlerMap
protected String _jhoveHome
protected String _outputFile
protected String _saxClass
protected boolean _showRaw
protected boolean _signature
protected String _tempDir
protected String _mixVsn
protected int _sigBytes
protected File _saveDir
protected long _nByte
protected URLConnection _conn
protected Thread _currentThread
protected Logger _logger
protected String _logLevel
public JhoveBase()
throws JhoveException
JhoveBase object.JhoveException - if invoked with a JVM lower than 1.6public void init(String configFile, String saxClass) throws JhoveException
configFile - Configuration file pathnamesaxClass - a SAX parser class, will use JVM default if not suppliedJhoveException - when anything goes wrongpublic void setCallback(Callback callback)
null.public void dispatch(App app, Module module, OutputHandler aboutHandler, OutputHandler handler, String outputFile, String[] dirFileOrUri) throws Exception
dirFileOrUri is null, Does one of the following:
aboutHandler is non-null, provides
information about that handler.
app - The App object for the applicationmodule - The module to be usedaboutHandler - If specified, the handler about which info is requestedhandler - The handler for processing the outputoutputFile - Name of the file to which output should godirFileOrUri - One or more file names or URI's to be analyzedExceptionpublic boolean process(App app, Module module, OutputHandler handler, String dirFileOrUri) throws Exception
false if processing should be aborted.
Calls itself recursively for directories.Exceptionpublic File connToTempFile(URLConnection conn, RepInfo info) throws IOException
abort, in which
case it will delete the temporary file and return null.IOExceptionpublic void abort()
public boolean processFile(App app, Module module, boolean verbose, File file, RepInfo info) throws Exception
false if aborted, or if
the module is incapable of validation. This shouldn't be called if
the module doesn't have the validation feature.Exceptionpublic File tempFile() throws IOException
IOExceptionpublic boolean getAbort()
public int getBufferSize()
public String getConfigFile()
public Date getDate()
public String getEncoding()
public String getExtension(String name)
public OutputHandler getHandler(String name)
public Map<String,OutputHandler> getHandlerMap()
public List<OutputHandler> getHandlerList()
public String getJhoveHome()
public String getName()
public String getOuputFile()
public String getRelease()
public String getRights()
public String getSaxClass()
public String getTempDirectory()
public int getSigBytes()
public File getSaveDirectory()
setSaveDirectory.public boolean getChecksumFlag()
true if checksums are requested.public boolean getShowRawFlag()
true if raw output is requested. Raw output means
numeric rather than symbolic output; its exact interpretation is up to
the module, but generally applies to named flags.public boolean getSignatureFlag()
public String getMixVersion()
public void setBufferSize(int bufferSize)
public void setEncoding(String encoding)
public void setTempDirectory(String tempDir)
public void setLogLevel(String level)
public void setChecksumFlag(boolean checksum)
doChecksum.public void setShowRawFlag(boolean raw)
getShowRawFlag, which
determines if only raw numeric values should be output.public void setSignatureFlag(boolean signature)
public void setSaveDirectory(File dir)
public void setCurrentThread(Thread t)
public void resetAbort()
public static String getConfigFileFromProperties()
jhove.conf. Returns
null if no such file is found.public static String getSaxClassFromProperties()
edu.harvard.hul.ois.jhove.saxClass, which should be the name
of the main SAX class. Returns null if no such property has
been set up.public static String getFromProperties(String name)
protected static PrintWriter makeWriter(String outputFile, String encoding) throws JhoveException
outputFile - Output filepath. If null, writer goes to System.out.encoding - Character encoding. Must not be null.JhoveExceptionpublic File newTempFile() throws IOException
IOExceptionCopyright © 2008–2018 The Open Preservation Foundation. All rights reserved.