Skip to content

Commit a72c71f

Browse files
committed
Consistently rename Quote/QuotePolicy to QuoteMode
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1612344 13f79535-47bb-0310-9956-ffa450edef68
1 parent 4695d73 commit a72c71f

5 files changed

Lines changed: 47 additions & 47 deletions

File tree

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

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public final class CSVFormat implements Serializable {
148148

149149
private final char delimiter;
150150
private final Character quoteChar; // null if quoting is disabled
151-
private final Quote quotePolicy;
151+
private final QuoteMode quoteMode;
152152
private final Character commentStart; // null if commenting is disabled
153153
private final Character escape; // null if escaping is disabled
154154
private final boolean ignoreSurroundingSpaces; // Should leading/trailing spaces be ignored around values?
@@ -313,8 +313,8 @@ public static CSVFormat newFormat(final char delimiter) {
313313
* the char used for value separation, must not be a line break character
314314
* @param quoteChar
315315
* the Character used as value encapsulation marker, may be {@code null} to disable
316-
* @param quotePolicy
317-
* the quote policy
316+
* @param quoteMode
317+
* the quote mode
318318
* @param commentStart
319319
* the Character used for comment identification, may be {@code null} to disable
320320
* @param escape
@@ -334,7 +334,7 @@ public static CSVFormat newFormat(final char delimiter) {
334334
* @throws IllegalArgumentException if the delimiter is a line break character
335335
*/
336336
private CSVFormat(final char delimiter, final Character quoteChar,
337-
final Quote quotePolicy, final Character commentStart,
337+
final QuoteMode quoteMode, final Character commentStart,
338338
final Character escape, final boolean ignoreSurroundingSpaces,
339339
final boolean ignoreEmptyLines, final String recordSeparator,
340340
final String nullString, final String[] header, final boolean skipHeaderRecord,
@@ -344,7 +344,7 @@ private CSVFormat(final char delimiter, final Character quoteChar,
344344
}
345345
this.delimiter = delimiter;
346346
this.quoteChar = quoteChar;
347-
this.quotePolicy = quotePolicy;
347+
this.quoteMode = quoteMode;
348348
this.commentStart = commentStart;
349349
this.escape = escape;
350350
this.ignoreSurroundingSpaces = ignoreSurroundingSpaces;
@@ -384,7 +384,7 @@ public boolean equals(final Object obj) {
384384
if (delimiter != other.delimiter) {
385385
return false;
386386
}
387-
if (quotePolicy != other.quotePolicy) {
387+
if (quoteMode != other.quoteMode) {
388388
return false;
389389
}
390390
if (quoteChar == null) {
@@ -552,8 +552,8 @@ public Character getQuoteChar() {
552552
*
553553
* @return the quote policy
554554
*/
555-
public Quote getQuotePolicy() {
556-
return quotePolicy;
555+
public QuoteMode getQuoteMode() {
556+
return quoteMode;
557557
}
558558

559559
/**
@@ -581,7 +581,7 @@ public int hashCode()
581581
int result = 1;
582582

583583
result = prime * result + delimiter;
584-
result = prime * result + ((quotePolicy == null) ? 0 : quotePolicy.hashCode());
584+
result = prime * result + ((quoteMode == null) ? 0 : quoteMode.hashCode());
585585
result = prime * result + ((quoteChar == null) ? 0 : quoteChar.hashCode());
586586
result = prime * result + ((commentStart == null) ? 0 : commentStart.hashCode());
587587
result = prime * result + ((escape == null) ? 0 : escape.hashCode());
@@ -735,7 +735,7 @@ private void validate() throws IllegalArgumentException {
735735
"The comment start and the escape character cannot be the same ('" + commentStart + "')");
736736
}
737737

738-
if (escape == null && quotePolicy == Quote.NONE) {
738+
if (escape == null && quoteMode == QuoteMode.NONE) {
739739
throw new IllegalArgumentException("No quotes mode set but no escape character is set");
740740
}
741741
}
@@ -770,7 +770,7 @@ public CSVFormat withCommentMarker(final Character commentMarker) {
770770
if (isLineBreak(commentMarker)) {
771771
throw new IllegalArgumentException("The comment start marker character cannot be a line break");
772772
}
773-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentMarker, escape,
773+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentMarker, escape,
774774
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
775775
allowMissingColumnNames);
776776
}
@@ -788,7 +788,7 @@ public CSVFormat withDelimiter(final char delimiter) {
788788
if (isLineBreak(delimiter)) {
789789
throw new IllegalArgumentException("The delimiter cannot be a line break");
790790
}
791-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
791+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
792792
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
793793
allowMissingColumnNames);
794794
}
@@ -819,7 +819,7 @@ public CSVFormat withEscape(final Character escape) {
819819
if (isLineBreak(escape)) {
820820
throw new IllegalArgumentException("The escape character cannot be a line break");
821821
}
822-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
822+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
823823
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
824824
allowMissingColumnNames);
825825
}
@@ -842,7 +842,7 @@ public CSVFormat withEscape(final Character escape) {
842842
* @see #withSkipHeaderRecord(boolean)
843843
*/
844844
public CSVFormat withHeader(final String... header) {
845-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
845+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
846846
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
847847
allowMissingColumnNames);
848848
}
@@ -856,7 +856,7 @@ public CSVFormat withHeader(final String... header) {
856856
* @return A new CSVFormat that is equal to this but with the specified missing column names behavior.
857857
*/
858858
public CSVFormat withAllowMissingColumnNames(final boolean allowMissingColumnNames) {
859-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
859+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
860860
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
861861
allowMissingColumnNames);
862862
}
@@ -870,7 +870,7 @@ public CSVFormat withAllowMissingColumnNames(final boolean allowMissingColumnNam
870870
* @return A new CSVFormat that is equal to this but with the specified empty line skipping behavior.
871871
*/
872872
public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
873-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
873+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
874874
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
875875
allowMissingColumnNames);
876876
}
@@ -884,7 +884,7 @@ public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
884884
* @return A new CSVFormat that is equal to this but with the specified trimming behavior.
885885
*/
886886
public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpaces) {
887-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
887+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
888888
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
889889
allowMissingColumnNames);
890890
}
@@ -905,7 +905,7 @@ public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpac
905905
* @return A new CSVFormat that is equal to this but with the specified null conversion string.
906906
*/
907907
public CSVFormat withNullString(final String nullString) {
908-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
908+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
909909
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
910910
allowMissingColumnNames);
911911
}
@@ -936,21 +936,21 @@ public CSVFormat withQuoteChar(final Character quoteChar) {
936936
if (isLineBreak(quoteChar)) {
937937
throw new IllegalArgumentException("The quoteChar cannot be a line break");
938938
}
939-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
939+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
940940
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
941941
allowMissingColumnNames);
942942
}
943943

944944
/**
945945
* Sets the output quote policy of the format to the specified value.
946946
*
947-
* @param quotePolicy
947+
* @param quoteModePolicy
948948
* the quote policy to use for output.
949949
*
950950
* @return A new CSVFormat that is equal to this but with the specified quote policy
951951
*/
952-
public CSVFormat withQuotePolicy(final Quote quotePolicy) {
953-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
952+
public CSVFormat withQuoteMode(final QuoteMode quoteModePolicy) {
953+
return new CSVFormat(delimiter, quoteChar, quoteModePolicy, commentStart, escape,
954954
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
955955
allowMissingColumnNames);
956956
}
@@ -984,7 +984,7 @@ public CSVFormat withRecordSeparator(final char recordSeparator) {
984984
* if recordSeparator is none of CR, LF or CRLF
985985
*/
986986
public CSVFormat withRecordSeparator(final String recordSeparator) {
987-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
987+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
988988
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
989989
allowMissingColumnNames);
990990
}
@@ -999,7 +999,7 @@ public CSVFormat withRecordSeparator(final String recordSeparator) {
999999
* @see #withHeader(String...)
10001000
*/
10011001
public CSVFormat withSkipHeaderRecord(final boolean skipHeaderRecord) {
1002-
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart, escape,
1002+
return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
10031003
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
10041004
allowMissingColumnNames);
10051005
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ private void printAndQuote(final Object object, final CharSequence value,
182182
final char delimChar = format.getDelimiter();
183183
final char quoteChar = format.getQuoteChar().charValue();
184184

185-
Quote quotePolicy = format.getQuotePolicy();
186-
if (quotePolicy == null) {
187-
quotePolicy = Quote.MINIMAL;
185+
QuoteMode quoteModePolicy = format.getQuoteMode();
186+
if (quoteModePolicy == null) {
187+
quoteModePolicy = QuoteMode.MINIMAL;
188188
}
189-
switch (quotePolicy) {
189+
switch (quoteModePolicy) {
190190
case ALL:
191191
quote = true;
192192
break;
@@ -248,7 +248,7 @@ private void printAndQuote(final Object object, final CharSequence value,
248248
}
249249
break;
250250
default:
251-
throw new IllegalStateException("Unexpected Quote value: " + quotePolicy);
251+
throw new IllegalStateException("Unexpected Quote value: " + quoteModePolicy);
252252
}
253253

254254
if (!quote) {

src/main/java/org/apache/commons/csv/Quote.java renamed to src/main/java/org/apache/commons/csv/QuoteMode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*
2222
* @version $Id$
2323
*/
24-
public enum Quote {
24+
public enum QuoteMode {
2525

2626
/**
2727
* Quotes all fields.

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void testEqualsCommentStart() {
8888
final CSVFormat right = CSVFormat.newFormat('\'')
8989
.withQuoteChar('"')
9090
.withCommentMarker('#')
91-
.withQuotePolicy(Quote.ALL);
91+
.withQuoteMode(QuoteMode.ALL);
9292
final CSVFormat left = right
9393
.withCommentMarker('!');
9494

@@ -109,7 +109,7 @@ public void testEqualsEscape() {
109109
.withQuoteChar('"')
110110
.withCommentMarker('#')
111111
.withEscape('+')
112-
.withQuotePolicy(Quote.ALL);
112+
.withQuoteMode(QuoteMode.ALL);
113113
final CSVFormat left = right
114114
.withEscape('!');
115115

@@ -126,7 +126,7 @@ public void testEqualsHeader() {
126126
.withIgnoreEmptyLines(true)
127127
.withIgnoreSurroundingSpaces(true)
128128
.withQuoteChar('"')
129-
.withQuotePolicy(Quote.ALL);
129+
.withQuoteMode(QuoteMode.ALL);
130130
final CSVFormat left = right
131131
.withHeader("Three", "Two", "One");
132132

@@ -141,7 +141,7 @@ public void testEqualsIgnoreEmptyLines() {
141141
.withIgnoreEmptyLines(true)
142142
.withIgnoreSurroundingSpaces(true)
143143
.withQuoteChar('"')
144-
.withQuotePolicy(Quote.ALL);
144+
.withQuoteMode(QuoteMode.ALL);
145145
final CSVFormat left = right
146146
.withIgnoreEmptyLines(false);
147147

@@ -155,7 +155,7 @@ public void testEqualsIgnoreSurroundingSpaces() {
155155
.withEscape('+')
156156
.withIgnoreSurroundingSpaces(true)
157157
.withQuoteChar('"')
158-
.withQuotePolicy(Quote.ALL);
158+
.withQuoteMode(QuoteMode.ALL);
159159
final CSVFormat left = right
160160
.withIgnoreSurroundingSpaces(false);
161161

@@ -174,9 +174,9 @@ public void testEqualsQuoteChar() {
174174
public void testEqualsQuotePolicy() {
175175
final CSVFormat right = CSVFormat.newFormat('\'')
176176
.withQuoteChar('"')
177-
.withQuotePolicy(Quote.ALL);
177+
.withQuoteMode(QuoteMode.ALL);
178178
final CSVFormat left = right
179-
.withQuotePolicy(Quote.MINIMAL);
179+
.withQuoteMode(QuoteMode.MINIMAL);
180180

181181
assertNotEquals(right, left);
182182
}
@@ -190,7 +190,7 @@ public void testEqualsRecordSeparator() {
190190
.withIgnoreEmptyLines(true)
191191
.withIgnoreSurroundingSpaces(true)
192192
.withQuoteChar('"')
193-
.withQuotePolicy(Quote.ALL);
193+
.withQuoteMode(QuoteMode.ALL);
194194
final CSVFormat left = right
195195
.withRecordSeparator(LF);
196196

@@ -206,7 +206,7 @@ public void testEqualsNullString() {
206206
.withIgnoreEmptyLines(true)
207207
.withIgnoreSurroundingSpaces(true)
208208
.withQuoteChar('"')
209-
.withQuotePolicy(Quote.ALL)
209+
.withQuoteMode(QuoteMode.ALL)
210210
.withNullString("null");
211211
final CSVFormat left = right
212212
.withNullString("---");
@@ -223,7 +223,7 @@ public void testEqualsSkipHeaderRecord() {
223223
.withIgnoreEmptyLines(true)
224224
.withIgnoreSurroundingSpaces(true)
225225
.withQuoteChar('"')
226-
.withQuotePolicy(Quote.ALL)
226+
.withQuoteMode(QuoteMode.ALL)
227227
.withNullString("null")
228228
.withSkipHeaderRecord(true);
229229
final CSVFormat left = right
@@ -291,7 +291,7 @@ public void testQuoteCharSameAsDelimiterThrowsException() {
291291

292292
@Test(expected = IllegalArgumentException.class)
293293
public void testQuotePolicyNoneWithoutEscapeThrowsException() {
294-
CSVFormat.newFormat('!').withQuotePolicy(Quote.NONE);
294+
CSVFormat.newFormat('!').withQuoteMode(QuoteMode.NONE);
295295
}
296296

297297
@Test
@@ -301,7 +301,7 @@ public void testRFC4180() {
301301
assertEquals(null, RFC4180.getEscape());
302302
assertFalse(RFC4180.getIgnoreEmptyLines());
303303
assertEquals(Character.valueOf('"'), RFC4180.getQuoteChar());
304-
assertEquals(null, RFC4180.getQuotePolicy());
304+
assertEquals(null, RFC4180.getQuoteMode());
305305
assertEquals("\r\n", RFC4180.getRecordSeparator());
306306
}
307307

@@ -405,8 +405,8 @@ public void testWithQuoteLFThrowsException() {
405405

406406
@Test
407407
public void testWithQuotePolicy() throws Exception {
408-
final CSVFormat formatWithQuotePolicy = CSVFormat.DEFAULT.withQuotePolicy(Quote.ALL);
409-
assertEquals(Quote.ALL, formatWithQuotePolicy.getQuotePolicy());
408+
final CSVFormat formatWithQuotePolicy = CSVFormat.DEFAULT.withQuoteMode(QuoteMode.ALL);
409+
assertEquals(QuoteMode.ALL, formatWithQuotePolicy.getQuoteMode());
410410
}
411411

412412
@Test

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ public void testParseCustomNullValues() throws IOException {
352352
@Test
353353
public void testQuoteAll() throws IOException {
354354
final StringWriter sw = new StringWriter();
355-
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuotePolicy(Quote.ALL));
355+
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteMode(QuoteMode.ALL));
356356
printer.printRecord("a", "b\nc", "d");
357357
assertEquals("\"a\",\"b\nc\",\"d\"" + recordSeparator, sw.toString());
358358
printer.close();
@@ -361,7 +361,7 @@ public void testQuoteAll() throws IOException {
361361
@Test
362362
public void testQuoteNonNumeric() throws IOException {
363363
final StringWriter sw = new StringWriter();
364-
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuotePolicy(Quote.NON_NUMERIC));
364+
final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteMode(QuoteMode.NON_NUMERIC));
365365
printer.printRecord("a", "b\nc", Integer.valueOf(1));
366366
assertEquals("\"a\",\"b\nc\",1" + recordSeparator, sw.toString());
367367
printer.close();
@@ -417,7 +417,7 @@ public void testDelimeterQuoted() throws IOException {
417417
@Test
418418
public void testDelimeterQuoteNONE() throws IOException {
419419
final StringWriter sw = new StringWriter();
420-
final CSVFormat format = CSVFormat.DEFAULT.withEscape('!').withQuotePolicy(Quote.NONE);
420+
final CSVFormat format = CSVFormat.DEFAULT.withEscape('!').withQuoteMode(QuoteMode.NONE);
421421
final CSVPrinter printer = new CSVPrinter(sw, format);
422422
printer.print("a,b,c");
423423
printer.print("xyz");

0 commit comments

Comments
 (0)