org.javasimon.console.action.CsvStringifierFactory Maven / Gradle / Ivy
package org.javasimon.console.action;
import org.javasimon.console.text.BaseStringifier;
import org.javasimon.console.text.Stringifier;
import org.javasimon.console.text.StringifierFactory;
/**
* Value formatter for CSV response format.
*
* @author gquintana
*/
public class CsvStringifierFactory extends StringifierFactory {
@Override
protected Stringifier registerStringStringifier(Stringifier nullStringifier) {
Stringifier stringStringifier = new BaseStringifier(nullStringifier) {
@Override
protected String doToString(String s) {
return "\"" + s.replace("\"", "\"\"") + "\"";
}
};
compositeStringifier.add(String.class, stringStringifier);
return stringStringifier;
}
}