Public Member Functions | |
CSVConverter (String cols) | |
CSVConverter () | |
CSVConverter (String cols, char separator, boolean doubleQuotes) | |
void | setSeparator (char sep) |
void | encloseByDoubleQuotes (boolean enclose) |
String | getHeader () |
String | convert (ILogEntry log) |
Objects of this class produce a CSV string from a given log. The CSV adhere to the definition in RFC4180.
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.
alma.acs.logging.tools.CSVConverter.CSVConverter | ( | String | cols | ) |
Constructor
cols | A string describing the field of the log and their position in the output |
alma.acs.logging.tools.CSVConverter.CSVConverter | ( | ) |
Constructor.
The converted string contains all the fields just once and the additional data.
alma.acs.logging.tools.CSVConverter.CSVConverter | ( | String | cols, | |
char | separator, | |||
boolean | doubleQuotes | |||
) |
Constructor
cols | A string describing the field of the log and their position in the output | |
separator | A character to use as fields separator | |
doubleQuotes | If true the fields are enclosed by double quotes |
String alma.acs.logging.tools.CSVConverter.convert | ( | ILogEntry | log | ) | [virtual] |
Convert a log in a CSV string
log | The log to convert |
Implements alma.acs.logging.tools.LogConverter.
Reimplemented in alma.acs.logging.tools.TwikiTableConverter.
References alma.acs.logging.tools.LogConverter.colIndex, com.cosylab.logging.engine.log.ILogEntry.getAdditionalData(), com.cosylab.logging.engine.log.ILogEntry.getField(), and com.cosylab.logging.engine.log.ILogEntry.hasDatas().
void alma.acs.logging.tools.CSVConverter.encloseByDoubleQuotes | ( | boolean | enclose | ) |
Put or remove the double quotes around the fields
enclose | If true the fields are enclosed by double quotes |
String alma.acs.logging.tools.CSVConverter.getHeader | ( | ) | [virtual] |
Generate the header for the CSV file (it is optional and can appear in the first line of the file)
Implements alma.acs.logging.tools.LogConverter.
Reimplemented in alma.acs.logging.tools.TwikiTableConverter.
References alma.acs.logging.tools.LogConverter.colIndex.
void alma.acs.logging.tools.CSVConverter.setSeparator | ( | char | sep | ) |
Set the separator
sep | The new separator char |