Package org.opensextant.output
Class AbstractGenericFormatter
java.lang.Object
org.opensextant.output.AbstractGenericFormatter
- All Implemented Interfaces:
ResultsFormatter
- Direct Known Subclasses:
CSVGenericFormatter
Abstract class encapsulating basic results formatter functionality without
prescribing schema
- Author:
- Marc Ubaldino, MITRE Corp.
-
Field Summary
Modifier and TypeFieldDescriptionboolean
The field_order.Distinct set of fields in your output schema.protected final org.slf4j.Logger
File extension for callers to know.protected Parameters
The output params.protected String
reflected by extension; an enum in OpenSextantboolean
The overwrite.protected static int
Size of text window around matches -- to use as excerpts -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the field.protected void
checkOverwrite
(File item) uniform helper for overwrite check.protected abstract void
Close output streams.protected String
Creates the output file name.protected abstract void
Create the output stream appropriate for the output type.protected final void
Default fields for generic CSV output.protected void
deleteOutput
(File prevOutput) This is checked only by internal classes as they create output streams.abstract void
finish()
Finish.A basic job name that reflects file name.Gets the output filepath.Gets the output type.void
Removes the field.void
setOutputDir
(String path) Sets the output dir.void
setOutputFilename
(String fname) Sets the output filename.void
setParameters
(Parameters params) Sets the parameters.abstract void
Start.abstract void
Write the data to the output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.opensextant.output.ResultsFormatter
formatResults
-
Field Details
-
outputParams
The output params. -
overwrite
public boolean overwriteThe overwrite. -
log
protected final org.slf4j.Logger log -
outputExtension
File extension for callers to know. -
outputType
reflected by extension; an enum in OpenSextant -
TEXT_WIDTH
protected static int TEXT_WIDTHSize of text window around matches -- to use as excerpts -
debug
public boolean debug -
fieldSet
Distinct set of fields in your output schema. -
fieldOrder
The field_order.
-
-
Constructor Details
-
AbstractGenericFormatter
public AbstractGenericFormatter()
-
-
Method Details
-
setParameters
Sets the parameters.- Specified by:
setParameters
in interfaceResultsFormatter
- Parameters:
params
- job parameters
-
addField
Adds the field.- Specified by:
addField
in interfaceResultsFormatter
- Parameters:
f
- field name- Throws:
ConfigException
-
removeField
Removes the field.- Specified by:
removeField
in interfaceResultsFormatter
- Parameters:
f
- field name- Throws:
ConfigException
-
defaultFields
protected final void defaultFields()Default fields for generic CSV output. If GIS output is desired, then use GeoCSV formatter. -
getJobName
A basic job name that reflects file name.- Specified by:
getJobName
in interfaceResultsFormatter
- Returns:
- the job name
-
setOutputFilename
Sets the output filename.- Specified by:
setOutputFilename
in interfaceResultsFormatter
- Parameters:
fname
- the new output filename
-
setOutputDir
Sets the output dir.- Specified by:
setOutputDir
in interfaceResultsFormatter
- Parameters:
path
- the new output dir
-
getOutputFilepath
Gets the output filepath.- Specified by:
getOutputFilepath
in interfaceResultsFormatter
- Returns:
- the output filepath
-
createOutputFileName
Creates the output file name.- Returns:
- the string
-
getOutputType
Gets the output type.- Specified by:
getOutputType
in interfaceResultsFormatter
- Returns:
- the output type
-
deleteOutput
This is checked only by internal classes as they create output streams.- Parameters:
prevOutput
- file path of previous output
-
checkOverwrite
uniform helper for overwrite check.- Parameters:
item
- target output file- Throws:
ProcessingException
- if unable to overwrite file
-
start
Start.- Specified by:
start
in interfaceResultsFormatter
- Parameters:
nm
- output file name/worksheet name- Throws:
ProcessingException
-
writeRow
Write the data to the output stream.- Parameters:
values
- Map of data
-
finish
public abstract void finish()Finish.- Specified by:
finish
in interfaceResultsFormatter
-
createOutputStreams
Create the output stream appropriate for the output type. IO is created using the filename represented by getOutputFilepath()- Throws:
Exception
- when unable to create output stream
-
closeOutputStreams
Close output streams.- Throws:
Exception
-