Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

alma::acs::logging::tools::CSVConverter Class Reference

List of all members.

Public Member Functions

 CSVConverter (String cols)
 CSVConverter (String cols, char separator, boolean doubleQuotes)
void setCols (String cols)
void setSeparator (char sep)
void encloseByDoubleQuotes (boolean enclose)
String getHeader ()
String convert (ILogEntry log)

Private Member Functions

void appendField (String fld, StringBuilder str)
String formatData (Vector< ILogEntry.AdditionalData > datas)

Private Attributes

String colIndex = "01234567890abcdefg"
char separator = ','
boolean useDoubleQuotes = true

Detailed Description

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 column of the log to export and their position in the 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 possible to define a different separator instead of a come, like for example the TAB.

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.

Author:
acaproni


Constructor & Destructor Documentation

alma::acs::logging::tools::CSVConverter::CSVConverter String  cols  )  [inline]
 

Constructor

Parameters:
cols A string describing the field of the log and their position in the output

alma::acs::logging::tools::CSVConverter::CSVConverter String  cols,
char  separator,
boolean  doubleQuotes
[inline]
 

Constructor

Parameters:
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


Member Function Documentation

void alma::acs::logging::tools::CSVConverter::appendField String  fld,
StringBuilder  str
[inline, private]
 

Append a field to the string (str) The field is into double quotes. If double quotes exist into the string, they are escaped.

Parameters:
fld The field to append
str The string builder where the field is appended

String alma::acs::logging::tools::CSVConverter::convert ILogEntry  log  )  [inline]
 

Convert a log in a CSV string

Parameters:
log The log to convert
Returns:
The CSV string representing the log

void alma::acs::logging::tools::CSVConverter::encloseByDoubleQuotes boolean  enclose  )  [inline]
 

Put or remove the double quotes around the fields

Parameters:
enclose If true the fields are enclosed by double quotes

String alma::acs::logging::tools::CSVConverter::formatData Vector< ILogEntry.AdditionalData >  datas  )  [inline, private]
 

Format the additional data in a string to be appended in the CSV. The produced string is not converted in CSV but contains all the entries of the additional data

The format is the following: [name1 ==> val1] [name2 ==> val2] ....

Parameters:
datas The additional data of a log
Returns:
A string with the additional data

String alma::acs::logging::tools::CSVConverter::getHeader  )  [inline]
 

Generate the header for the CSV file (it is optional and can appear in the first line of the file)

Returns:
The CSV string representing the header in CSV format with CR/LF at the end of the line

void alma::acs::logging::tools::CSVConverter::setCols String  cols  )  [inline]
 

Set the fields of the log and their position in the output

Parameters:
cols 

void alma::acs::logging::tools::CSVConverter::setSeparator char  sep  )  [inline]
 

Set the separator

Parameters:
sep The new separator char


Member Data Documentation

String alma::acs::logging::tools::CSVConverter::colIndex = "01234567890abcdefg" [private]
 

char alma::acs::logging::tools::CSVConverter::separator = ',' [private]
 

boolean alma::acs::logging::tools::CSVConverter::useDoubleQuotes = true [private]
 


The documentation for this class was generated from the following file:
Generated on Thu Apr 30 02:53:59 2009 for ACS Java API by doxygen 1.3.8