From f074aeedfe62c388b57c0e8f490897d444d59b30 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Sat, 13 Oct 2012 19:05:08 +0000 Subject: [PATCH] Delimiter is not optional so change back type from Character to char. The side effect is that the "pristine" format must be built with somekind of default (',') seems reasonable. The comment used to say "no settings defined" but that was not true, since false was passed in for two values instead of null. IMO, this is all due to the fluent API making this part of the code a little more tricky. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1397927 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/commons/csv/CSVFormat.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java index 44d0f00d..29f9e621 100644 --- a/src/main/java/org/apache/commons/csv/CSVFormat.java +++ b/src/main/java/org/apache/commons/csv/CSVFormat.java @@ -39,7 +39,7 @@ public class CSVFormat implements Serializable { private static final long serialVersionUID = 1L; - private final Character delimiter; + private final char delimiter; private final Character encapsulator; private final Character commentStart; private final Character escape; @@ -49,9 +49,9 @@ public class CSVFormat implements Serializable { private final String[] header; /** - * Starting format with no settings defined; used for creating other formats from scratch. + * Starting format; used for creating other formats. */ - static final CSVFormat PRISTINE = new CSVFormat(null, null, null, null, false, false, null, null); + static final CSVFormat PRISTINE = new CSVFormat(COMMA, null, null, null, false, false, null, null); /** * Standard comma separated format, as for {@link #RFC4180} but allowing blank lines. @@ -143,7 +143,7 @@ public class CSVFormat implements Serializable { * @param header * the header */ - public CSVFormat(final Character delimiter, final Character encapsulator, final Character commentStart, final Character escape, final + public CSVFormat(final char delimiter, final Character encapsulator, final Character commentStart, final Character escape, final boolean ignoreSurroundingSpaces, final boolean ignoreEmptyLines, final String lineSeparator, final String[] header) { this.delimiter = delimiter; this.encapsulator = encapsulator; @@ -173,10 +173,6 @@ public class CSVFormat implements Serializable { * @throws IllegalStateException */ void validate() throws IllegalStateException { - if (delimiter == null) { - throw new IllegalStateException("The delimiter character cannot be null"); - } - if (delimiter == encapsulator) { throw new IllegalStateException("The encapsulator character and the delimiter cannot be the same ('" + encapsulator + "')"); }