From 3be1057064c83bbebb9e1394f754b6bc21cd3d3e Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Sun, 14 Oct 2012 04:31:39 +0000 Subject: [PATCH] Change the type of printer API to accept Object instead of String. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398005 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/csv/CSVPrinter.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVPrinter.java b/src/main/java/org/apache/commons/csv/CSVPrinter.java index 17413715..b51c2470 100644 --- a/src/main/java/org/apache/commons/csv/CSVPrinter.java +++ b/src/main/java/org/apache/commons/csv/CSVPrinter.java @@ -87,8 +87,8 @@ public class CSVPrinter { * @param values * values to be outputted. */ - public void println(final String... values) throws IOException { - for (final String value : values) { + public void println(final Object... values) throws IOException { + for (final Object value : values) { print(value); } println(); @@ -280,15 +280,12 @@ public class CSVPrinter { * Prints the string as the next value on the line. The value will be escaped or encapsulated as needed if * checkForEscape==true * - * @param value + * @param object * value to output. */ - public void print(String value, final boolean checkForEscape) throws IOException { - if (value == null) { - // null values are considered empty - value = EMPTY; - } - + public void print(Object object, final boolean checkForEscape) throws IOException { + // null values are considered empty + final String value = object == null ? EMPTY : object.toString(); if (!checkForEscape) { // write directly from string printDelimiter(); @@ -302,9 +299,9 @@ public class CSVPrinter { * Prints the string as the next value on the line. The value will be escaped or encapsulated as needed. * * @param value - * value to be outputted. + * value to be output. */ - public void print(final String value) throws IOException { + public void print(final Object value) throws IOException { print(value, true); } }