Package edu.harvard.hul.ois.jhove
Class ConfigHandler
- java.lang.Object
-
- org.xml.sax.helpers.DefaultHandler
-
- edu.harvard.hul.ois.jhove.ConfigHandler
-
- All Implemented Interfaces:
ContentHandler,DTDHandler,EntityResolver,ErrorHandler
public class ConfigHandler extends DefaultHandler
SAX Parser for the configuration file.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBuffer_contentprotected List<List<String>>_handlerParamsThe list of handler parameters.protected boolean_isHandlerprotected boolean_isLanguageprotected boolean_isModuleprotected List<List<String>>_modParamsThe list of module parameters.protected List<ModuleInfo>_moduleThe list of modules.
-
Constructor Summary
Constructors Constructor Description ConfigHandler()Creates a ConfigHandler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcharacters(char[] ch, int start, int length)SAX parser callback method.voidendElement(String namespaceURI, String localName, String rawName)SAX parser callback method.intgetBufferSize()Returns the buffer size specified in the config file.StringgetEncoding()Returns the character encoding specified by the config file.List<String[]>getHandler()Returns the List of OutputHandlers specified by the config file.List<List<String>>getHandlerParams()Returns the List of handler parameters specified by the config file.StringgetJhoveHome()Returns the path to the application's home directory, with final path separator.StringgetLanguage()StringgetLogLevel()Returns the name of the desired log level.StringgetMixVsn()Returns the MIX schema version specified by the config file.List<ModuleInfo>getModule()Returns the List of Modules specified by the config file.List<List<String>>getModuleParams()Returns the List of module parameters specified by the config file.intgetSigBytes()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.StringgetTempDir()Returns the temporary directory path specified by the config file, with final path separator.InputSourceresolveEntity(String publicId, String systemId)EntityResolver designed to locate the config schema.voidstartElement(String namespaceURI, String localName, String rawName, 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
-
-
-
-
Field Detail
-
_content
protected StringBuffer _content
-
_handlerParams
protected List<List<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
-
_isLanguage
protected boolean _isLanguage
-
_isModule
protected boolean _isModule
-
_module
protected 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.
-
-
Method Detail
-
getModule
public 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 List<List<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 bygetModuleParams()are in one-to-one correspondence with those return bygetModule().
-
getHandlerParams
public List<List<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 bygetHandlerParams()are in one-to-one correspondence with those return bygetHandler().
-
getHandler
public List<String[]> getHandler()
Returns the List of OutputHandlers specified by the config file.- See Also:
OutputHandler
-
getTempDir
public String getTempDir()
Returns the temporary directory path specified by the config file, with final path separator.
-
getMixVsn
public 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 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
-
getJhoveHome
public String getJhoveHome()
Returns the path to the application's home directory, with final path separator.
-
getLogLevel
public 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.
-
getLanguage
public String getLanguage()
- Returns:
- a language code if set
-
startElement
public void startElement(String namespaceURI, String localName, String rawName, Attributes atts)
SAX parser callback method.- Specified by:
startElementin interfaceContentHandler- Overrides:
startElementin classDefaultHandler
-
characters
public void characters(char[] ch, int start, int length)SAX parser callback method.- Specified by:
charactersin interfaceContentHandler- Overrides:
charactersin classDefaultHandler
-
endElement
public void endElement(String namespaceURI, String localName, String rawName)
SAX parser callback method.- Specified by:
endElementin interfaceContentHandler- Overrides:
endElementin classDefaultHandler
-
resolveEntity
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, 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:
resolveEntityin interfaceEntityResolver- Overrides:
resolveEntityin classDefaultHandler- Throws:
SAXExceptionIOException
-
-