Skip to content

Commit ecea0c3

Browse files
committed
Rename "encapsulator" to "quoteChar" so we have quoteChar and quotePolicy. Encapsulator makes me want to ask "encapsulate what"? fieldEncapsulator would be better but so verbose, quoteChar feels more to the point to me and provides symmetry with quotePolicy.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398010 13f79535-47bb-0310-9956-ffa450edef68
1 parent 6e57364 commit ecea0c3

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/main/java/org/apache/commons/csv/CSVFormat.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public class CSVFormat implements Serializable {
6666
public static final CSVFormat DEFAULT =
6767
PRISTINE
6868
.withDelimiter(COMMA)
69-
.withEncapsulator(DOUBLE_QUOTE)
69+
.withQuoteChar(DOUBLE_QUOTE)
7070
.withIgnoreEmptyLines(true)
7171
.withLineSeparator(CRLF);
7272

@@ -82,7 +82,7 @@ public class CSVFormat implements Serializable {
8282
public static final CSVFormat RFC4180 =
8383
PRISTINE
8484
.withDelimiter(COMMA)
85-
.withEncapsulator(DOUBLE_QUOTE)
85+
.withQuoteChar(DOUBLE_QUOTE)
8686
.withLineSeparator(CRLF);
8787

8888
/**
@@ -98,14 +98,14 @@ public class CSVFormat implements Serializable {
9898
public static final CSVFormat EXCEL =
9999
PRISTINE
100100
.withDelimiter(COMMA)
101-
.withEncapsulator(DOUBLE_QUOTE)
101+
.withQuoteChar(DOUBLE_QUOTE)
102102
.withLineSeparator(CRLF);
103103

104104
/** Tab-delimited format, with quote; leading and trailing spaces ignored. */
105105
public static final CSVFormat TDF =
106106
PRISTINE
107107
.withDelimiter(TAB)
108-
.withEncapsulator(DOUBLE_QUOTE)
108+
.withQuoteChar(DOUBLE_QUOTE)
109109
.withIgnoreSurroundingSpaces(true)
110110
.withIgnoreEmptyLines(true)
111111
.withLineSeparator(CRLF);
@@ -258,8 +258,8 @@ public Character getQuoteChar() {
258258
* @throws IllegalArgumentException
259259
* thrown if the specified character is a line break
260260
*/
261-
public CSVFormat withEncapsulator(final char encapsulator) {
262-
return withEncapsulator(Character.valueOf(encapsulator));
261+
public CSVFormat withQuoteChar(final char quoteChar) {
262+
return withQuoteChar(Character.valueOf(quoteChar));
263263
}
264264

265265
/**
@@ -271,11 +271,11 @@ public CSVFormat withEncapsulator(final char encapsulator) {
271271
* @throws IllegalArgumentException
272272
* thrown if the specified character is a line break
273273
*/
274-
public CSVFormat withEncapsulator(final Character encapsulator) {
275-
if (isLineBreak(encapsulator)) {
274+
public CSVFormat withQuoteChar(final Character quoteChar) {
275+
if (isLineBreak(quoteChar)) {
276276
throw new IllegalArgumentException("The quoteChar cannot be a line break");
277277
}
278-
return new CSVFormat(delimiter, encapsulator, quotePolicy, commentStart, escape,
278+
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
279279
ignoreSurroundingSpaces, ignoreEmptyLines, lineSeparator, header);
280280
}
281281

src/test/java/org/apache/commons/csv/CSVFileParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void testCSVFile() throws Exception {
8888
assertTrue(testName+" require 1 param", split.length >= 1);
8989
// first line starts with csv data file name
9090
final BufferedReader csvFile = new BufferedReader(new FileReader(new File(BASE, split[0])));
91-
CSVFormat fmt = CSVFormat.PRISTINE.withDelimiter(',').withEncapsulator('"');
91+
CSVFormat fmt = CSVFormat.PRISTINE.withDelimiter(',').withQuoteChar('"');
9292
boolean checkComments = false;
9393
for(int i=1; i < split.length; i++) {
9494
final String option = split[i];

src/test/java/org/apache/commons/csv/CSVFormatTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public void testImmutalibity() {
3838
final CSVFormat format = new CSVFormat('!', '!', Quote.MINIMAL, '!', '!', true, true, CRLF, null);
3939

4040
format.withDelimiter('?');
41-
format.withEncapsulator('?');
41+
format.withQuoteChar('?');
4242
format.withCommentStart('?');
4343
format.withLineSeparator("?");
4444
format.withEscape('?');
@@ -63,7 +63,7 @@ public void testMutators() {
6363
final CSVFormat format = new CSVFormat('!', '!', null, '!', '!', true, true, CRLF, null);
6464

6565
assertEquals('?', format.withDelimiter('?').getDelimiter());
66-
assertEquals('?', format.withEncapsulator('?').getQuoteChar().charValue());
66+
assertEquals('?', format.withQuoteChar('?').getQuoteChar().charValue());
6767
assertEquals('?', format.withCommentStart('?').getCommentStart().charValue());
6868
assertEquals("?", format.withLineSeparator("?").getLineSeparator());
6969
assertEquals('?', format.withEscape('?').getEscape().charValue());
@@ -102,7 +102,7 @@ public void testValidation() {
102102
}
103103

104104
try {
105-
format.withEncapsulator('\n');
105+
format.withQuoteChar('\n');
106106
fail();
107107
} catch (final IllegalArgumentException e) {
108108
// expected
@@ -130,13 +130,13 @@ public void testValidation() {
130130
}
131131

132132
try {
133-
format.withEncapsulator('!').withCommentStart('!').validate();
133+
format.withQuoteChar('!').withCommentStart('!').validate();
134134
fail();
135135
} catch (final IllegalStateException e) {
136136
// expected
137137
}
138138

139-
format.withEncapsulator(null).withCommentStart(null).validate();
139+
format.withQuoteChar(null).withCommentStart(null).validate();
140140

141141
try {
142142
format.withEscape('!').withCommentStart('!').validate();
@@ -149,7 +149,7 @@ public void testValidation() {
149149

150150

151151
try {
152-
format.withEncapsulator('!').withDelimiter('!').validate();
152+
format.withQuoteChar('!').withDelimiter('!').validate();
153153
fail();
154154
} catch (final IllegalStateException e) {
155155
// expected

src/test/java/org/apache/commons/csv/CSVLexerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ public void testNextToken6() throws IOException {
259259
* ;;
260260
*/
261261
final String code = "a;'b and '' more\n'\n!comment;;;;\n;;";
262-
final CSVFormat format = CSVFormat.DEFAULT.withDelimiter(';').withEncapsulator('\'').withCommentStart('!');
262+
final CSVFormat format = CSVFormat.DEFAULT.withDelimiter(';').withQuoteChar('\'').withCommentStart('!');
263263
final Lexer parser = getLexer(code, format);
264264
assertTokenEquals(TOKEN, "a", parser.nextToken(new Token()));
265265
assertTokenEquals(EORECORD, "b and ' more\n", parser.nextToken(new Token()));

src/test/java/org/apache/commons/csv/CSVParserTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ public void testBackslashEscaping() throws IOException {
309309
};
310310

311311

312-
final CSVFormat format = CSVFormat.PRISTINE.withDelimiter(',').withEncapsulator('\'').withEscape('/')
312+
final CSVFormat format = CSVFormat.PRISTINE.withDelimiter(',').withQuoteChar('\'').withEscape('/')
313313
.withIgnoreEmptyLines(true).withLineSeparator(CRLF);
314314

315315
final CSVParser parser = new CSVParser(code, format);

0 commit comments

Comments
 (0)