Package org.opensextant.output
Class CSVGenericFormatter
- java.lang.Object
-
- org.opensextant.output.AbstractGenericFormatter
-
- org.opensextant.output.CSVGenericFormatter
-
- All Implemented Interfaces:
ResultsFormatter
public class CSVGenericFormatter extends AbstractGenericFormatter
Alternative to CSVFormatter which is schema-specific and a bit rigid. ResultsFormatter interface assumes an "extraction result"- Author:
- ubaldino
-
-
Field Summary
-
Fields inherited from class org.opensextant.output.AbstractGenericFormatter
debug, fieldOrder, fieldSet, log, outputExtension, outputParams, outputType, overwrite, TEXT_WIDTH
-
-
Constructor Summary
Constructors Constructor Description CSVGenericFormatter(Parameters p)
-
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 nullprotected void
buildSchema()
Create a schema instance with the fields properly typed and orderedprotected boolean
canAdd(java.lang.String f)
protected void
closeOutputStreams()
Close output streams.protected void
createOutputStreams()
Create the output stream appropriate for the output type.void
finish()
Finish.java.lang.String
formatResults(ExtractionResult result)
Not implemented: this formatter is more flexible than requiring you to use it for Extraction outputvoid
setDelimiter(java.lang.String ch)
void
start(java.lang.String nm)
Start.void
writeRow(java.util.Map<java.lang.String,java.lang.Object> values)
Write the data to the output stream.-
Methods inherited from class org.opensextant.output.AbstractGenericFormatter
addField, checkOverwrite, createOutputFileName, defaultFields, deleteOutput, getJobName, getOutputFilepath, getOutputType, removeField, setOutputDir, setOutputFilename, setParameters
-
-
-
-
Constructor Detail
-
CSVGenericFormatter
public CSVGenericFormatter(Parameters p)
-
-
Method Detail
-
setDelimiter
public void setDelimiter(java.lang.String ch)
-
start
public void start(java.lang.String nm) throws ProcessingException
Description copied from class:AbstractGenericFormatter
Start.- Specified by:
start
in interfaceResultsFormatter
- Specified by:
start
in classAbstractGenericFormatter
- Parameters:
nm
- output file name/worksheet name- Throws:
ProcessingException
-
finish
public void finish()
Description copied from class:AbstractGenericFormatter
Finish.- Specified by:
finish
in interfaceResultsFormatter
- Specified by:
finish
in classAbstractGenericFormatter
-
createOutputStreams
protected void createOutputStreams() throws java.lang.Exception
Description copied from class:AbstractGenericFormatter
Create the output stream appropriate for the output type. IO is created using the filename represented by getOutputFilepath()- Specified by:
createOutputStreams
in classAbstractGenericFormatter
- Throws:
java.lang.Exception
- when unable to create output stream
-
closeOutputStreams
protected void closeOutputStreams() throws java.lang.Exception
Description copied from class:AbstractGenericFormatter
Close output streams.- Specified by:
closeOutputStreams
in classAbstractGenericFormatter
- Throws:
java.lang.Exception
-
writeRow
public void writeRow(java.util.Map<java.lang.String,java.lang.Object> values)
Write the data to the output stream.- Specified by:
writeRow
in classAbstractGenericFormatter
- Parameters:
values
- Map of data
-
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)
-
formatResults
public java.lang.String formatResults(ExtractionResult result) throws ProcessingException
Not implemented: this formatter is more flexible than requiring you to use it for Extraction output- Returns:
- A message for the user
- Throws:
ProcessingException
- formatting error
-
-