Author: britter
Date: Mon Jul 21 16:23:00 2014
New Revision: 1612337
URL: http://svn.apache.org/r1612337
Log:
Rename the IgnoreEmptyHeaders property to AllowMissingColumnNames
Modified:
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
Modified:
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java?rev=1612337&r1=1612336&r2=1612337&view=diff
==============================================================================
---
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
(original)
+++
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVFormat.java
Mon Jul 21 16:23:00 2014
@@ -152,7 +152,7 @@ public final class CSVFormat implements
private final Character commentStart; // null if commenting is disabled
private final Character escape; // null if escaping is disabled
private final boolean ignoreSurroundingSpaces; // Should leading/trailing
spaces be ignored around values?
- private final boolean ignoreEmptyHeaders;
+ private final boolean allowMissingColumnNames;
private final boolean ignoreEmptyLines;
private final String recordSeparator; // for outputs
private final String nullString; // the string to be used for null values
@@ -330,7 +330,7 @@ public final class CSVFormat implements
* @param header
* the header
* @param skipHeaderRecord TODO
- * @param ignoreEmptyHeaders TODO
+ * @param allowMissingColumnNames TODO
* @throws IllegalArgumentException if the delimiter is a line break
character
*/
private CSVFormat(final char delimiter, final Character quoteChar,
@@ -338,7 +338,7 @@ public final class CSVFormat implements
final Character escape, final boolean ignoreSurroundingSpaces,
final boolean ignoreEmptyLines, final String recordSeparator,
final String nullString, final String[] header, final boolean
skipHeaderRecord,
- final boolean ignoreEmptyHeaders) {
+ final boolean allowMissingColumnNames) {
if (isLineBreak(delimiter)) {
throw new IllegalArgumentException("The delimiter cannot be a line
break");
}
@@ -348,7 +348,7 @@ public final class CSVFormat implements
this.commentStart = commentStart;
this.escape = escape;
this.ignoreSurroundingSpaces = ignoreSurroundingSpaces;
- this.ignoreEmptyHeaders = ignoreEmptyHeaders;
+ this.allowMissingColumnNames = allowMissingColumnNames;
this.ignoreEmptyLines = ignoreEmptyLines;
this.recordSeparator = recordSeparator;
this.nullString = nullString;
@@ -492,13 +492,13 @@ public final class CSVFormat implements
}
/**
- * Specifies whether empty headers are ignored when parsing the header
line.
+ * Specifies whether missing column names are allowed when parsing the
header line.
*
- * @return {@code true} if headers are ignored when parsing the header
line, {@code false} to throw an
+ * @return {@code true} if missing column names are allowed when parsing
the header line, {@code false} to throw an
* {@link IllegalArgumentException}.
*/
- public boolean isIgnoringEmptyHeaders() {
- return ignoreEmptyHeaders;
+ public boolean isAllowMissingColumnNames() {
+ return allowMissingColumnNames;
}
/**
@@ -772,7 +772,7 @@ public final class CSVFormat implements
}
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentMarker,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -790,7 +790,7 @@ public final class CSVFormat implements
}
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -821,7 +821,7 @@ public final class CSVFormat implements
}
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -844,21 +844,21 @@ public final class CSVFormat implements
public CSVFormat withHeader(final String... header) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
- * Sets the empty header behavior of the format.
+ * Sets the missing column names behavior of the format.
*
- * @param ignoreEmptyHeaders
- * the empty header behavior, {@code true} to ignore empty
headers in the header line,
+ * @param allowMissingColumnNames
+ * the missing column names behavior, {@code true} to allow
missing column names in the header line,
* {@code false} to cause an {@link IllegalArgumentException}
to be thrown.
- * @return A new CSVFormat that is equal to this but with the specified
empty header behavior.
+ * @return A new CSVFormat that is equal to this but with the specified
missing column names behavior.
*/
- public CSVFormat withIgnoreEmptyHeaders(final boolean ignoreEmptyHeaders) {
+ public CSVFormat withAllowMissingColumnNames(final boolean
allowMissingColumnNames) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
- ignoreSurroundingSpaces, ignoreEmptyHeaders, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
+ allowMissingColumnNames);
}
/**
@@ -872,7 +872,7 @@ public final class CSVFormat implements
public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -886,7 +886,7 @@ public final class CSVFormat implements
public CSVFormat withIgnoreSurroundingSpaces(final boolean
ignoreSurroundingSpaces) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -907,7 +907,7 @@ public final class CSVFormat implements
public CSVFormat withNullString(final String nullString) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -938,7 +938,7 @@ public final class CSVFormat implements
}
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -952,7 +952,7 @@ public final class CSVFormat implements
public CSVFormat withQuotePolicy(final Quote quotePolicy) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -986,7 +986,7 @@ public final class CSVFormat implements
public CSVFormat withRecordSeparator(final String recordSeparator) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
/**
@@ -1001,6 +1001,6 @@ public final class CSVFormat implements
public CSVFormat withSkipHeaderRecord(final boolean skipHeaderRecord) {
return new CSVFormat(delimiter, quoteChar, quotePolicy, commentStart,
escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator,
nullString, header, skipHeaderRecord,
- ignoreEmptyHeaders);
+ allowMissingColumnNames);
}
}
Modified:
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java?rev=1612337&r1=1612336&r2=1612337&view=diff
==============================================================================
---
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
(original)
+++
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVParser.java
Mon Jul 21 16:23:00 2014
@@ -29,7 +29,6 @@ import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
@@ -365,7 +364,7 @@ public final class CSVParser implements
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.isIgnoringEmptyHeaders()))) {
+ if (containsHeader && (!emptyHeader || (emptyHeader &&
!this.format.isAllowMissingColumnNames()))) {
throw new IllegalArgumentException("The header
contains a duplicate name: \"" + header +
"\" in " + Arrays.toString(headerRecord));
}
Modified:
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java?rev=1612337&r1=1612336&r2=1612337&view=diff
==============================================================================
---
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
(original)
+++
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
Mon Jul 21 16:23:00 2014
@@ -40,7 +40,6 @@ import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
@@ -650,13 +649,13 @@ public class CSVParserTest {
@Test
public void testHeadersMissing() throws Exception {
final Reader in = new StringReader("a,,c,,d\n1,2,3,4\nx,y,z,zz");
-
CSVFormat.DEFAULT.withHeader().withIgnoreEmptyHeaders(true).parse(in).iterator();
+
CSVFormat.DEFAULT.withHeader().withAllowMissingColumnNames(true).parse(in).iterator();
}
@Test
public void testHeaderMissingWithNull() throws Exception {
final Reader in = new StringReader("a,,c,,d\n1,2,3,4\nx,y,z,zz");
-
CSVFormat.DEFAULT.withHeader().withNullString("").withIgnoreEmptyHeaders(true).parse(in).iterator();
+
CSVFormat.DEFAULT.withHeader().withNullString("").withAllowMissingColumnNames(true).parse(in).iterator();
}
@Test