JhoveBase (JHOVE Documentation)
Date: 2013-09-08

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.harvard.hul.ois.jhove
Class JhoveBase

    java.lang.Object
      edu.harvard.hul.ois.jhove.JhoveBase

    public class JhoveBase

extends java.lang.Object

The JHOVE engine, providing all base services necessary to build an application. More than one JhoveBase may be instantiated and process files in concurrent threads. Any one instance must not be multithreaded.

Field Summary
`protected boolean` | `_abort` Flag for aborting activity.
`protected int` | `_bufferSize` Buffer size for buffered I/O.
`protected boolean` | `_checksum`
`protected java.lang.String` | `_configFile` Configuration file pathname.
`protected java.net.URLConnection` | `_conn` Current URL connection.
`protected java.lang.Thread` | `_currentThread` Thread currently parsing a document.
`protected java.lang.String` | `_encoding` Selected encoding.
`protected java.util.Map<java.lang.String,java.lang.String>` | `_extensions` Associate map of configution extensions.
`protected java.util.List<OutputHandler>` | `_handlerList` Ordered list of output handlers.
`protected java.util.Map<java.lang.String,OutputHandler>` | `_handlerMap` Map of output handlers (for fast access by name).
`protected java.lang.String` | `_jhoveHome` JHOVE home directory.
`protected java.util.logging.Logger` | `_logger` Logger for this class.
`protected java.lang.String` | `_logLevel` Logger resource bundle.
`protected java.lang.String` | `_mixVsn` MIX version.
`protected java.util.List<Module>` | `_moduleList` Ordered list of modules.
`protected java.util.Map<java.lang.String,Module>` | `_moduleMap` Map of modules (for fast access by name).
`static java.lang.String` | `_name`
`protected long` | `_nByte` Byte count for digital object
`protected java.lang.String` | `_outputFile`
`static java.lang.String` | `_release`
`protected java.io.File` | `_saveDir` Directory for saving files.
`protected java.lang.String` | `_saxClass` SAX parser class.
`protected boolean` | `_showRaw`
`protected int` | `_sigBytes` Number of bytes for fake signature checking.
`protected boolean` | `_signature`
`protected java.lang.String` | `_tempDir` Temporary directory.
`static int[]` | `DATE`

Constructor Summary
`JhoveBase()` Instantiate a `JhoveBase` object.

