Skip to content

Commit 67bbc35

Browse files
committed
Rename ivars that were in the past tense to use the imperative style.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1397087 13f79535-47bb-0310-9956-ffa450edef68
1 parent b5589d0 commit 67bbc35

8 files changed

Lines changed: 62 additions & 62 deletions

File tree

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

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public class CSVFormat implements Serializable {
4444
private final char encapsulator;
4545
private final char commentStart;
4646
private final char escape;
47-
private final boolean surroundingSpacesIgnored; // Should leading/trailing spaces be ignored around values?
48-
private final boolean emptyLinesIgnored;
47+
private final boolean ignoreSurroundingSpaces; // Should leading/trailing spaces be ignored around values?
48+
private final boolean ignoreEmptyLines;
4949
private final String lineSeparator; // for outputs
5050
private final String[] header;
5151

@@ -78,7 +78,7 @@ public class CSVFormat implements Serializable {
7878
PRISTINE.
7979
withDelimiter(COMMA)
8080
.withEncapsulator(DOUBLE_QUOTE)
81-
.withEmptyLinesIgnored(true)
81+
.withIgnoreEmptyLines(true)
8282
.withLineSeparator(CRLF);
8383

8484
/**
@@ -117,8 +117,8 @@ public class CSVFormat implements Serializable {
117117
PRISTINE
118118
.withDelimiter(TAB)
119119
.withEncapsulator(DOUBLE_QUOTE)
120-
.withSurroundingSpacesIgnored(true)
121-
.withEmptyLinesIgnored(true)
120+
.withIgnoreSurroundingSpaces(true)
121+
.withIgnoreEmptyLines(true)
122122
.withLineSeparator(CRLF);
123123

124124
/**
@@ -146,9 +146,9 @@ public class CSVFormat implements Serializable {
146146
* the char used for comment identification
147147
* @param escape
148148
* the char used to escape special characters in values
149-
* @param surroundingSpacesIgnored
149+
* @param ignoreSurroundingSpaces
150150
* <tt>true</tt> when whitespaces enclosing values should be ignored
151-
* @param emptyLinesIgnored
151+
* @param ignoreEmptyLines
152152
* <tt>true</tt> when the parser should skip empty lines
153153
* @param lineSeparator
154154
* the line separator to use for output
@@ -161,8 +161,8 @@ public class CSVFormat implements Serializable {
161161
this.encapsulator = encapsulator;
162162
this.commentStart = commentStart;
163163
this.escape = escape;
164-
this.surroundingSpacesIgnored = surroundingSpacesIgnored;
165-
this.emptyLinesIgnored = emptyLinesIgnored;
164+
this.ignoreSurroundingSpaces = surroundingSpacesIgnored;
165+
this.ignoreEmptyLines = emptyLinesIgnored;
166166
this.lineSeparator = lineSeparator;
167167
this.header = header;
168168
this.isEncapsulating = encapsulator != DISABLED;
@@ -234,8 +234,8 @@ public CSVFormat withDelimiter(char delimiter) {
234234
if (isLineBreak(delimiter)) {
235235
throw new IllegalArgumentException("The delimiter cannot be a line break");
236236
}
237-
return new CSVFormat(delimiter, encapsulator, commentStart, escape, surroundingSpacesIgnored,
238-
emptyLinesIgnored, lineSeparator, header);
237+
return new CSVFormat(delimiter, encapsulator, commentStart, escape, ignoreSurroundingSpaces,
238+
ignoreEmptyLines, lineSeparator, header);
239239
}
240240

241241
/**
@@ -260,8 +260,8 @@ public CSVFormat withEncapsulator(char encapsulator) {
260260
if (isLineBreak(encapsulator)) {
261261
throw new IllegalArgumentException("The encapsulator cannot be a line break");
262262
}
263-
return new CSVFormat(delimiter, encapsulator, commentStart, escape, surroundingSpacesIgnored,
264-
emptyLinesIgnored, lineSeparator, header);
263+
return new CSVFormat(delimiter, encapsulator, commentStart, escape, ignoreSurroundingSpaces,
264+
ignoreEmptyLines, lineSeparator, header);
265265
}
266266

267267
/**
@@ -297,8 +297,8 @@ public CSVFormat withCommentStart(char commentStart) {
297297
if (isLineBreak(commentStart)) {
298298
throw new IllegalArgumentException("The comment start character cannot be a line break");
299299
}
300-
return new CSVFormat(delimiter, encapsulator, commentStart, escape, surroundingSpacesIgnored,
301-
emptyLinesIgnored, lineSeparator, header);
300+
return new CSVFormat(delimiter, encapsulator, commentStart, escape, ignoreSurroundingSpaces,
301+
ignoreEmptyLines, lineSeparator, header);
302302
}
303303

304304
/**
@@ -334,8 +334,8 @@ public CSVFormat withEscape(char escape) {
334334
if (isLineBreak(escape)) {
335335
throw new IllegalArgumentException("The escape character cannot be a line break");
336336
}
337-
return new CSVFormat(delimiter, encapsulator, commentStart, escape, surroundingSpacesIgnored,
338-
emptyLinesIgnored, lineSeparator, header);
337+
return new CSVFormat(delimiter, encapsulator, commentStart, escape, ignoreSurroundingSpaces,
338+
ignoreEmptyLines, lineSeparator, header);
339339
}
340340

341341
/**
@@ -353,21 +353,21 @@ public boolean isEscaping() {
353353
* @return <tt>true</tt> if spaces around values are ignored, <tt>false</tt> if they are treated as part of the
354354
* value.
355355
*/
356-
public boolean isSurroundingSpacesIgnored() {
357-
return surroundingSpacesIgnored;
356+
public boolean getIgnoreSurroundingSpaces() {
357+
return ignoreSurroundingSpaces;
358358
}
359359

360360
/**
361361
* Returns a copy of this format with the specified trimming behavior.
362362
*
363-
* @param surroundingSpacesIgnored
363+
* @param ignoreSurroundingSpaces
364364
* the trimming behavior, <tt>true</tt> to remove the surrounding spaces, <tt>false</tt> to leave the
365365
* spaces as is.
366366
* @return A copy of this format with the specified trimming behavior.
367367
*/
368-
public CSVFormat withSurroundingSpacesIgnored(boolean surroundingSpacesIgnored) {
369-
return new CSVFormat(delimiter, encapsulator, commentStart, escape, surroundingSpacesIgnored,
370-
emptyLinesIgnored, lineSeparator, header);
368+
public CSVFormat withIgnoreSurroundingSpaces(boolean ignoreSurroundingSpaces) {
369+
return new CSVFormat(delimiter, encapsulator, commentStart, escape, ignoreSurroundingSpaces,
370+
ignoreEmptyLines, lineSeparator, header);
371371
}
372372

373373
/**
@@ -376,21 +376,21 @@ public CSVFormat withSurroundingSpacesIgnored(boolean surroundingSpacesIgnored)
376376
* @return <tt>true</tt> if empty lines between records are ignored, <tt>false</tt> if they are turned into empty
377377
* records.
378378
*/
379-
public boolean isEmptyLinesIgnored() {
380-
return emptyLinesIgnored;
379+
public boolean getIgnoreEmptyLines() {
380+
return ignoreEmptyLines;
381381
}
382382

383383
/**
384384
* Returns a copy of this format with the specified empty line skipping behavior.
385385
*
386-
* @param emptyLinesIgnored
386+
* @param ignoreEmptyLines
387387
* the empty line skipping behavior, <tt>true</tt> to ignore the empty lines between the records,
388388
* <tt>false</tt> to translate empty lines to empty records.
389389
* @return A copy of this format with the specified empty line skipping behavior.
390390
*/
391-
public CSVFormat withEmptyLinesIgnored(boolean emptyLinesIgnored) {
392-
return new CSVFormat(delimiter, encapsulator, commentStart, escape, surroundingSpacesIgnored,
393-
emptyLinesIgnored, lineSeparator, header);
391+
public CSVFormat withIgnoreEmptyLines(boolean ignoreEmptyLines) {
392+
return new CSVFormat(delimiter, encapsulator, commentStart, escape, ignoreSurroundingSpaces,
393+
ignoreEmptyLines, lineSeparator, header);
394394
}
395395

396396
/**
@@ -411,8 +411,8 @@ public String getLineSeparator() {
411411
* @return A copy of this format using the specified output line separator
412412
*/
413413
public CSVFormat withLineSeparator(String lineSeparator) {
414-
return new CSVFormat(delimiter, encapsulator, commentStart, escape, surroundingSpacesIgnored,
415-
emptyLinesIgnored, lineSeparator, header);
414+
return new CSVFormat(delimiter, encapsulator, commentStart, escape, ignoreSurroundingSpaces,
415+
ignoreEmptyLines, lineSeparator, header);
416416
}
417417

418418
String[] getHeader() {
@@ -439,8 +439,8 @@ String[] getHeader() {
439439
* @return A copy of this format using the specified header
440440
*/
441441
public CSVFormat withHeader(String... header) {
442-
return new CSVFormat(delimiter, encapsulator, commentStart, escape, surroundingSpacesIgnored,
443-
emptyLinesIgnored, lineSeparator, header);
442+
return new CSVFormat(delimiter, encapsulator, commentStart, escape, ignoreSurroundingSpaces,
443+
ignoreEmptyLines, lineSeparator, header);
444444
}
445445

446446
/**
@@ -486,10 +486,10 @@ public String toString() {
486486
sb.append(' ');
487487
sb.append("CommentStart=<").append(commentStart).append('>');
488488
}
489-
if (isEmptyLinesIgnored()) {
489+
if (getIgnoreEmptyLines()) {
490490
sb.append(" EmptyLines:ignored");
491491
}
492-
if (isSurroundingSpacesIgnored()) {
492+
if (getIgnoreSurroundingSpaces()) {
493493
sb.append(" SurroundingSpaces:ignored");
494494
}
495495
return sb.toString();

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ abstract class Lexer {
5151
this.escape = format.getEscape();
5252
this.encapsulator = format.getEncapsulator();
5353
this.commmentStart = format.getCommentStart();
54-
this.surroundingSpacesIgnored = format.isSurroundingSpacesIgnored();
55-
this.emptyLinesIgnored = format.isEmptyLinesIgnored();
54+
this.surroundingSpacesIgnored = format.getIgnoreSurroundingSpaces();
55+
this.emptyLinesIgnored = format.getIgnoreEmptyLines();
5656
}
5757

5858
int getLineNumber() {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ public void testCSVFile() throws Exception {
9494
final String option = split[i];
9595
String[] option_parts = option.split("=",2);
9696
if ("IgnoreEmpty".equalsIgnoreCase(option_parts[0])){
97-
fmt = fmt.withEmptyLinesIgnored(Boolean.parseBoolean(option_parts[1]));
97+
fmt = fmt.withIgnoreEmptyLines(Boolean.parseBoolean(option_parts[1]));
9898
} else if ("IgnoreSpaces".equalsIgnoreCase(option_parts[0])) {
99-
fmt = fmt.withSurroundingSpacesIgnored(Boolean.parseBoolean(option_parts[1]));
99+
fmt = fmt.withIgnoreSurroundingSpaces(Boolean.parseBoolean(option_parts[1]));
100100
} else if ("CommentStart".equalsIgnoreCase(option_parts[0])) {
101101
fmt = fmt.withCommentStart(option_parts[1].charAt(0));
102102
} else if ("CheckComments".equalsIgnoreCase(option_parts[0])) {

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,17 @@ public void testImmutalibity() {
4141
format.withCommentStart('?');
4242
format.withLineSeparator("?");
4343
format.withEscape('?');
44-
format.withSurroundingSpacesIgnored(false);
45-
format.withEmptyLinesIgnored(false);
44+
format.withIgnoreSurroundingSpaces(false);
45+
format.withIgnoreEmptyLines(false);
4646

4747
assertEquals('!', format.getDelimiter());
4848
assertEquals('!', format.getEncapsulator());
4949
assertEquals('!', format.getCommentStart());
5050
assertEquals('!', format.getEscape());
5151
assertEquals(CSVFormat.CRLF, format.getLineSeparator());
5252

53-
assertTrue(format.isSurroundingSpacesIgnored());
54-
assertTrue(format.isEmptyLinesIgnored());
53+
assertTrue(format.getIgnoreSurroundingSpaces());
54+
assertTrue(format.getIgnoreEmptyLines());
5555
}
5656

5757
@Test
@@ -64,8 +64,8 @@ public void testMutators() {
6464
assertEquals("?", format.withLineSeparator("?").getLineSeparator());
6565
assertEquals('?', format.withEscape('?').getEscape());
6666

67-
assertFalse(format.withSurroundingSpacesIgnored(false).isSurroundingSpacesIgnored());
68-
assertFalse(format.withEmptyLinesIgnored(false).isEmptyLinesIgnored());
67+
assertFalse(format.withIgnoreSurroundingSpaces(false).getIgnoreSurroundingSpaces());
68+
assertFalse(format.withIgnoreEmptyLines(false).getIgnoreEmptyLines());
6969
}
7070

7171
@Test
@@ -169,7 +169,7 @@ public void testSerialization() throws Exception {
169169
assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), format.getCommentStart());
170170
assertEquals("line separator", CSVFormat.DEFAULT.getLineSeparator(), format.getLineSeparator());
171171
assertEquals("escape", CSVFormat.DEFAULT.getEscape(), format.getEscape());
172-
assertEquals("trim", CSVFormat.DEFAULT.isSurroundingSpacesIgnored(), format.isSurroundingSpacesIgnored());
173-
assertEquals("empty lines", CSVFormat.DEFAULT.isEmptyLinesIgnored(), format.isEmptyLinesIgnored());
172+
assertEquals("trim", CSVFormat.DEFAULT.getIgnoreSurroundingSpaces(), format.getIgnoreSurroundingSpaces());
173+
assertEquals("empty lines", CSVFormat.DEFAULT.getIgnoreEmptyLines(), format.getIgnoreEmptyLines());
174174
}
175175
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ Token nextToken(Token tkn) throws IOException {
5858
c = in.readAgain();
5959

6060
// empty line detection: eol AND (last char was EOL or beginning)
61-
if (format.isEmptyLinesIgnored()) {
61+
if (format.getIgnoreEmptyLines()) {
6262
while (eol
6363
&& (lastChar == '\n' || lastChar == '\r' || lastChar == ExtendedBufferedReader.UNDEFINED)
6464
&& !isEndOfFile(lastChar)) {
@@ -84,7 +84,7 @@ Token nextToken(Token tkn) throws IOException {
8484
// important: make sure a new char gets consumed in each iteration
8585
while (!tkn.isReady && tkn.type != EOF) {
8686
// ignore whitespaces at beginning of a token
87-
if (format.isSurroundingSpacesIgnored()) {
87+
if (format.getIgnoreSurroundingSpaces()) {
8888
while (isWhitespace(c) && !eol) {
8989
wsBuf.append((char) c);
9090
c = in.read();
@@ -117,7 +117,7 @@ Token nextToken(Token tkn) throws IOException {
117117
} else {
118118
// next token must be a simple token
119119
// add removed blanks when not ignoring whitespace chars...
120-
if (!format.isSurroundingSpacesIgnored()) {
120+
if (!format.getIgnoreSurroundingSpaces()) {
121121
tkn.content.append(wsBuf);
122122
}
123123
simpleTokenLexer(tkn, c);
@@ -169,7 +169,7 @@ private Token simpleTokenLexer(Token tkn, int c) throws IOException {
169169
c = in.read();
170170
}
171171

172-
if (format.isSurroundingSpacesIgnored()) {
172+
if (format.getIgnoreSurroundingSpaces()) {
173173
trimTrailingSpaces(tkn.content);
174174
}
175175

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private void assertTokenEquals(Token.Type expectedType, String expectedContent,
4646
@Test
4747
public void testNextToken1() throws IOException {
4848
String code = "abc,def, hijk, lmnop, qrst,uv ,wxy ,z , ,";
49-
Lexer parser = getLexer(code, CSVFormat.DEFAULT.withSurroundingSpacesIgnored(true));
49+
Lexer parser = getLexer(code, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true));
5050
assertTokenEquals(TOKEN, "abc", parser.nextToken(new Token()));
5151
assertTokenEquals(TOKEN, "def", parser.nextToken(new Token()));
5252
assertTokenEquals(TOKEN, "hijk", parser.nextToken(new Token()));
@@ -79,7 +79,7 @@ public void testNextToken2() throws IOException {
7979
"\n"+
8080
"# Final comment\n"; // 7
8181
CSVFormat format = CSVFormat.DEFAULT.withCommentStart('#');
82-
assertTrue("Should ignore empty lines", format.isEmptyLinesIgnored());
82+
assertTrue("Should ignore empty lines", format.getIgnoreEmptyLines());
8383

8484
Lexer parser = getLexer(code, format);
8585

@@ -121,8 +121,8 @@ public void testNextToken2EmptyLines() throws IOException {
121121
"\n"+ // 6b
122122
"\n"+ // 6c
123123
"# Final comment\n"; // 7
124-
CSVFormat format = CSVFormat.DEFAULT.withCommentStart('#').withEmptyLinesIgnored(false);
125-
assertFalse("Should not ignore empty lines", format.isEmptyLinesIgnored());
124+
CSVFormat format = CSVFormat.DEFAULT.withCommentStart('#').withIgnoreEmptyLines(false);
125+
assertFalse("Should not ignore empty lines", format.getIgnoreEmptyLines());
126126

127127
Lexer parser = getLexer(code, format);
128128

@@ -182,7 +182,7 @@ public void testNextToken3Escaping() throws IOException {
182182
* \,,
183183
*/
184184
String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\r\ne";
185-
CSVFormat format = CSVFormat.DEFAULT.withEscape('\\').withEmptyLinesIgnored(false);
185+
CSVFormat format = CSVFormat.DEFAULT.withEscape('\\').withIgnoreEmptyLines(false);
186186
assertTrue(format.isEscaping());
187187
Lexer parser = getLexer(code, format);
188188

@@ -221,7 +221,7 @@ public void testNextToken4() throws IOException {
221221
* a, " foo " ,b
222222
*/
223223
String code = "a,\"foo\",b\na, \" foo\",b\na,\"foo \" ,b\na, \" foo \" ,b";
224-
Lexer parser = getLexer(code, CSVFormat.DEFAULT.withSurroundingSpacesIgnored(true));
224+
Lexer parser = getLexer(code, CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true));
225225
assertTokenEquals(TOKEN, "a", parser.nextToken(new Token()));
226226
assertTokenEquals(TOKEN, "foo", parser.nextToken(new Token()));
227227
assertTokenEquals(EORECORD, "b", parser.nextToken(new Token()));

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class CSVParserTest {
6565

6666
@Test
6767
public void testGetLine() throws IOException {
68-
CSVParser parser = new CSVParser(new StringReader(CSVINPUT), CSVFormat.DEFAULT.withSurroundingSpacesIgnored(true));
68+
CSVParser parser = new CSVParser(new StringReader(CSVINPUT), CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true));
6969
for (String[] re : RESULT) {
7070
assertArrayEquals(re, parser.getRecord().values());
7171
}
@@ -75,7 +75,7 @@ public void testGetLine() throws IOException {
7575

7676
@Test
7777
public void testGetRecords() throws IOException {
78-
CSVParser parser = new CSVParser(new StringReader(CSVINPUT), CSVFormat.DEFAULT.withSurroundingSpacesIgnored(true));
78+
CSVParser parser = new CSVParser(new StringReader(CSVINPUT), CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true));
7979
List<CSVRecord> records = parser.getRecords();
8080
assertEquals(RESULT.length, records.size());
8181
assertTrue(records.size() > 0);
@@ -307,7 +307,7 @@ public void testBackslashEscaping() throws IOException {
307307

308308

309309
CSVFormat format = CSVFormat.PRISTINE.withDelimiter(',').withEncapsulator('\'').withEscape('/')
310-
.withEmptyLinesIgnored(true).withLineSeparator(CSVFormat.CRLF);
310+
.withIgnoreEmptyLines(true).withLineSeparator(CSVFormat.CRLF);
311311

312312
CSVParser parser = new CSVParser(code, format);
313313
List<CSVRecord> records = parser.getRecords();
@@ -337,7 +337,7 @@ public void testBackslashEscaping2() throws IOException {
337337

338338

339339
CSVFormat format = CSVFormat.PRISTINE.withDelimiter(',').withEscape('/')
340-
.withEmptyLinesIgnored(true).withLineSeparator(CSVFormat.CRLF);
340+
.withIgnoreEmptyLines(true).withLineSeparator(CSVFormat.CRLF);
341341

342342
CSVParser parser = new CSVParser(code, format);
343343
List<CSVRecord> records = parser.getRecords();

src/test/java/org/apache/commons/csv/perf/PerformanceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private BufferedReader getBufferedReader() throws IOException {
4040
}
4141

4242
private long parse(Reader in) throws IOException {
43-
CSVFormat format = CSVFormat.DEFAULT.withSurroundingSpacesIgnored(false);
43+
CSVFormat format = CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(false);
4444
long count = 0;
4545
for (Object record : format.parse(in)) {
4646
count++;

0 commit comments

Comments
 (0)