edu.harvard.hul.ois.jhove
Class ConfigHandler

java.lang.Object
  extended by org.xml.sax.helpers.DefaultHandler
      extended by edu.harvard.hul.ois.jhove.ConfigHandler
All Implemented Interfaces:
org.xml.sax.ContentHandler, org.xml.sax.DTDHandler, org.xml.sax.EntityResolver, org.xml.sax.ErrorHandler

public class ConfigHandler
extends org.xml.sax.helpers.DefaultHandler

SAX Parser for the configuration file.


Field Summary
protected  java.lang.StringBuffer _content
           
protected  java.util.List<java.util.List<java.lang.String>> _handlerParams
          The list of handler parameters.
protected  boolean _isHandler
           
protected  boolean _isModule
           
protected  java.util.List<java.util.List<java.lang.String>> _modParams
          The list of module parameters.
protected  java.util.List<ModuleInfo> _module
          The list of modules.
 
Constructor Summary
ConfigHandler()
          Creates a ConfigHandler.
 
Method Summary
 void characters(char[] ch, int start, int length)
          SAX parser callback method.
 void endElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName)
          SAX parser callback method.
 int getBufferSize()
          Returns the buffer size specified in the config file.
 java.lang.String getEncoding()
          Returns the character encoding specified by the config file.
 java.util.Map<java.lang.String,java.lang.String> getExtensions()
          Return an associative map of configuration extensions.
 java.util.List<java.lang.String[]> getHandler()
          Returns the List of OutputHandlers specified by the config file.
 java.util.List<java.util.List<java.lang.String>> getHandlerParams()
          Returns the List of handler parameters specified by the config file.
 java.lang.String getJhoveHome()
          Returns the path to the application's home directory, with final path separator.
 java.lang.String getLogLevel()
          Returns the name of the desired log level.
 java.lang.String getMixVsn()
          Returns the MIX schema version specified by the config file.
 java.util.List<ModuleInfo> getModule()
          Returns the List of Modules specified by the config file.
 java.util.List<java.util.List<java.lang.String>> getModuleParams()
          Returns the List of module parameters specified by the config file.
 int getSigBytes()
          Returns the number of bytes to examine when looking for an indefinitely positioned signature, or checking the first sigBytes bytes of a file in lieu of a signature.
 java.lang.String getTempDir()
          Returns the temporary directory path specified by the config file, with final path separator.
 org.xml.sax.InputSource resolveEntity(java.lang.String publicId, java.lang.String systemId)
          EntityResolver designed to locate the config schema.
 void startElement(java.lang.String namespaceURI, java.lang.String localName, java.lang.String rawName, org.xml.sax.Attributes atts)
          SAX parser callback method.
 
Methods inherited from class org.xml.sax.helpers.DefaultHandler
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_content

protected java.lang.StringBuffer _content

_handlerParams

protected java.util.List<java.util.List<java.lang.String>> _handlerParams
The list of handler parameters. Each element in the List is a List of Strings (which may be empty but not null) representing parameters to be passed to the module. List elements are in one-to-one correspondence with _handler.


_isHandler

protected boolean _isHandler

_isModule

protected boolean _isModule

_module

protected java.util.List<ModuleInfo> _module
The list of modules. Each element in the List is an array of two Strings representing the class and the initialization string.


_modParams

protected java.util.List<java.util.List<java.lang.String>> _modParams
The list of module parameters. Each element in the List is a List of Strings (which may be empty but not null) representing parameters to be passed to the module. List elements are in one-to-one correspondence with _module.

Constructor Detail

ConfigHandler

public ConfigHandler()
Creates a ConfigHandler.

Method Detail

getModule

public java.util.List<ModuleInfo> getModule()
Returns the List of Modules specified by the config file. Each element of the List is a String[2] whose elements are the module class name and initialization value.

See Also:
Module

getModuleParams

public java.util.List<java.util.List<java.lang.String>> getModuleParams()
Returns the List of module parameters specified by the config file. Each element of the List is a List (possibly empty) of Strings whose elements are parameters to pass to the module. The values returned by getModuleParams() are in one-to-one correspondence with those return by getModule().


getHandlerParams

public java.util.List<java.util.List<java.lang.String>> getHandlerParams()
Returns the List of handler parameters specified by the config file. Each element of the List is a List (possibly empty) of Strings whose elements are parameters to pass to the output handler. The values returned by getHandlerParams() are in one-to-one correspondence with those return by getHandler().


getHandler

public java.util.List<java.lang.String[]> getHandler()
Returns the List of OutputHandlers specified by the config file.

See Also:
OutputHandler

getTempDir

public java.lang.String getTempDir()
Returns the temporary directory path specified by the config file, with final path separator.


getMixVsn

public java.lang.String getMixVsn()
Returns the MIX schema version specified by the config file. Acceptable values are "0.2" and "1.0" and "2.0".


getSigBytes

public int getSigBytes()
Returns the number of bytes to examine when looking for an indefinitely positioned signature, or checking the first sigBytes bytes of a file in lieu of a signature.


getEncoding

public java.lang.String getEncoding()
Returns the character encoding specified by the config file.


getBufferSize

public int getBufferSize()
Returns the buffer size specified in the config file.

Returns:
the buffer size, or -1 if none specified

getExtensions

public java.util.Map<java.lang.String,java.lang.String> getExtensions()
Return an associative map of configuration extensions.


getJhoveHome

public java.lang.String getJhoveHome()
Returns the path to the application's home directory, with final path separator.


getLogLevel

public java.lang.String getLogLevel()
Returns the name of the desired log level. This should be the name of one of the predefined values of java.util.logging.Level, e.g., "WARNING", "INFO", "ALL". The default level is SEVERE.


startElement

public void startElement(java.lang.String namespaceURI,
                         java.lang.String localName,
                         java.lang.String rawName,
                         org.xml.sax.Attributes atts)
                  throws org.xml.sax.SAXException
SAX parser callback method.

Specified by:
startElement in interface org.xml.sax.ContentHandler
Overrides:
startElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

characters

public void characters(char[] ch,
                       int start,
                       int length)
                throws org.xml.sax.SAXException
SAX parser callback method.

Specified by:
characters in interface org.xml.sax.ContentHandler
Overrides:
characters in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

endElement

public void endElement(java.lang.String namespaceURI,
                       java.lang.String localName,
                       java.lang.String rawName)
                throws org.xml.sax.SAXException
SAX parser callback method.

Specified by:
endElement in interface org.xml.sax.ContentHandler
Overrides:
endElement in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException

resolveEntity

public org.xml.sax.InputSource resolveEntity(java.lang.String publicId,
                                             java.lang.String systemId)
                                      throws org.xml.sax.SAXException,
                                             java.io.IOException
EntityResolver designed to locate the config schema. It tries to find it as a local resource. It appears that not all SAX implementations will actually call this function for schema resolution, so this isn't a guarantee that the schema in the config file won't be called directly. But hopefully it will cut down on the burden on the server with the official schema copy.

Specified by:
resolveEntity in interface org.xml.sax.EntityResolver
Overrides:
resolveEntity in class org.xml.sax.helpers.DefaultHandler
Throws:
org.xml.sax.SAXException
java.io.IOException