Package edu.harvard.hul.ois.jhove
Class HandlerBase
java.lang.Object
edu.harvard.hul.ois.jhove.HandlerBase
- All Implemented Interfaces:
OutputHandler
- Direct Known Subclasses:
JsonHandler,TextHandler,XmlHandler
Abstract base class for Jhove output handlers.
Output handlers should normally subclass HandlerBase.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA DateFormat class to address an issue of thread safety. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AppThe application objectprotected JhoveBaseThe Jhove engineprotected DateHandler last modification dateList of default parameters.protected StringCharacter encoding for writerprotected StringInitialization value.protected JhoveBaseJHOVE engine.protected intIndentation levelprotected LoggerLogger for a handler class.protected StringHandler nameprotected StringHandler noteprotected StringHandler-specific parameter.protected StringHandler release description.protected StringCopyright noticeHandler specification document listprotected AgentHandler vendorprotected PrintWriterWriter for doing outputA DateFormat for representing a Date in yyyy-MM-dd (e.g., 2003-07-31) format.A DateFormat for representing a Date in yyyy-MM-dd HH:mm:ss z (e.g., 2003-07-31 15:31:12 EDT) format.A DateFormat for representing a Date in ISO 8601 (e.g., 2003-07-31T15:31:12-0400) format. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHandlerBase(String name, String release, int[] date, String note, String rights) Constructors of all subclasses of HandlerBase should call this as asuperconstructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidCallback allowing post-parse, pre-show analysis of object representation information.voidApplies the default parameters.voidclose()Close the writer after all output has been done.protected static StringReturn the XML DOCTYPE instruction.protected static StringReturn the XML DOCTYPE instruction.protected static StringdoubleArray(double[] darray) Return String representation of an array of double.protected static StringReturns, as a String, an empty XML.protected static StringReturns, as a String, an XML element with a given tag and contentprotected static StringReturns, as a String, an XML element with a given tag and attributesprotected static StringReturns, as a String, an XML element with a given tag, content and attributesprotected static StringelementEnd(String tag) Returns, as a String, the closing tag of an element.protected static StringelementStart(String tag) Returns, as a String, the opening tag of an element.protected static StringelementStart(String tag, String[][] attrs) Returns, as a String, the opening tag of an element with specified attributes.voidCallback indicating a directory is finished being processed.final DategetDate()Return the last modification date of this OutputHandler, as a Java Date objectReturns this handler's encoding.protected static StringgetIndent(int level) Returns a String containing a number of spaces equal to the current indent level.final StringgetName()Return the OutputHandler namefinal StringgetNote()Return the OutputHandler notefinal StringReturn the release identifierfinal StringReturn the copyright information stringReturns a list ofDocumentobjects (one for each specification document).final AgentReturn the vendor informationvoidPer-instantiation initialization.protected static StringintegerArray(int[] iarray) Return String representation of an integer array.protected static StringintegerArray(int[] iarray, char separator) Return String representation of an integer array with specified separator.protected static StringlongArray(long[] larray) Return String representation of an array of long with space separator.booleanokToProcess(String filepath) Callback to give the handler the opportunity to decide whether or not to process a file.voidPer-action initialization.protected static StringrationalArray(Rational[] rarray) Return String representation of an array of Rational, each evaluated as a double, with space separator.protected static StringrationalArray10(Rational[] rarray) Return String representation of an array of Rational, each as two integers, with space separator.voidreset()Reset the handler.voidReset parameter settings.final voidPass the associated App object to this Module.final voidAssigns the JHOVE engine object to provide services to this handlervoidsetDefaultParams(List<String> params) Set a a List of default parameters for the module.voidsetEncoding(String encoding) Assigns the encoding to be used by this OutputHandlerfinal voidsetWriter(PrintWriter writer) Assigns a PrintWriter to do output for this OutputHandlerabstract voidshow()Outputs minimal information about the applicationabstract voidOutputs detailed information about the application, including configuration, available modules and handlers, etc.abstract voidOutputs information about a Moduleabstract voidshow(OutputHandler handler) Outputs information about the OutputHandler specified in the parameterabstract voidOutputs the information contained in a RepInfo objectabstract voidDo the final output.abstract voidDo the initial output.voidstartDirectory(String directory) Callback indicating a new directory is being processed.protected StringtoDateTime(Date date) protected static StringxmlDecl()Return a canonical XML declaration with default encoding.protected static StringReturn a canonical XML declaration with specified encoding.
-
Field Details
-
date
A DateFormat for representing a Date in yyyy-MM-dd (e.g., 2003-07-31) format. -
dateTime
A DateFormat for representing a Date in yyyy-MM-dd HH:mm:ss z (e.g., 2003-07-31 15:31:12 EDT) format. -
iso8601
A DateFormat for representing a Date in ISO 8601 (e.g., 2003-07-31T15:31:12-0400) format. We subclass SimpleDateFormat to make it thread-safe. -
_app
The application object -
_base
The Jhove engine -
_date
Handler last modification date -
_encoding
Character encoding for writer -
_init
Initialization value. -
_defaultParams
List of default parameters. -
_je
JHOVE engine. -
_level
protected int _levelIndentation level -
_name
Handler name -
_note
Handler note -
_release
Handler release description. -
_param
Handler-specific parameter. -
_rights
Copyright notice -
_specification
Handler specification document list -
_vendor
Handler vendor -
_writer
Writer for doing output -
_logger
Logger for a handler class.
-
-
Constructor Details
-
HandlerBase
Constructors of all subclasses of HandlerBase should call this as asuperconstructor.- Parameters:
name- Name of the handlerrelease- Release identifierdate- Last modification date of the handler code, in the form of an array of three numbers.date[0]is the year,date[1]the month, anddate[2]the day.note- Additional information about the handler (may be null)rights- Copyright notice for the handler
-
-
Method Details
-
reset
public void reset()Reset the handler. This needs to be called before each invocation.- Specified by:
resetin interfaceOutputHandler
-
setDefaultParams
Set a a List of default parameters for the module.- Specified by:
setDefaultParamsin interfaceOutputHandler- Parameters:
params- A List whose elements are Strings. May be empty.
-
applyDefaultParams
public void applyDefaultParams()Applies the default parameters. Calling this clears any prior parameters.- Specified by:
applyDefaultParamsin interfaceOutputHandler
-
resetParams
public void resetParams()Reset parameter settings. Returns to a default state without any parameters. The default method clears the saved parameter.- Specified by:
resetParamsin interfaceOutputHandler
-
init
Per-instantiation initialization. The default method does nothing.- Specified by:
initin interfaceOutputHandler- Parameters:
init- Initialization parameter. This is typically obtained from the configuration file.
-
param
Per-action initialization. The default method does nothing.- Specified by:
paramin interfaceOutputHandler- Parameters:
param- Initialization parameter.
-
getDate
Return the last modification date of this OutputHandler, as a Java Date object- Specified by:
getDatein interfaceOutputHandler
-
getName
Return the OutputHandler name- Specified by:
getNamein interfaceOutputHandler
-
getNote
Return the OutputHandler note- Specified by:
getNotein interfaceOutputHandler
-
getRelease
Return the release identifier- Specified by:
getReleasein interfaceOutputHandler
-
getRights
Return the copyright information string- Specified by:
getRightsin interfaceOutputHandler
-
getSpecification
Returns a list ofDocumentobjects (one for each specification document). The specification list is generated by the OutputHandler, and specifications cannot be added by callers.- Specified by:
getSpecificationin interfaceOutputHandler- See Also:
-
getVendor
Return the vendor information- Specified by:
getVendorin interfaceOutputHandler
-
getEncoding
Returns this handler's encoding.- Specified by:
getEncodingin interfaceOutputHandler
-
setApp
Pass the associated App object to this Module. The App makes various services available.- Specified by:
setAppin interfaceOutputHandler
-
setBase
Assigns the JHOVE engine object to provide services to this handler- Specified by:
setBasein interfaceOutputHandler
-
setEncoding
Assigns the encoding to be used by this OutputHandler- Specified by:
setEncodingin interfaceOutputHandler
-
setWriter
Assigns a PrintWriter to do output for this OutputHandler- Specified by:
setWriterin interfaceOutputHandler
-
analyze
Callback allowing post-parse, pre-show analysis of object representation information.- Specified by:
analyzein interfaceOutputHandler- Parameters:
info- Object representation information
-
endDirectory
public void endDirectory()Callback indicating a directory is finished being processed.- Specified by:
endDirectoryin interfaceOutputHandler
-
okToProcess
Callback to give the handler the opportunity to decide whether or not to process a file. Most handlers will always return true.- Specified by:
okToProcessin interfaceOutputHandler- Parameters:
filepath- File pathname
-
show
Outputs information about a Module- Specified by:
showin interfaceOutputHandler
-
show
Outputs the information contained in a RepInfo object- Specified by:
showin interfaceOutputHandler
-
show
Outputs information about the OutputHandler specified in the parameter- Specified by:
showin interfaceOutputHandler
-
show
public abstract void show()Outputs minimal information about the application- Specified by:
showin interfaceOutputHandler
-
show
Outputs detailed information about the application, including configuration, available modules and handlers, etc.- Specified by:
showin interfaceOutputHandler
-
showHeader
public abstract void showHeader()Do the initial output. This should be in a suitable format for including multiple files between the header and the footer.- Specified by:
showHeaderin interfaceOutputHandler
-
close
public void close()Close the writer after all output has been done.- Specified by:
closein interfaceOutputHandler
-
startDirectory
Callback indicating a new directory is being processed.- Specified by:
startDirectoryin interfaceOutputHandler- Parameters:
directory- Directory path
-
doctype
Return the XML DOCTYPE instruction.- Parameters:
root- Root element of the DTDuri- URI of the DTD
-
doctype
Return the XML DOCTYPE instruction.- Parameters:
root- Root element of the DTDname- Public name of the DTDuri- URI of the DTD
-
element
Returns, as a String, an empty XML.- Parameters:
tag- XML tag
-
element
Returns, as a String, an XML element with a given tag and content- Parameters:
tag- An XML tagcontent- Content string. Characters requiring conversion to entitites will be converted.
-
element
Returns, as a String, an XML element with a given tag and attributes- Parameters:
tag- An XML tagattrs- An array of String[2] elements, where for each element, attrs[i][0] is the attribute key and attrs[i][1] is the attribute value. Null values are skipped.
-
element
Returns, as a String, an XML element with a given tag, content and attributes- Parameters:
tag- An XML tagcontent- Content string. Characters requiring conversion to entitites will be converted.attrs- An array of String[2] elements, where for each element, attrs[i][0] is the attribute key and attrs[i][1] is the attribute value. Null values are skipped.
-
elementEnd
Returns, as a String, the closing tag of an element. No checking is done that opening and closing tags match.- Parameters:
tag- An XML tag
-
elementStart
Returns, as a String, the opening tag of an element.- Parameters:
tag- An XML tag
-
elementStart
Returns, as a String, the opening tag of an element with specified attributes.- Parameters:
tag- An XML tagattrs- An array of String[2] elements, where for each element, attrs[i][0] is the attribute key and attrs[i][1] is the attribute value.
-
xmlDecl
Return a canonical XML declaration with default encoding. -
xmlDecl
Return a canonical XML declaration with specified encoding. -
getIndent
Returns a String containing a number of spaces equal to the current indent level. -
integerArray
Return String representation of an integer array. -
integerArray
Return String representation of an integer array with specified separator. -
longArray
Return String representation of an array of long with space separator. -
rationalArray
Return String representation of an array of Rational, each evaluated as a double, with space separator. -
rationalArray10
Return String representation of an array of Rational, each as two integers, with space separator. -
doubleArray
Return String representation of an array of double. -
toDateTime
-