Change back to DEFAULT format name.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1461192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2013-03-26 15:50:18 +00:00
parent 1e83d1fb59
commit e33bedefce
8 changed files with 37 additions and 37 deletions

View File

@ -84,7 +84,7 @@ public class CSVFormat implements Serializable {
* <li>withIgnoreEmptyLines(true)</li>
* </ul>
*/
public static final CSVFormat RFC4180_EMPTY_LINES =
public static final CSVFormat DEFAULT =
newBuilder()
.build();
@ -166,7 +166,7 @@ public class CSVFormat implements Serializable {
* <li>withLineSeparator(CRLF)</li>
* </ul>
*
* Shortcut for {@code CSVFormat.newBuilder(CSVFormat.RFC4180_EMPTY_LINES)}
* Shortcut for {@code CSVFormat.newBuilder(CSVFormat.DEFAULT)}
*
* @return a standard comma separated format builder, as for {@link #RFC4180} but allowing empty lines.
*/

View File

@ -89,7 +89,7 @@ public class CSVParser implements Iterable<CSVRecord> {
* thrown if the parameters of the format are inconsistent
*/
public CSVParser(final Reader input) throws IOException {
this(input, CSVFormat.RFC4180_EMPTY_LINES);
this(input, CSVFormat.DEFAULT);
}
/**

View File

@ -52,13 +52,13 @@ public class CSVPrinter implements Flushable, Closeable {
* @param out
* stream to which to print.
* @param format
* the CSV format. If null the default format is used ({@link CSVFormat#RFC4180_EMPTY_LINES})
* the CSV format. If null the default format is used ({@link CSVFormat#DEFAULT})
* @throws IllegalArgumentException
* thrown if the parameters of the format are inconsistent
*/
public CSVPrinter(final Appendable out, final CSVFormat format) {
this.out = out;
this.format = format == null ? CSVFormat.RFC4180_EMPTY_LINES : format;
this.format = format == null ? CSVFormat.DEFAULT : format;
}
// ======================================================

View File

@ -68,7 +68,7 @@
* <p>Example usage:</p>
* <blockquote><pre>
* Reader in = new StringReader("a,b,c");
* for (CSVRecord record : CSVFormat.RFC4180_EMPTY_LINES.parse(in)) {
* for (CSVRecord record : CSVFormat.DEFAULT.parse(in)) {
* for (String field : record) {
* System.out.print("\"" + field + "\", ");
* }

View File

@ -37,7 +37,7 @@ public class CSVFormatTest {
@Test
public void testFormat() {
final CSVFormat format = CSVFormat.RFC4180_EMPTY_LINES;
final CSVFormat format = CSVFormat.DEFAULT;
assertEquals("", format.format());
assertEquals("a,b,c", format.format("a", "b", "c"));
@ -50,7 +50,7 @@ public class CSVFormatTest {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(out);
oos.writeObject(CSVFormat.RFC4180_EMPTY_LINES);
oos.writeObject(CSVFormat.DEFAULT);
oos.flush();
oos.close();
@ -58,18 +58,18 @@ public class CSVFormatTest {
final CSVFormat format = (CSVFormat) in.readObject();
assertNotNull(format);
assertEquals("delimiter", CSVFormat.RFC4180_EMPTY_LINES.getDelimiter(), format.getDelimiter());
assertEquals("encapsulator", CSVFormat.RFC4180_EMPTY_LINES.getQuoteChar(), format.getQuoteChar());
assertEquals("comment start", CSVFormat.RFC4180_EMPTY_LINES.getCommentStart(), format.getCommentStart());
assertEquals("line separator", CSVFormat.RFC4180_EMPTY_LINES.getRecordSeparator(), format.getRecordSeparator());
assertEquals("escape", CSVFormat.RFC4180_EMPTY_LINES.getEscape(), format.getEscape());
assertEquals("trim", CSVFormat.RFC4180_EMPTY_LINES.getIgnoreSurroundingSpaces(), format.getIgnoreSurroundingSpaces());
assertEquals("empty lines", CSVFormat.RFC4180_EMPTY_LINES.getIgnoreEmptyLines(), format.getIgnoreEmptyLines());
assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), format.getDelimiter());
assertEquals("encapsulator", CSVFormat.DEFAULT.getQuoteChar(), format.getQuoteChar());
assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), format.getCommentStart());
assertEquals("line separator", CSVFormat.DEFAULT.getRecordSeparator(), format.getRecordSeparator());
assertEquals("escape", CSVFormat.DEFAULT.getEscape(), format.getEscape());
assertEquals("trim", CSVFormat.DEFAULT.getIgnoreSurroundingSpaces(), format.getIgnoreSurroundingSpaces());
assertEquals("empty lines", CSVFormat.DEFAULT.getIgnoreEmptyLines(), format.getIgnoreEmptyLines());
}
@Test
public void testEquals() {
final CSVFormat right = CSVFormat.RFC4180_EMPTY_LINES;
final CSVFormat right = CSVFormat.DEFAULT;
final CSVFormat left = CSVFormat.newBuilder().build();
assertFalse(right.equals(null));

View File

@ -178,7 +178,7 @@ public class CSVLexerTest {
* \,,
*/
final String code = "a,\\,,b\\\n\\,,";
final CSVFormat format = CSVFormat.RFC4180_EMPTY_LINES;
final CSVFormat format = CSVFormat.DEFAULT;
assertFalse(format.isEscaping());
final Lexer parser = getLexer(code, format);
@ -242,7 +242,7 @@ public class CSVLexerTest {
@Test
public void testNextToken5() throws IOException {
final String code = "a,\"foo\n\",b\n\"foo\n baar ,,,\"\n\"\n\t \n\"";
final Lexer parser = getLexer(code, CSVFormat.RFC4180_EMPTY_LINES);
final Lexer parser = getLexer(code, CSVFormat.DEFAULT);
assertTokenEquals(TOKEN, "a", parser.nextToken(new Token()));
assertTokenEquals(TOKEN, "foo\n", parser.nextToken(new Token()));
assertTokenEquals(EORECORD, "b", parser.nextToken(new Token()));

View File

@ -234,13 +234,13 @@ public class CSVParserTest {
@Test
public void testEmptyFile() throws Exception {
final CSVParser parser = new CSVParser("", CSVFormat.RFC4180_EMPTY_LINES);
final CSVParser parser = new CSVParser("", CSVFormat.DEFAULT);
assertNull(parser.nextRecord());
}
@Test
public void testCSV57() throws Exception {
final CSVParser parser = new CSVParser("", CSVFormat.RFC4180_EMPTY_LINES);
final CSVParser parser = new CSVParser("", CSVFormat.DEFAULT);
final List<CSVRecord> list = parser.getRecords();
assertNotNull(list);
assertEquals(0, list.size());
@ -366,7 +366,7 @@ public class CSVParserTest {
{"# Final comment"}
};
CSVFormat format = CSVFormat.RFC4180_EMPTY_LINES;
CSVFormat format = CSVFormat.DEFAULT;
assertFalse(format.isCommentingEnabled());
CSVParser parser = new CSVParser(code, format);
@ -427,7 +427,7 @@ public class CSVParserTest {
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");
for (final CSVRecord record : CSVFormat.RFC4180_EMPTY_LINES.parse(in)) {
for (final CSVRecord record : CSVFormat.DEFAULT.parse(in)) {
records.add(record);
}
@ -440,9 +440,9 @@ public class CSVParserTest {
@Test
public void testRoundtrip() throws Exception {
final StringWriter out = new StringWriter();
final CSVPrinter printer = new CSVPrinter(out, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(out, CSVFormat.DEFAULT);
final String input = "a,b,c\r\n1,2,3\r\nx,y,z\r\n";
for (final CSVRecord record : CSVFormat.RFC4180_EMPTY_LINES.parse(new StringReader(input))) {
for (final CSVRecord record : CSVFormat.DEFAULT.parse(new StringReader(input))) {
printer.printRecord(record);
}
assertEquals(input, out.toString());
@ -453,7 +453,7 @@ public class CSVParserTest {
public void testIterator() throws Exception {
final Reader in = new StringReader("a,b,c\n1,2,3\nx,y,z");
final Iterator<CSVRecord> iterator = CSVFormat.RFC4180_EMPTY_LINES.parse(in).iterator();
final Iterator<CSVRecord> iterator = CSVFormat.DEFAULT.parse(in).iterator();
assertTrue(iterator.hasNext());
try {

View File

@ -51,7 +51,7 @@ public class CSVPrinterTest {
return sb.toString();
}
String recordSeparator = CSVFormat.RFC4180_EMPTY_LINES.getRecordSeparator();
String recordSeparator = CSVFormat.DEFAULT.getRecordSeparator();
public void doOneRandom(final CSVFormat format) throws Exception {
final Random r = new Random();
@ -144,7 +144,7 @@ public class CSVPrinterTest {
@Test
public void testDisabledComment() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printComment("This is a comment");
assertEquals("", sw.toString());
@ -216,7 +216,7 @@ public class CSVPrinterTest {
stmt.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, NAME VARCHAR(255))");
stmt.execute("insert into TEST values(1, 'r1')");
stmt.execute("insert into TEST values(2, 'r2')");
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecords(stmt.executeQuery("select ID, NAME from TEST"));
assertEquals("1,r1" + recordSeparator + "2,r2" + recordSeparator, sw.toString());
printer.close();
@ -238,7 +238,7 @@ public class CSVPrinterTest {
@Test
public void testPrinter1() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b");
assertEquals("a,b" + recordSeparator, sw.toString());
printer.close();
@ -247,7 +247,7 @@ public class CSVPrinterTest {
@Test
public void testPrinter2() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a,b", "b");
assertEquals("\"a,b\",b" + recordSeparator, sw.toString());
printer.close();
@ -256,7 +256,7 @@ public class CSVPrinterTest {
@Test
public void testPrinter3() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a, b", "b ");
assertEquals("\"a, b\",\"b \"" + recordSeparator, sw.toString());
printer.close();
@ -265,7 +265,7 @@ public class CSVPrinterTest {
@Test
public void testPrinter4() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b\"c");
assertEquals("a,\"b\"\"c\"" + recordSeparator, sw.toString());
printer.close();
@ -274,7 +274,7 @@ public class CSVPrinterTest {
@Test
public void testPrinter5() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b\nc");
assertEquals("a,\"b\nc\"" + recordSeparator, sw.toString());
printer.close();
@ -283,7 +283,7 @@ public class CSVPrinterTest {
@Test
public void testPrinter6() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b\r\nc");
assertEquals("a,\"b\r\nc\"" + recordSeparator, sw.toString());
printer.close();
@ -292,7 +292,7 @@ public class CSVPrinterTest {
@Test
public void testPrinter7() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", "b\\c");
assertEquals("a,b\\c" + recordSeparator, sw.toString());
printer.close();
@ -301,7 +301,7 @@ public class CSVPrinterTest {
@Test
public void testPrintNullValues() throws IOException {
final StringWriter sw = new StringWriter();
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.RFC4180_EMPTY_LINES);
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT);
printer.printRecord("a", null, "b");
assertEquals("a,,b" + recordSeparator, sw.toString());
printer.close();
@ -328,7 +328,7 @@ public class CSVPrinterTest {
@Test
public void testRandom() throws Exception {
final int iter = 10000;
doRandom(CSVFormat.RFC4180_EMPTY_LINES, iter);
doRandom(CSVFormat.DEFAULT, iter);
doRandom(CSVFormat.EXCEL, iter);
doRandom(CSVFormat.MYSQL, iter);
}