diff --git a/src/main/java/org/apache/commons/csv/CSVFormat.java b/src/main/java/org/apache/commons/csv/CSVFormat.java index 3eca2d58..191d263a 100644 --- a/src/main/java/org/apache/commons/csv/CSVFormat.java +++ b/src/main/java/org/apache/commons/csv/CSVFormat.java @@ -497,7 +497,7 @@ public final class CSVFormat implements Serializable { * @return true if headers are ignored when parsing the header line, false to throw an * {@link IllegalArgumentException}. */ - public boolean getIgnoreEmptyHeaders() { + public boolean isIgnoringEmptyHeaders() { return ignoreEmptyHeaders; } @@ -507,7 +507,7 @@ public final class CSVFormat implements Serializable { * @return true if empty lines between records are ignored, false if they are turned into empty * records. */ - public boolean getIgnoreEmptyLines() { + public boolean isIgnoringEmptyLines() { return ignoreEmptyLines; } @@ -517,7 +517,7 @@ public final class CSVFormat implements Serializable { * @return true if spaces around values are ignored, false if they are treated as part of the * value. */ - public boolean getIgnoreSurroundingSpaces() { + public boolean isIgnoringSurroundingSpaces() { return ignoreSurroundingSpaces; } @@ -570,7 +570,7 @@ public final class CSVFormat implements Serializable { * * @return whether to skip the header record. */ - public boolean getSkipHeaderRecord() { + public boolean isSkippingHeaderRecord() { return skipHeaderRecord; } @@ -619,7 +619,7 @@ public final class CSVFormat implements Serializable { * * @return {@code true} if a nullString is defined */ - public boolean isNullHandling() { + public boolean isHandlingNull() { return nullString != null; } @@ -682,7 +682,7 @@ public final class CSVFormat implements Serializable { sb.append(' '); sb.append("CommentStart=<").append(commentStart).append('>'); } - if (isNullHandling()) { + if (isHandlingNull()) { sb.append(' '); sb.append("NullString=<").append(nullString).append('>'); } @@ -690,10 +690,10 @@ public final class CSVFormat implements Serializable { sb.append(' '); sb.append("RecordSeparator=<").append(recordSeparator).append('>'); } - if (getIgnoreEmptyLines()) { + if (isIgnoringEmptyLines()) { sb.append(" EmptyLines:ignored"); } - if (getIgnoreSurroundingSpaces()) { + if (isIgnoringSurroundingSpaces()) { sb.append(" SurroundingSpaces:ignored"); } sb.append(" SkipHeaderRecord:").append(skipHeaderRecord); diff --git a/src/main/java/org/apache/commons/csv/CSVParser.java b/src/main/java/org/apache/commons/csv/CSVParser.java index b7ca3fa9..533fe291 100644 --- a/src/main/java/org/apache/commons/csv/CSVParser.java +++ b/src/main/java/org/apache/commons/csv/CSVParser.java @@ -370,7 +370,7 @@ public final class CSVParser implements Iterable, Closeable { headerRecord = nextRecord.values(); } } else { - if (this.format.getSkipHeaderRecord()) { + if (this.format.isSkippingHeaderRecord()) { this.nextRecord(); } headerRecord = formatHeader; @@ -382,7 +382,7 @@ public final class CSVParser implements Iterable, Closeable { final String header = headerRecord[i]; final boolean containsHeader = hdrMap.containsKey(header); final boolean emptyHeader = header == null || header.trim().isEmpty(); - if (containsHeader && (!emptyHeader || (emptyHeader && !this.format.getIgnoreEmptyHeaders()))) { + if (containsHeader && (!emptyHeader || (emptyHeader && !this.format.isIgnoringEmptyHeaders()))) { throw new IllegalArgumentException("The header contains a duplicate name: \"" + header + "\" in " + Arrays.toString(headerRecord)); } diff --git a/src/main/java/org/apache/commons/csv/Lexer.java b/src/main/java/org/apache/commons/csv/Lexer.java index 6a4075e0..21630d78 100644 --- a/src/main/java/org/apache/commons/csv/Lexer.java +++ b/src/main/java/org/apache/commons/csv/Lexer.java @@ -65,8 +65,8 @@ final class Lexer implements Closeable { this.escape = mapNullToDisabled(format.getEscape()); this.quoteChar = mapNullToDisabled(format.getQuoteChar()); this.commentStart = mapNullToDisabled(format.getCommentStart()); - this.ignoreSurroundingSpaces = format.getIgnoreSurroundingSpaces(); - this.ignoreEmptyLines = format.getIgnoreEmptyLines(); + this.ignoreSurroundingSpaces = format.isIgnoringSurroundingSpaces(); + this.ignoreEmptyLines = format.isIgnoringEmptyLines(); } /** diff --git a/src/test/java/org/apache/commons/csv/CSVFormatTest.java b/src/test/java/org/apache/commons/csv/CSVFormatTest.java index c138556e..fe2fc30c 100644 --- a/src/test/java/org/apache/commons/csv/CSVFormatTest.java +++ b/src/test/java/org/apache/commons/csv/CSVFormatTest.java @@ -299,7 +299,7 @@ public class CSVFormatTest { assertEquals(null, RFC4180.getCommentStart()); assertEquals(',', RFC4180.getDelimiter()); assertEquals(null, RFC4180.getEscape()); - assertFalse(RFC4180.getIgnoreEmptyLines()); + assertFalse(RFC4180.isIgnoringEmptyLines()); assertEquals(Character.valueOf('"'), RFC4180.getQuoteChar()); assertEquals(null, RFC4180.getQuotePolicy()); assertEquals("\r\n", RFC4180.getRecordSeparator()); @@ -324,8 +324,8 @@ public class CSVFormatTest { assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), format.getCommentStart()); assertEquals("record 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()); + assertEquals("trim", CSVFormat.DEFAULT.isIgnoringSurroundingSpaces(), format.isIgnoringSurroundingSpaces()); + assertEquals("empty lines", CSVFormat.DEFAULT.isIgnoringEmptyLines(), format.isIgnoringEmptyLines()); } @Test @@ -376,14 +376,14 @@ public class CSVFormatTest { @Test public void testWithIgnoreEmptyLines() throws Exception { - assertFalse(CSVFormat.DEFAULT.withIgnoreEmptyLines(false).getIgnoreEmptyLines()); - assertTrue(CSVFormat.DEFAULT.withIgnoreEmptyLines(true).getIgnoreEmptyLines()); + assertFalse(CSVFormat.DEFAULT.withIgnoreEmptyLines(false).isIgnoringEmptyLines()); + assertTrue(CSVFormat.DEFAULT.withIgnoreEmptyLines(true).isIgnoringEmptyLines()); } @Test public void testWithIgnoreSurround() throws Exception { - assertFalse(CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(false).getIgnoreSurroundingSpaces()); - assertTrue(CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true).getIgnoreSurroundingSpaces()); + assertFalse(CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(false).isIgnoringSurroundingSpaces()); + assertTrue(CSVFormat.DEFAULT.withIgnoreSurroundingSpaces(true).isIgnoringSurroundingSpaces()); } @Test diff --git a/src/test/java/org/apache/commons/csv/LexerTest.java b/src/test/java/org/apache/commons/csv/LexerTest.java index 25dd5db2..4ede3b78 100644 --- a/src/test/java/org/apache/commons/csv/LexerTest.java +++ b/src/test/java/org/apache/commons/csv/LexerTest.java @@ -159,7 +159,7 @@ public class LexerTest { "\n"+ // 6c "# Final comment\n"; // 7 final CSVFormat format = CSVFormat.DEFAULT.withCommentStart('#').withIgnoreEmptyLines(false); - assertFalse("Should not ignore empty lines", format.getIgnoreEmptyLines()); + assertFalse("Should not ignore empty lines", format.isIgnoringEmptyLines()); final Lexer parser = getLexer(code, format);