All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.doolin.tabular.csv.StringCSVAdapter Maven / Gradle / Ivy

Go to download

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