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
FieldsModifier and TypeFieldDescriptionbooleanThe field_order.Distinct set of fields in your output schema.protected final org.slf4j.LoggerFile extension for callers to know.protected ParametersThe output params.protected Stringreflected by extension; an enum in OpenSextantbooleanThe overwrite.protected static intSize of text window around matches -- to use as excerpts -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the field.protected voidcheckOverwrite(File item) uniform helper for overwrite check.protected abstract voidClose output streams.protected StringCreates the output file name.protected abstract voidCreate the output stream appropriate for the output type.protected final voidDefault fields for generic CSV output.protected voiddeleteOutput(File prevOutput) This is checked only by internal classes as they create output streams.abstract voidfinish()Finish.A basic job name that reflects file name.Gets the output filepath.Gets the output type.voidRemoves the field.voidsetOutputDir(String path) Sets the output dir.voidsetOutputFilename(String fname) Sets the output filename.voidsetParameters(Parameters params) Sets the parameters.abstract voidStart.abstract voidWrite the data to the output stream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:
setParametersin interfaceResultsFormatter- Parameters:
params- job parameters
-
addField
Adds the field.- Specified by:
addFieldin interfaceResultsFormatter- Parameters:
f- field name- Throws:
ConfigException
-
removeField
Removes the field.- Specified by:
removeFieldin 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:
getJobNamein interfaceResultsFormatter- Returns:
- the job name
-
setOutputFilename
Sets the output filename.- Specified by:
setOutputFilenamein interfaceResultsFormatter- Parameters:
fname- the new output filename
-
setOutputDir
Sets the output dir.- Specified by:
setOutputDirin interfaceResultsFormatter- Parameters:
path- the new output dir
-
getOutputFilepath
Gets the output filepath.- Specified by:
getOutputFilepathin interfaceResultsFormatter- Returns:
- the output filepath
-
createOutputFileName
Creates the output file name.- Returns:
- the string
-
getOutputType
Gets the output type.- Specified by:
getOutputTypein 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:
startin 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:
finishin 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
-