public class CSVConverter extends LogConverter
It is possible to select the columns of the log to export and their positions by setting a string.
A method generate the header in CSV format
All the fields appear inside double quotes. If a field contains double quotes they are escaped by double quotes. It is also possible not to enclose the fields by double quotes but in that case the content of the field is changed because some character are not allowed.
It is possible to define a different separator instead of a comma, like for example the TAB.
ADDITIONAL_DATA_ID, colIndex| Constructor and Description |
|---|
CSVConverter()
Constructor.
|
CSVConverter(java.lang.String cols)
Constructor
|
CSVConverter(java.lang.String cols,
char separator,
boolean doubleQuotes)
Constructor
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
convert(ILogEntry log)
Convert a log in a CSV string
|
void |
encloseByDoubleQuotes(boolean enclose)
Put or remove the double quotes around the fields
|
java.lang.String |
getHeader()
Generate the header for the CSV file
(it is optional and can appear in the first line of the file)
|
void |
setSeparator(char sep)
Set the separator
|
setCols, setColspublic CSVConverter(java.lang.String cols)
cols - A string describing the field of the log and their
position in the outputpublic CSVConverter()
The converted string contains all the fields just once and the additional data.
public CSVConverter(java.lang.String cols,
char separator,
boolean doubleQuotes)
cols - A string describing the field of the log and their
position in the outputseparator - A character to use as fields separatordoubleQuotes - If true the fields are enclosed by double quotespublic void setSeparator(char sep)
sep - The new separator charpublic void encloseByDoubleQuotes(boolean enclose)
enclose - If true the fields are enclosed by double quotespublic java.lang.String getHeader()
getHeader in class LogConverterpublic java.lang.String convert(ILogEntry log)
convert in class LogConverterlog - The log to convert