On 21 March 2012 18:34, Benedikt Ritter <benerit...@googlemail.com> wrote:
> What about the Builder pattern we discussed lately? Several people
> have expressed their feels for that solution.

We don't have consensus on that yet.

But it would be very easy to convert those definitions to use the
builder pattern.

> Am 21. März 2012 19:20 schrieb  <s...@apache.org>:
>> Author: sebb
>> Date: Wed Mar 21 18:20:05 2012
>> New Revision: 1303488
>>
>> URL: http://svn.apache.org/viewvc?rev=1303488&view=rev
>> Log:
>> CSV-74 - CSVFormat definitions are difficult to read and maintain
>>
>> Modified:
>>    
>> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
>>
>> Modified: 
>> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
>> URL: 
>> http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1303488&r1=1303487&r2=1303488&view=diff
>> ==============================================================================
>> --- 
>> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java 
>> (original)
>> +++ 
>> commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java 
>> Wed Mar 21 18:20:05 2012
>> @@ -51,8 +51,23 @@ public class CSVFormat implements Serial
>>      */
>>     static final char DISABLED = '\ufffe';
>>
>> +    /**
>> +     * Starting format with no settings defined; used for creating other 
>> formats from scratch.
>> +     */
>> +    private static CSVFormat PRISTINE =
>> +            new CSVFormat(DISABLED, DISABLED, DISABLED, DISABLED, false, 
>> false, false, null, null);
>> +
>>     /** Standard comma separated format as defined by <a 
>> href="http://tools.ietf.org/html/rfc4180";>RFC 4180</a>. */
>> -    public static final CSVFormat DEFAULT = new CSVFormat(',', '"', 
>> DISABLED, DISABLED, true, true, true, CRLF, null);
>> +    public static final CSVFormat DEFAULT =
>> +            PRISTINE.
>> +            withDelimiter(',')
>> +            .withEncapsulator('"')
>> +            .withLeadingSpacesIgnored(true)
>> +            .withTrailingSpacesIgnored(true)
>> +            .withEmptyLinesIgnored(true)
>> +            .withLineSeparator(CRLF)
>> +            ;
>> +
>>
>>     /**
>>      * Excel file format (using a comma as the value delimiter).
>> @@ -65,10 +80,23 @@ public class CSVFormat implements Serial
>>      *
>>      * <pre>CSVFormat fmt = CSVFormat.EXCEL.withDelimiter(';');</pre>
>>      */
>> -    public static final CSVFormat EXCEL = new CSVFormat(',', '"', DISABLED, 
>> DISABLED, false, false, false, CRLF, null);
>> +    public static final CSVFormat EXCEL =
>> +            PRISTINE
>> +            .withDelimiter(',')
>> +            .withEncapsulator('"')
>> +            .withLineSeparator(CRLF)
>> +            ;
>>
>>     /** Tab-delimited format, with quote; leading and trailing spaces 
>> ignored. */
>> -    public static final CSVFormat TDF = new CSVFormat('\t', '"', DISABLED, 
>> DISABLED, true, true, true, CRLF, null);
>> +    public static final CSVFormat TDF =
>> +            PRISTINE
>> +            .withDelimiter('\t')
>> +            .withEncapsulator('"')
>> +            .withLeadingSpacesIgnored(true)
>> +            .withTrailingSpacesIgnored(true)
>> +            .withEmptyLinesIgnored(true)
>> +            .withLineSeparator(CRLF)
>> +            ;
>>
>>     /**
>>      * Default MySQL format used by the <tt>SELECT INTO OUTFILE</tt> and
>> @@ -78,7 +106,12 @@ public class CSVFormat implements Serial
>>      *
>>      * @see <a 
>> href="http://dev.mysql.com/doc/refman/5.1/en/load-data.html";>http://dev.mysql.com/doc/refman/5.1/en/load-data.html</a>
>>      */
>> -    public static final CSVFormat MYSQL = new CSVFormat('\t', DISABLED, 
>> DISABLED, '\\', false, false, false, "\n", null);
>> +    public static final CSVFormat MYSQL =
>> +            PRISTINE
>> +            .withDelimiter('\t')
>> +            .withEscape('\\')
>> +            .withLineSeparator("\n")
>> +            ;
>>
>>
>>     /**
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
> For additional commands, e-mail: dev-h...@commons.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to