Package org.opensextant.output
Class CSVFormatter
- java.lang.Object
-
- org.opensextant.output.AbstractFormatter
-
- org.opensextant.output.CSVFormatter
-
- All Implemented Interfaces:
MatchInterpreter
,ResultsFormatter
public class CSVFormatter extends AbstractFormatter
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.List<java.lang.String>
fieldOrder
-
Fields inherited from class org.opensextant.output.AbstractFormatter
debug, geoInterpreter, includeCoordinate, includeOffsets, log, outputExtension, outputParams, outputType, overwrite, TEXT_WIDTH
-
-
Constructor Summary
Constructors Constructor Description CSVFormatter()
-
Method Summary
Modifier and Type Method Description protected void
addColumn(java.util.Map<java.lang.String,java.lang.String> row, java.lang.String f, int d)
protected void
addColumn(java.util.Map<java.lang.String,java.lang.String> row, java.lang.String f, java.lang.String d)
Add a column of data to output; Field is validated ; value is not added if nullvoid
addField(java.lang.String f)
void
buildRow(java.util.Map<java.lang.String,java.lang.String> row, TextMatch m)
Pull in data from match into the output schema (map)protected void
buildSchema()
Create a schema instance with the fields properly typed and orderedprotected boolean
canAdd(java.lang.String f)
void
close()
protected void
createOutputStreams()
Create the output stream appropriate for the output type.protected void
defaultFields()
Default fields for generic CSV output.void
finish()
void
removeField(java.lang.String f)
void
start(java.lang.String nm)
void
writeGeocodingResult(ExtractionResult rowdata)
Write your geocoding result directly to output Result should carry ExtractionResult.recordFile as a URI for original.-
Methods inherited from class org.opensextant.output.AbstractFormatter
checkOverwrite, createOutputFileName, deleteOutput, formatResults, getGeocoding, getJobName, getOutputFilepath, getOutputType, setMatchInterpeter, setOutputDir, setOutputFilename, setParameters
-
-
-
-
Method Detail
-
addField
public void addField(java.lang.String f) throws ConfigException
- Parameters:
f
- field- Throws:
ConfigException
- if not consistent with schema
-
removeField
public void removeField(java.lang.String f) throws ConfigException
- Parameters:
f
- field- Throws:
ConfigException
- if not consistent with schema
-
start
public void start(java.lang.String nm) throws ProcessingException
- Specified by:
start
in interfaceResultsFormatter
- Specified by:
start
in classAbstractFormatter
- Throws:
ProcessingException
-
finish
public void finish()
- Specified by:
finish
in interfaceResultsFormatter
- Specified by:
finish
in classAbstractFormatter
-
createOutputStreams
protected void createOutputStreams() throws java.lang.Exception
Description copied from class:AbstractFormatter
Create the output stream appropriate for the output type. IO is created using the filename represented by getOutputFilepath()- Specified by:
createOutputStreams
in classAbstractFormatter
- Throws:
java.lang.Exception
-
close
public void close() throws java.io.IOException
- Specified by:
close
in classAbstractFormatter
- Throws:
java.io.IOException
-
writeGeocodingResult
public void writeGeocodingResult(ExtractionResult rowdata)
Description copied from class:AbstractFormatter
Write your geocoding result directly to output Result should carry ExtractionResult.recordFile as a URI for original.- Specified by:
writeGeocodingResult
in classAbstractFormatter
- Parameters:
rowdata
- the data to write out
-
buildRow
public void buildRow(java.util.Map<java.lang.String,java.lang.String> row, TextMatch m)
Pull in data from match into the output schema (map)- Parameters:
row
- input row to writem
- given match has more metadata
-
buildSchema
protected void buildSchema() throws ConfigException
Create a schema instance with the fields properly typed and ordered- Throws:
ConfigException
- schema configuration error
-
canAdd
protected boolean canAdd(java.lang.String f)
-
addColumn
protected void addColumn(java.util.Map<java.lang.String,java.lang.String> row, java.lang.String f, java.lang.String d)
Add a column of data to output; Field is validated ; value is not added if null
-
addColumn
protected void addColumn(java.util.Map<java.lang.String,java.lang.String> row, java.lang.String f, int d)
-
defaultFields
protected final void defaultFields()
Default fields for generic CSV output. If GIS output is desired, then use GeoCSV formatter.
-
-