net.sf.doolin.tabular.csv.StringCSVAdapter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of doolin-tabular Show documentation
Show all versions of doolin-tabular Show documentation
This Doolin GUI module is an extension that allows writing
tabular data (CSV, Excel).
The newest version!
package net.sf.doolin.tabular.csv;
import org.apache.commons.lang.ObjectUtils;
import org.apache.commons.lang.StringUtils;
/**
* Just renders the value by calling the toString()
method on it
* and escapes special characters.
*
* @author Damien Coraboeuf
*/
public class StringCSVAdapter implements CSVAdapter {
/**
* Just renders the value by calling the toString()
method on
* it and escapes special characters.
*
* @see net.sf.doolin.tabular.csv.CSVAdapter#getCSVValue(java.lang.Object)
*/
public String getCSVValue(Object value) {
String string = ObjectUtils.toString(value, "");
// Replace double quotes
string = StringUtils.replace(string, "\"", "\"\"");
// Surrounds with quotes
return "\"" + string + "\"";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy