Package org.opensextant.output
Class AbstractFormatter
java.lang.Object
org.opensextant.output.AbstractFormatter
- All Implemented Interfaces:
MatchInterpreter,ResultsFormatter
- Direct Known Subclasses:
CSVFormatter,GISDataFormatter
public abstract class AbstractFormatter
extends Object
implements ResultsFormatter, MatchInterpreter
Abstract class encapsulating basic results formatter functionality.
- Author:
- Rich Markeloff, MITRE Corp. Initial version created on Aug 22, 2011, Marc Ubaldino, MITRE Corp. Refactored, 2013
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanprotected MatchInterpreterbooleanGIS formats may optionally include coordinates as fields.booleanSchema-specific stuff.protected final org.slf4j.LoggerFile extension for callers to know.protected Parametersprotected Stringbooleanprotected static int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcheckOverwrite(File item) uniform helper for overwrite check.abstract voidclose()protected Stringprotected abstract voidCreate the output stream appropriate for the output type.protected voiddeleteOutput(File previousRun) This is checked only by internal classes as they create output streams.abstract voidfinish()Write to a file and return HTML containing a link to the file.The default geocoding interpretation is here.A basic job name that reflects file nameGet the path to the output file.Get the type of output produced by this formatter.voidOverride means for how geocoding is determined per row.voidsetOutputDir(String path) Set the path to the output directory.voidsetOutputFilename(String fname) Set the name of the output file.voidsetParameters(Parameters params) Note - output parameters use tag_XYZ flags to indicate date to include or excludeabstract voidabstract voidwriteGeocodingResult(ExtractionResult rowdata) Write your geocoding result directly to output Result should carry ExtractionResult.recordFile as a URI for original.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
addField, removeField
-
Field Details
-
outputParams
-
overwrite
public boolean overwrite -
geoInterpreter
-
log
protected final org.slf4j.Logger log -
outputExtension
File extension for callers to know. -
outputType
-
TEXT_WIDTH
protected static int TEXT_WIDTH -
debug
public boolean debug -
includeOffsets
public boolean includeOffsetsSchema-specific stuff. GIS formats would not make use of offsets. CSV format is only one where offsets make sense. -
includeCoordinate
public boolean includeCoordinateGIS formats may optionally include coordinates as fields. GDB and SHP have a Point geometry which carries the lat/lon already. KML, CSV, JSON, etc. it makes sense to include these explicitly.
-
-
Constructor Details
-
AbstractFormatter
public AbstractFormatter()
-
-
Method Details
-
setParameters
Note - output parameters use tag_XYZ flags to indicate date to include or exclude- Specified by:
setParametersin interfaceResultsFormatter
-
setMatchInterpeter
Override means for how geocoding is determined per row. -
getGeocoding
The default geocoding interpretation is here. This works for simple stuff like Coordinate extraction- Specified by:
getGeocodingin interfaceMatchInterpreter- Parameters:
m- TextMatch -- which may or may not be geographic in nature.- Returns:
-
getJobName
A basic job name that reflects file name- Specified by:
getJobNamein interfaceResultsFormatter- Returns:
-
setOutputFilename
Description copied from interface:ResultsFormatterSet the name of the output file.- Specified by:
setOutputFilenamein interfaceResultsFormatter- Parameters:
fname- file name of output
-
setOutputDir
Description copied from interface:ResultsFormatterSet the path to the output directory.- Specified by:
setOutputDirin interfaceResultsFormatter- Parameters:
path- output dir path
-
formatResults
Write to a file and return HTML containing a link to the file.- Specified by:
formatResultsin interfaceResultsFormatter- Parameters:
res- result to write- Returns:
- A message for the user
- Throws:
ProcessingException- processing or formatting error
-
getOutputFilepath
Description copied from interface:ResultsFormatterGet the path to the output file.- Specified by:
getOutputFilepathin interfaceResultsFormatter- Returns:
- file path of output
-
createOutputFileName
- Returns:
- file name with extension
-
getOutputType
Description copied from interface:ResultsFormatterGet the type of output produced by this formatter.- Specified by:
getOutputTypein interfaceResultsFormatter- Returns:
- type of output
-
deleteOutput
This is checked only by internal classes as they create output streams. -
checkOverwrite
uniform helper for overwrite check.- Throws:
IOException
-
start
- Specified by:
startin interfaceResultsFormatter- Throws:
ProcessingException
-
finish
public abstract void 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
-
close
- Throws:
IOException
-
writeGeocodingResult
Write your geocoding result directly to output Result should carry ExtractionResult.recordFile as a URI for original.- Parameters:
rowdata- the data to write out
-