public abstract class HandlerBase extends Object implements OutputHandler
Modifier and Type | Class and Description |
---|---|
static class |
HandlerBase.SynchronizedDateFormat
A DateFormat class to address an issue of thread safety.
|
Modifier and Type | Field and Description |
---|---|
protected App |
_app
The application object
|
protected JhoveBase |
_base
The Jhove engine
|
protected Date |
_date
Handler last modification date
|
protected List<String> |
_defaultParams
List of default parameters.
|
protected String |
_encoding
Character encoding for writer
|
protected String |
_init
Initialization value.
|
protected JhoveBase |
_je
JHOVE engine.
|
protected int |
_level
Indentation level
|
protected Logger |
_logger
Logger for a handler class.
|
protected String |
_name
Handler name
|
protected String |
_note
Handler note
|
protected String |
_param
Handler-specific parameter.
|
protected String |
_release
Handler release description.
|
protected String |
_rights
Copyright notice
|
protected List<Document> |
_specification
Handler specification document list
|
protected Agent |
_vendor
Handler vendor
|
protected PrintWriter |
_writer
Writer for doing output
|
static HandlerBase.SynchronizedDateFormat |
date
A DateFormat for representing a Date in yyyy-MM-dd
(e.g., 2003-07-31) format.
|
static HandlerBase.SynchronizedDateFormat |
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.
|
static HandlerBase.SynchronizedDateFormat |
iso8601
A DateFormat for representing a Date in ISO 8601
(e.g., 2003-07-31T15:31:12-0400) format.
|
Modifier | Constructor and Description |
---|---|
protected |
HandlerBase(String name,
String release,
int[] date,
String note,
String rights)
Constructors of all subclasses of HandlerBase should call
this as a
super constructor. |
Modifier and Type | Method and Description |
---|---|
void |
analyze(RepInfo info)
Callback allowing post-parse, pre-show analysis of object
representation information.
|
void |
applyDefaultParams()
Applies the default parameters.
|
void |
close()
Close the writer after all output has been done.
|
protected static String |
doctype(String root,
String uri)
Return the XML DOCTYPE instruction.
|
protected static String |
doctype(String root,
String name,
String uri)
Return the XML DOCTYPE instruction.
|
protected static String |
doubleArray(double[] darray)
Return String representation of an array of double.
|
protected static String |
element(String tag)
Returns, as a String, an empty XML.
|
protected static String |
element(String tag,
String content)
Returns, as a String, an XML element with a given tag and content
|
protected static String |
element(String tag,
String[][] attrs)
Returns, as a String,
an XML element with a given tag and attributes
|
protected static String |
element(String tag,
String[][] attrs,
String content)
Returns, as a String,
an XML element with a given tag, content and attributes
|
protected static String |
elementEnd(String tag)
Returns, as a String, the closing tag of an element.
|
protected static String |
elementStart(String tag)
Returns, as a String, the opening tag of an element.
|
protected static String |
elementStart(String tag,
String[][] attrs)
Returns, as a String, the opening tag of an element with
specified attributes.
|
void |
endDirectory()
Callback indicating a directory is finished being processed.
|
Date |
getDate()
Return the last modification date of this OutputHandler, as a
Java Date object
|
String |
getEncoding()
Returns this handler's encoding.
|
protected static String |
getIndent(int level)
Returns a String containing a number of spaces equal
to the current indent level.
|
String |
getName()
Return the OutputHandler name
|
String |
getNote()
Return the OutputHandler note
|
String |
getRelease()
Return the release identifier
|
String |
getRights()
Return the copyright information string
|
List<Document> |
getSpecification()
Returns a list of
Document objects (one for each
specification document). |
Agent |
getVendor()
Return the vendor information
|
void |
init(String init)
Per-instantiation initialization.
|
protected static String |
integerArray(int[] iarray)
Return String representation of an integer array.
|
protected static String |
integerArray(int[] iarray,
char separator)
Return String representation of an integer array with
specified separator.
|
protected static String |
longArray(long[] larray)
Return String representation of an array of long with
space separator.
|
boolean |
okToProcess(String filepath)
Callback to give the handler the opportunity to decide whether or
not to process a file.
|
void |
param(String param)
Per-action initialization.
|
protected static String |
rationalArray(Rational[] rarray)
Return String representation of an array of Rational, each evaluated
as a double, with space separator.
|
protected static String |
rationalArray10(Rational[] rarray)
Return String representation of an array of Rational, each as
two integers, with space separator.
|
void |
reset()
Reset the handler.
|
void |
resetParams()
Reset parameter settings.
|
void |
setApp(App app)
Pass the associated App object to this Module.
|
void |
setBase(JhoveBase je)
Assigns the JHOVE engine object to provide services to this handler
|
void |
setDefaultParams(List<String> params)
Set a a List of default parameters for the module.
|
void |
setEncoding(String encoding)
Assigns the encoding to be used by this OutputHandler
|
void |
setWriter(PrintWriter writer)
Assigns a PrintWriter to do output for this OutputHandler
|
abstract void |
show()
Outputs minimal information about the application
|
abstract void |
show(App app)
Outputs detailed information about the application,
including configuration, available modules and handlers,
etc.
|
abstract void |
show(Module module)
Outputs information about a Module
|
abstract void |
show(OutputHandler handler)
Outputs information about the OutputHandler specified
in the parameter
|
abstract void |
show(RepInfo info)
Outputs the information contained in a RepInfo object
|
abstract void |
showFooter()
Do the final output.
|
abstract void |
showHeader()
Do the initial output.
|
void |
startDirectory(String directory)
Callback indicating a new directory is being processed.
|
protected String |
toDateTime(Date date) |
protected static String |
xmlDecl()
Return a canonical XML declaration with default encoding.
|
protected static String |
xmlDecl(String encoding)
Return a canonical XML declaration with specified encoding.
|
public static HandlerBase.SynchronizedDateFormat date
public static HandlerBase.SynchronizedDateFormat dateTime
public static HandlerBase.SynchronizedDateFormat iso8601
protected App _app
protected JhoveBase _base
protected Date _date
protected String _encoding
protected String _init
protected JhoveBase _je
protected int _level
protected String _name
protected String _note
protected String _release
protected String _param
protected String _rights
protected Agent _vendor
protected PrintWriter _writer
protected Logger _logger
protected HandlerBase(String name, String release, int[] date, String note, String rights)
super
constructor.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, and
date[2]
the day.note
- Additional information about the handler
(may be null)rights
- Copyright notice for the handlerpublic void reset()
reset
in interface OutputHandler
public void setDefaultParams(List<String> params)
setDefaultParams
in interface OutputHandler
params
- A List whose elements are Strings.
May be empty.public void applyDefaultParams() throws Exception
applyDefaultParams
in interface OutputHandler
Exception
public void resetParams() throws Exception
resetParams
in interface OutputHandler
Exception
public void init(String init) throws Exception
init
in interface OutputHandler
init
- Initialization parameter. This is typically obtained
from the configuration file.Exception
public void param(String param) throws Exception
param
in interface OutputHandler
param
- Initialization parameter.Exception
public final Date getDate()
getDate
in interface OutputHandler
public final String getName()
getName
in interface OutputHandler
public final String getNote()
getNote
in interface OutputHandler
public final String getRelease()
getRelease
in interface OutputHandler
public final String getRights()
getRights
in interface OutputHandler
public final List<Document> getSpecification()
Document
objects (one for each
specification document). The specification
list is generated by the OutputHandler, and specifications cannot
be added by callers.getSpecification
in interface OutputHandler
Document
public final Agent getVendor()
getVendor
in interface OutputHandler
public String getEncoding()
getEncoding
in interface OutputHandler
public final void setApp(App app)
setApp
in interface OutputHandler
public final void setBase(JhoveBase je)
setBase
in interface OutputHandler
public void setEncoding(String encoding)
setEncoding
in interface OutputHandler
public final void setWriter(PrintWriter writer)
setWriter
in interface OutputHandler
public void analyze(RepInfo info)
analyze
in interface OutputHandler
info
- Object representation informationpublic void endDirectory()
endDirectory
in interface OutputHandler
public boolean okToProcess(String filepath)
okToProcess
in interface OutputHandler
filepath
- File pathnamepublic abstract void show(Module module)
show
in interface OutputHandler
public abstract void show(RepInfo info)
show
in interface OutputHandler
public abstract void show(OutputHandler handler)
show
in interface OutputHandler
public abstract void show()
show
in interface OutputHandler
public abstract void show(App app)
show
in interface OutputHandler
public abstract void showHeader()
showHeader
in interface OutputHandler
public abstract void showFooter()
showFooter
in interface OutputHandler
public void close()
close
in interface OutputHandler
public void startDirectory(String directory)
startDirectory
in interface OutputHandler
directory
- Directory pathprotected static String doctype(String root, String uri)
root
- Root element of the DTDuri
- URI of the DTDprotected static String doctype(String root, String name, String uri)
root
- Root element of the DTDname
- Public name of the DTDuri
- URI of the DTDprotected static String element(String tag)
tag
- XML tagprotected static String element(String tag, String content)
tag
- An XML tagcontent
- Content string. Characters requiring
conversion to entitites will be converted.protected static String element(String tag, String[][] attrs)
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.protected static String element(String tag, String[][] attrs, String content)
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.protected static String elementEnd(String tag)
tag
- An XML tagprotected static String elementStart(String tag)
tag
- An XML tagprotected static String elementStart(String tag, String[][] attrs)
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.protected static String xmlDecl()
protected static String xmlDecl(String encoding)
protected static String getIndent(int level)
protected static String integerArray(int[] iarray)
protected static String integerArray(int[] iarray, char separator)
protected static String longArray(long[] larray)
protected static String rationalArray(Rational[] rarray)
protected static String rationalArray10(Rational[] rarray)
protected static String doubleArray(double[] darray)
Copyright © 2008–2017 The Open Preservation Foundation. All rights reserved.