Method Summary
`void` | `abort()` Aborts an activity.
`java.io.File` | `connToTempFile(java.net.URLConnection conn, RepInfo info)` Saves a URLConnection's data stream to a temporary file.
`void` | `dispatch(App app, Module module, OutputHandler aboutHandler, OutputHandler handler, java.lang.String outputFile, java.lang.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 checksumming is requested.
`java.lang.String` | `getConfigFile()` Returns the configuration file.
`static java.lang.String` | `getConfigFileFromProperties()` Uses the user.home property to locate the configuration file.
`java.util.Date` | `getDate()` Returns the engine date (the date at which this instance was created).
`java.lang.String` | `getEncoding()` Returns the output encoding.
`java.util.Map<java.lang.String,java.lang.String>` | `getExtension()` Return the JHOVE configuration extensions.
`java.lang.String` | `getExtension(java.lang.String name)` Return the JHOVE configuration extension by name.
`static java.lang.String` | `getFromProperties(java.lang.String name)` Returns a named value from the properties file.
`OutputHandler` | `getHandler(java.lang.String name)` Return a handler by name.
`java.util.List<OutputHandler>` | `getHandlerList()` Returns the list of handlers.
`java.util.Map<java.lang.String,OutputHandler>` | `getHandlerMap()` Returns map of handler names to handlers.
`java.lang.String` | `getJhoveHome()` Returns the JHOVE home directory.
`java.lang.String` | `getMixVersion()` Returns the requested MIX schema version.
`Module` | `getModule(java.lang.String name)` Returns a module by name.
`java.util.List<Module>` | `getModuleList()` Returns the List of modules.
`java.util.Map<java.lang.String,Module>` | `getModuleMap()` Returns the Map of module names to modules.
`java.lang.String` | `getName()` Returns the engine name.
`java.lang.String` | `getOuputFile()` Returns the output file.
`java.lang.String` | `getRelease()` Returns the engine release.
`java.lang.String` | `getRights()` Return the engine rights statement
`java.io.File` | `getSaveDirectory()` Return the directory designated for saving files.
`java.lang.String` | `getSaxClass()` Return the SAX class.
`static java.lang.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()` Return 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.
`java.lang.String` | `getTempDirectory()` Return the temporary directory.
`void` | `init(java.lang.String configFile, java.lang.String saxClass)` Initialize the JHOVE engine.
`protected static java.io.PrintWriter` | `makeWriter(java.lang.String outputFile, java.lang.String encoding)` Creates an output PrintWriter.
`java.io.File` | `newTempFile()` Creates a temporary file with a unique name.
`boolean` | `process(App app, Module module, OutputHandler handler, java.lang.String dirFileOrUri)`
`boolean` | `processFile(App app, Module module, boolean verbose, java.io.File file, RepInfo info)`
`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(java.lang.Thread t)` Sets the current thread for parsing.
`void` | `setEncoding(java.lang.String encoding)` Sets the output encoding.
`void` | `setLogLevel(java.lang.String level)` Sets the log level.
`void` | `setSaveDirectory(java.io.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(java.lang.String tempDir)` Sets the temporary directory path.
`java.io.File` | `tempFile()` Creates a temporary file with a unique name.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### _name

    public static final java.lang.String _name

See Also:
  Constant Field Values

### _release

    public static final java.lang.String _release

See Also:
  Constant Field Values

### DATE

    public static final int[] DATE

### _abort

    protected boolean _abort

  Flag for aborting activity.

### _bufferSize

    protected int _bufferSize

  Buffer size for buffered I/O.

### _checksum

    protected boolean _checksum

### _configFile

    protected java.lang.String _configFile

  Configuration file pathname.

### _encoding

    protected java.lang.String _encoding

  Selected encoding.

### _extensions

    protected java.util.Map<java.lang.String,java.lang.String> _extensions

  Associate map of configution extensions.

### _handlerList

    protected java.util.List<OutputHandler> _handlerList

  Ordered list of output handlers.

### _handlerMap

    protected java.util.Map<java.lang.String,OutputHandler> _handlerMap

  Map of output handlers (for fast access by name).

### _jhoveHome

    protected java.lang.String _jhoveHome

  JHOVE home directory.

### _moduleList

    protected java.util.List<Module> _moduleList

  Ordered list of modules.

### _moduleMap

    protected java.util.Map<java.lang.String,Module> _moduleMap

  Map of modules (for fast access by name).

### _outputFile

    protected java.lang.String _outputFile

### _saxClass

    protected java.lang.String _saxClass

  SAX parser class.

### _showRaw

    protected boolean _showRaw

### _signature

    protected boolean _signature

### _tempDir

    protected java.lang.String _tempDir

  Temporary directory.

### _mixVsn

    protected java.lang.String _mixVsn

  MIX version.

### _sigBytes

    protected int _sigBytes

  Number of bytes for fake signature checking.

### _saveDir

    protected java.io.File _saveDir

  Directory for saving files.

### _nByte

    protected long _nByte

  Byte count for digital object

### _conn

    protected java.net.URLConnection _conn

  Current URL connection.

### _currentThread

    protected java.lang.Thread _currentThread

  Thread currently parsing a document.

### _logger

    protected java.util.logging.Logger _logger

  Logger for this class.

### _logLevel

    protected java.lang.String _logLevel

  Logger resource bundle.

Constructor Detail

### JhoveBase

    public JhoveBase()
              throws JhoveException

  Instantiate a `JhoveBase` object.

  Throws:
    `JhoveException` - If invoked with JVM lower than 1.5

Method Detail

### init

    public void init(java.lang.String configFile,
                     java.lang.String saxClass)
              throws JhoveException

  Initialize the JHOVE engine.

  Parameters:
    `configFile` - Configuration file pathname
  Throws:
    `JhoveException`

### setCallback

    public void setCallback(Callback callback)

  Sets a callback object for tracking progress. By default, the callback is null.

### dispatch

    public void dispatch(App app,
                         Module module,
                         OutputHandler aboutHandler,
                         OutputHandler handler,
                         java.lang.String outputFile,
                         java.lang.String[] dirFileOrUri)
                  throws java.lang.Exception

  Processes a file or directory, or outputs information. If `dirFileOrUri` is null, Does one of the following:
  - If module is non-null, provides information about the module.
  - Otherwise if `aboutHandler` is non-null, provides information about that handler.
  - If they're both null, provides information about the application.

  Parameters:
    `app` - The App object for the application
    `module` - The module to be used
    `aboutHandler` - If specified, the handler about which info is requested
    `handler` - The handler for processing the output
    `outputFile` - Name of the file to which output should go
    `dirFileOrUri` - One or more file names or URI's to be analyzed
  Throws:
    `java.lang.Exception`

### process

    public boolean process(App app,
                           Module module,
                           OutputHandler handler,
                           java.lang.String dirFileOrUri)
                    throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### connToTempFile

    public java.io.File connToTempFile(java.net.URLConnection conn,
                                       RepInfo info)
                                throws java.io.IOException

  Saves a URLConnection's data stream to a temporary file. This may be interrupted asynchronously by calling `abort ()`, in which case it will delete the temporary file and return `null`.

  Throws:
    `java.io.IOException`

### abort

    public void abort()

  Aborts an activity. This simply sets a flag; whether anything is aborted depends on what activity is happening.

### processFile

    public boolean processFile(App app,
                               Module module,
                               boolean verbose,
                               java.io.File file,
                               RepInfo info)
                        throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### tempFile

    public java.io.File tempFile()
                          throws java.io.IOException

  Creates a temporary file with a unique name. The file will be deleted when the application exits.

  Throws:
    `java.io.IOException`

### getAbort

    public boolean getAbort()

  Returns the abort flag.

### getBufferSize

    public int getBufferSize()

  Returns buffer size. A value of -1 signifies that the invoknig code should assume the default buffer size.

### getConfigFile

    public java.lang.String getConfigFile()

  Returns the configuration file.

### getDate

    public java.util.Date getDate()

  Returns the engine date (the date at which this instance was created).

### getEncoding

    public java.lang.String getEncoding()

  Returns the output encoding.

### getExtension

    public java.util.Map<java.lang.String,java.lang.String> getExtension()

  Return the JHOVE configuration extensions.

### getExtension

    public java.lang.String getExtension(java.lang.String name)

  Return the JHOVE configuration extension by name.

### getHandler

    public OutputHandler getHandler(java.lang.String name)

  Return a handler by name.

### getHandlerMap

    public java.util.Map<java.lang.String,OutputHandler> getHandlerMap()

  Returns map of handler names to handlers.

### getHandlerList

    public java.util.List<OutputHandler> getHandlerList()

  Returns the list of handlers.

### getJhoveHome

    public java.lang.String getJhoveHome()

  Returns the JHOVE home directory.

### getModule

    public Module getModule(java.lang.String name)

  Returns a module by name.

### getModuleMap

    public java.util.Map<java.lang.String,Module> getModuleMap()

  Returns the Map of module names to modules.

### getModuleList

    public java.util.List<Module> getModuleList()

  Returns the List of modules.

### getName

    public java.lang.String getName()

  Returns the engine name.

### getOuputFile

    public java.lang.String getOuputFile()

  Returns the output file.

### getRelease

    public java.lang.String getRelease()

  Returns the engine release.

### getRights

    public java.lang.String getRights()

  Return the engine rights statement

### getSaxClass

    public java.lang.String getSaxClass()

  Return the SAX class.

### getTempDirectory

    public java.lang.String getTempDirectory()

  Return the temporary directory.

### getSigBytes

    public int getSigBytes()

  Return 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

### getSaveDirectory

    public java.io.File getSaveDirectory()

  Return the directory designated for saving files. This is simply the directory most recently set by setSaveDirectory.

### getChecksumFlag

    public boolean getChecksumFlag()

  Returns `true` if checksumming is requested.

### getShowRawFlag

    public boolean getShowRawFlag()

  Returns `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.

### getSignatureFlag

    public boolean getSignatureFlag()

  Returns the "check signature only" flag.

### getMixVersion

    public java.lang.String getMixVersion()

  Returns the requested MIX schema version.

### setBufferSize

    public void setBufferSize(int bufferSize)

  Sets the buffer size. A value of -1 signifies that the invoking code will assume the default buffer size. Any non-negative value less than 1024 will result in a buffer size of 1024.

### setEncoding

    public void setEncoding(java.lang.String encoding)

  Sets the output encoding.

### setTempDirectory

    public void setTempDirectory(java.lang.String tempDir)

  Sets the temporary directory path.

### setLogLevel

    public void setLogLevel(java.lang.String level)

  Sets the log level. The value should be the name of a predefined instance of java.util.logging.Level, e.g., "WARNING", "INFO", "ALL". This will override the config file setting.

### setChecksumFlag

    public void setChecksumFlag(boolean checksum)

  Sets the value to be returned by `doChecksum()`.

### setShowRawFlag

    public void setShowRawFlag(boolean raw)

  Sets the value to be returned by `getShowRawFlag ()`, which determines if only raw numeric values should be output.

### setSignatureFlag

    public void setSignatureFlag(boolean signature)

  Sets the "check signature only" flag.

### setSaveDirectory

    public void setSaveDirectory(java.io.File dir)

  Sets the default directory for subsequent save operations.

### setCurrentThread

    public void setCurrentThread(java.lang.Thread t)

  Sets the current thread for parsing.

### resetAbort

    public void resetAbort()

  Resets the abort flag. This must be called at the beginning of any activity for which the abort flag may subsequently be set.

### getConfigFileFromProperties

    public static java.lang.String getConfigFileFromProperties()

  Uses the user.home property to locate the configuration file. The file is expected to be in the subdirectory named by CONFIG_DIR under the home directory, and to be named `jhove.conf`. Returns `null` if no such file is found.

### getSaxClassFromProperties

    public static java.lang.String getSaxClassFromProperties()

  Returns the value of the property `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.

### getFromProperties

    public static java.lang.String getFromProperties(java.lang.String name)

  Returns a named value from the properties file.

### makeWriter

    protected static java.io.PrintWriter makeWriter(java.lang.String outputFile,
                                                    java.lang.String encoding)
                                             throws JhoveException

  Creates an output PrintWriter.

  Parameters:
    `outputFile` - Output filepath. If null, writer goes to System.out.
    `encoding` - Character encoding. Must not be null.
  Throws:
    `JhoveException`

### newTempFile

    public java.io.File newTempFile()
                             throws java.io.IOException

  Creates a temporary file with a unique name. The file will be deleted when the application exits.

  Throws:
    `java.io.IOException`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD