You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2014/07/21 19:18:21 UTC
svn commit: r1612352 - in /commons/proper/csv/trunk/src:
main/java/org/apache/commons/csv/ test/java/org/apache/commons/csv/
Author: ggregory
Date: Mon Jul 21 17:18:20 2014
New Revision: 1612352
URL: http://svn.apache.org/r1612352
Log:
Use "Character" as the postfix is ivar names. Use the method name pattern isFooSet() for ivar "foo" for methods that test foo for null (foo != null).
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/CSVPrinter.java
commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVParserTest.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/LexerTest.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=1612352&r1=1612351&r2=1612352&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 17:18:20 2014
@@ -147,10 +147,10 @@ public final class CSVFormat implements
private static final long serialVersionUID = 1L;
private final char delimiter;
- private final Character quoteChar; // null if quoting is disabled
+ private final Character quoteCharacter; // null if quoting is disabled
private final QuoteMode quoteMode;
- private final Character commentStart; // null if commenting is disabled
- private final Character escape; // null if escaping is disabled
+ private final Character commentStartCharacter; // null if commenting is disabled
+ private final Character escapeCharacter; // null if escaping is disabled
private final boolean ignoreSurroundingSpaces; // Should leading/trailing spaces be ignored around values?
private final boolean allowMissingColumnNames;
private final boolean ignoreEmptyLines;
@@ -258,7 +258,7 @@ public final class CSVFormat implements
.withDelimiter(TAB)
.withEscape(BACKSLASH)
.withIgnoreEmptyLines(false)
- .withQuoteChar(null)
+ .withQuote(null)
.withRecordSeparator(LF);
/**
@@ -343,10 +343,10 @@ public final class CSVFormat implements
throw new IllegalArgumentException("The delimiter cannot be a line break");
}
this.delimiter = delimiter;
- this.quoteChar = quoteChar;
+ this.quoteCharacter = quoteChar;
this.quoteMode = quoteMode;
- this.commentStart = commentStart;
- this.escape = escape;
+ this.commentStartCharacter = commentStart;
+ this.escapeCharacter = escape;
this.ignoreSurroundingSpaces = ignoreSurroundingSpaces;
this.allowMissingColumnNames = allowMissingColumnNames;
this.ignoreEmptyLines = ignoreEmptyLines;
@@ -387,25 +387,25 @@ public final class CSVFormat implements
if (quoteMode != other.quoteMode) {
return false;
}
- if (quoteChar == null) {
- if (other.quoteChar != null) {
+ if (quoteCharacter == null) {
+ if (other.quoteCharacter != null) {
return false;
}
- } else if (!quoteChar.equals(other.quoteChar)) {
+ } else if (!quoteCharacter.equals(other.quoteCharacter)) {
return false;
}
- if (commentStart == null) {
- if (other.commentStart != null) {
+ if (commentStartCharacter == null) {
+ if (other.commentStartCharacter != null) {
return false;
}
- } else if (!commentStart.equals(other.commentStart)) {
+ } else if (!commentStartCharacter.equals(other.commentStartCharacter)) {
return false;
}
- if (escape == null) {
- if (other.escape != null) {
+ if (escapeCharacter == null) {
+ if (other.escapeCharacter != null) {
return false;
}
- } else if (!escape.equals(other.escape)) {
+ } else if (!escapeCharacter.equals(other.escapeCharacter)) {
return false;
}
if (nullString == null) {
@@ -460,8 +460,8 @@ public final class CSVFormat implements
*
* @return the comment start marker, may be {@code null}
*/
- public Character getCommentStart() {
- return commentStart;
+ public Character getCommentStartCharacter() {
+ return commentStartCharacter;
}
/**
@@ -478,8 +478,8 @@ public final class CSVFormat implements
*
* @return the escape character, may be {@code null}
*/
- public Character getEscape() {
- return escape;
+ public Character getEscapeCharacter() {
+ return escapeCharacter;
}
/**
@@ -543,8 +543,8 @@ public final class CSVFormat implements
*
* @return the quoteChar character, may be {@code null}
*/
- public Character getQuoteChar() {
- return quoteChar;
+ public Character getQuoteCharacter() {
+ return quoteCharacter;
}
/**
@@ -582,9 +582,9 @@ public final class CSVFormat implements
result = prime * result + delimiter;
result = prime * result + ((quoteMode == null) ? 0 : quoteMode.hashCode());
- result = prime * result + ((quoteChar == null) ? 0 : quoteChar.hashCode());
- result = prime * result + ((commentStart == null) ? 0 : commentStart.hashCode());
- result = prime * result + ((escape == null) ? 0 : escape.hashCode());
+ result = prime * result + ((quoteCharacter == null) ? 0 : quoteCharacter.hashCode());
+ result = prime * result + ((commentStartCharacter == null) ? 0 : commentStartCharacter.hashCode());
+ result = prime * result + ((escapeCharacter == null) ? 0 : escapeCharacter.hashCode());
result = prime * result + ((nullString == null) ? 0 : nullString.hashCode());
result = prime * result + (ignoreSurroundingSpaces ? 1231 : 1237);
result = prime * result + (ignoreEmptyLines ? 1231 : 1237);
@@ -601,8 +601,8 @@ public final class CSVFormat implements
*
* @return {@code true} is comments are supported, {@code false} otherwise
*/
- public boolean isCommentingEnabled() {
- return commentStart != null;
+ public boolean isCommentStartCharacterSet() {
+ return commentStartCharacter != null;
}
/**
@@ -610,8 +610,8 @@ public final class CSVFormat implements
*
* @return {@code true} if escapes are processed
*/
- public boolean isEscaping() {
- return escape != null;
+ public boolean isEscapeCharacterSet() {
+ return escapeCharacter != null;
}
/**
@@ -619,7 +619,7 @@ public final class CSVFormat implements
*
* @return {@code true} if a nullString is defined
*/
- public boolean isHandlingNull() {
+ public boolean isNullStringSet() {
return nullString != null;
}
@@ -628,8 +628,8 @@ public final class CSVFormat implements
*
* @return {@code true} if a quoteChar is defined
*/
- public boolean isQuoting() {
- return quoteChar != null;
+ public boolean isQuoteCharacterSet() {
+ return quoteCharacter != null;
}
/**
@@ -670,19 +670,19 @@ public final class CSVFormat implements
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("Delimiter=<").append(delimiter).append('>');
- if (isEscaping()) {
+ if (isEscapeCharacterSet()) {
sb.append(' ');
- sb.append("Escape=<").append(escape).append('>');
+ sb.append("Escape=<").append(escapeCharacter).append('>');
}
- if (isQuoting()) {
+ if (isQuoteCharacterSet()) {
sb.append(' ');
- sb.append("QuoteChar=<").append(quoteChar).append('>');
+ sb.append("QuoteChar=<").append(quoteCharacter).append('>');
}
- if (isCommentingEnabled()) {
+ if (isCommentStartCharacterSet()) {
sb.append(' ');
- sb.append("CommentStart=<").append(commentStart).append('>');
+ sb.append("CommentStart=<").append(commentStartCharacter).append('>');
}
- if (isHandlingNull()) {
+ if (isNullStringSet()) {
sb.append(' ');
sb.append("NullString=<").append(nullString).append('>');
}
@@ -710,32 +710,32 @@ public final class CSVFormat implements
* @throws IllegalArgumentException
*/
private void validate() throws IllegalArgumentException {
- if (quoteChar != null && delimiter == quoteChar.charValue()) {
+ if (quoteCharacter != null && delimiter == quoteCharacter.charValue()) {
throw new IllegalArgumentException(
- "The quoteChar character and the delimiter cannot be the same ('" + quoteChar + "')");
+ "The quoteChar character and the delimiter cannot be the same ('" + quoteCharacter + "')");
}
- if (escape != null && delimiter == escape.charValue()) {
+ if (escapeCharacter != null && delimiter == escapeCharacter.charValue()) {
throw new IllegalArgumentException(
- "The escape character and the delimiter cannot be the same ('" + escape + "')");
+ "The escape character and the delimiter cannot be the same ('" + escapeCharacter + "')");
}
- if (commentStart != null && delimiter == commentStart.charValue()) {
+ if (commentStartCharacter != null && delimiter == commentStartCharacter.charValue()) {
throw new IllegalArgumentException(
- "The comment start character and the delimiter cannot be the same ('" + commentStart + "')");
+ "The comment start character and the delimiter cannot be the same ('" + commentStartCharacter + "')");
}
- if (quoteChar != null && quoteChar.equals(commentStart)) {
+ if (quoteCharacter != null && quoteCharacter.equals(commentStartCharacter)) {
throw new IllegalArgumentException(
- "The comment start character and the quoteChar cannot be the same ('" + commentStart + "')");
+ "The comment start character and the quoteChar cannot be the same ('" + commentStartCharacter + "')");
}
- if (escape != null && escape.equals(commentStart)) {
+ if (escapeCharacter != null && escapeCharacter.equals(commentStartCharacter)) {
throw new IllegalArgumentException(
- "The comment start and the escape character cannot be the same ('" + commentStart + "')");
+ "The comment start and the escape character cannot be the same ('" + commentStartCharacter + "')");
}
- if (escape == null && quoteMode == QuoteMode.NONE) {
+ if (escapeCharacter == null && quoteMode == QuoteMode.NONE) {
throw new IllegalArgumentException("No quotes mode set but no escape character is set");
}
}
@@ -770,7 +770,7 @@ public final class CSVFormat implements
if (isLineBreak(commentMarker)) {
throw new IllegalArgumentException("The comment start marker character cannot be a line break");
}
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentMarker, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentMarker, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -788,7 +788,7 @@ public final class CSVFormat implements
if (isLineBreak(delimiter)) {
throw new IllegalArgumentException("The delimiter cannot be a line break");
}
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -819,7 +819,7 @@ public final class CSVFormat implements
if (isLineBreak(escape)) {
throw new IllegalArgumentException("The escape character cannot be a line break");
}
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escape,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -842,7 +842,7 @@ public final class CSVFormat implements
* @see #withSkipHeaderRecord(boolean)
*/
public CSVFormat withHeader(final String... header) {
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -856,7 +856,7 @@ public final class CSVFormat implements
* @return A new CSVFormat that is equal to this but with the specified missing column names behavior.
*/
public CSVFormat withAllowMissingColumnNames(final boolean allowMissingColumnNames) {
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -870,7 +870,7 @@ public final class CSVFormat implements
* @return A new CSVFormat that is equal to this but with the specified empty line skipping behavior.
*/
public CSVFormat withIgnoreEmptyLines(final boolean ignoreEmptyLines) {
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -884,7 +884,7 @@ public final class CSVFormat implements
* @return A new CSVFormat that is equal to this but with the specified trimming behavior.
*/
public CSVFormat withIgnoreSurroundingSpaces(final boolean ignoreSurroundingSpaces) {
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -905,7 +905,7 @@ public final class CSVFormat implements
* @return A new CSVFormat that is equal to this but with the specified null conversion string.
*/
public CSVFormat withNullString(final String nullString) {
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -919,8 +919,8 @@ public final class CSVFormat implements
* @throws IllegalArgumentException
* thrown if the specified character is a line break
*/
- public CSVFormat withQuoteChar(final char quoteChar) {
- return withQuoteChar(Character.valueOf(quoteChar));
+ public CSVFormat withQuote(final char quoteChar) {
+ return withQuote(Character.valueOf(quoteChar));
}
/**
@@ -932,11 +932,11 @@ public final class CSVFormat implements
* @throws IllegalArgumentException
* thrown if the specified character is a line break
*/
- public CSVFormat withQuoteChar(final Character quoteChar) {
+ public CSVFormat withQuote(final Character quoteChar) {
if (isLineBreak(quoteChar)) {
throw new IllegalArgumentException("The quoteChar cannot be a line break");
}
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteChar, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -950,7 +950,7 @@ public final class CSVFormat implements
* @return A new CSVFormat that is equal to this but with the specified quote policy
*/
public CSVFormat withQuoteMode(final QuoteMode quoteModePolicy) {
- return new CSVFormat(delimiter, quoteChar, quoteModePolicy, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteModePolicy, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -984,7 +984,7 @@ public final class CSVFormat implements
* if recordSeparator is none of CR, LF or CRLF
*/
public CSVFormat withRecordSeparator(final String recordSeparator) {
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
@@ -999,7 +999,7 @@ public final class CSVFormat implements
* @see #withHeader(String...)
*/
public CSVFormat withSkipHeaderRecord(final boolean skipHeaderRecord) {
- return new CSVFormat(delimiter, quoteChar, quoteMode, commentStart, escape,
+ return new CSVFormat(delimiter, quoteCharacter, quoteMode, commentStartCharacter, escapeCharacter,
ignoreSurroundingSpaces, ignoreEmptyLines, recordSeparator, nullString, header, skipHeaderRecord,
allowMissingColumnNames);
}
Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java?rev=1612352&r1=1612351&r2=1612352&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/CSVPrinter.java Mon Jul 21 17:18:20 2014
@@ -118,10 +118,10 @@ public final class CSVPrinter implements
if (!newRecord) {
out.append(format.getDelimiter());
}
- if (format.isQuoting()) {
+ if (format.isQuoteCharacterSet()) {
// the original object is needed so can check for Number
printAndQuote(object, value, offset, len);
- } else if (format.isEscaping()) {
+ } else if (format.isEscapeCharacterSet()) {
printAndEscape(value, offset, len);
} else {
out.append(value, offset, offset + len);
@@ -138,7 +138,7 @@ public final class CSVPrinter implements
final int end = offset + len;
final char delim = format.getDelimiter();
- final char escape = format.getEscape().charValue();
+ final char escape = format.getEscapeCharacter().charValue();
while (pos < end) {
char c = value.charAt(pos);
@@ -180,7 +180,7 @@ public final class CSVPrinter implements
final int end = offset + len;
final char delimChar = format.getDelimiter();
- final char quoteChar = format.getQuoteChar().charValue();
+ final char quoteChar = format.getQuoteCharacter().charValue();
QuoteMode quoteModePolicy = format.getQuoteMode();
if (quoteModePolicy == null) {
@@ -297,13 +297,13 @@ public final class CSVPrinter implements
* If an I/O error occurs
*/
public void printComment(final String comment) throws IOException {
- if (!format.isCommentingEnabled()) {
+ if (!format.isCommentStartCharacterSet()) {
return;
}
if (!newRecord) {
println();
}
- out.append(format.getCommentStart().charValue());
+ out.append(format.getCommentStartCharacter().charValue());
out.append(SP);
for (int i = 0; i < comment.length(); i++) {
final char c = comment.charAt(i);
@@ -315,7 +315,7 @@ public final class CSVPrinter implements
//$FALL-THROUGH$ break intentionally excluded.
case LF:
println();
- out.append(format.getCommentStart().charValue());
+ out.append(format.getCommentStartCharacter().charValue());
out.append(SP);
break;
default:
Modified: commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java?rev=1612352&r1=1612351&r2=1612352&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java (original)
+++ commons/proper/csv/trunk/src/main/java/org/apache/commons/csv/Lexer.java Mon Jul 21 17:18:20 2014
@@ -62,9 +62,9 @@ final class Lexer implements Closeable {
Lexer(final CSVFormat format, final ExtendedBufferedReader reader) {
this.reader = reader;
this.delimiter = format.getDelimiter();
- this.escape = mapNullToDisabled(format.getEscape());
- this.quoteChar = mapNullToDisabled(format.getQuoteChar());
- this.commentStart = mapNullToDisabled(format.getCommentStart());
+ this.escape = mapNullToDisabled(format.getEscapeCharacter());
+ this.quoteChar = mapNullToDisabled(format.getQuoteCharacter());
+ this.commentStart = mapNullToDisabled(format.getCommentStartCharacter());
this.ignoreSurroundingSpaces = format.getIgnoreSurroundingSpaces();
this.ignoreEmptyLines = format.getIgnoreEmptyLines();
}
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java?rev=1612352&r1=1612351&r2=1612352&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFileParserTest.java Mon Jul 21 17:18:20 2014
@@ -90,7 +90,7 @@ public class CSVFileParserTest {
final String[] split = line.split(" ");
assertTrue(testName+" require 1 param", split.length >= 1);
// first line starts with csv data file name
- CSVFormat format = CSVFormat.newFormat(',').withQuoteChar('"');
+ CSVFormat format = CSVFormat.newFormat(',').withQuote('"');
boolean checkComments = false;
for(int i=1; i < split.length; i++) {
final String option = split[i];
@@ -134,7 +134,7 @@ public class CSVFileParserTest {
final String[] split = line.split(" ");
assertTrue(testName + " require 1 param", split.length >= 1);
// first line starts with csv data file name
- CSVFormat format = CSVFormat.newFormat(',').withQuoteChar('"');
+ CSVFormat format = CSVFormat.newFormat(',').withQuote('"');
boolean checkComments = false;
for (int i = 1; i < split.length; i++) {
final String option = split[i];
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java?rev=1612352&r1=1612351&r2=1612352&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVFormatTest.java Mon Jul 21 17:18:20 2014
@@ -86,7 +86,7 @@ public class CSVFormatTest {
@Test
public void testEqualsCommentStart() {
final CSVFormat right = CSVFormat.newFormat('\'')
- .withQuoteChar('"')
+ .withQuote('"')
.withCommentMarker('#')
.withQuoteMode(QuoteMode.ALL);
final CSVFormat left = right
@@ -106,7 +106,7 @@ public class CSVFormatTest {
@Test
public void testEqualsEscape() {
final CSVFormat right = CSVFormat.newFormat('\'')
- .withQuoteChar('"')
+ .withQuote('"')
.withCommentMarker('#')
.withEscape('+')
.withQuoteMode(QuoteMode.ALL);
@@ -125,7 +125,7 @@ public class CSVFormatTest {
.withHeader("One", "Two", "Three")
.withIgnoreEmptyLines(true)
.withIgnoreSurroundingSpaces(true)
- .withQuoteChar('"')
+ .withQuote('"')
.withQuoteMode(QuoteMode.ALL);
final CSVFormat left = right
.withHeader("Three", "Two", "One");
@@ -140,7 +140,7 @@ public class CSVFormatTest {
.withEscape('+')
.withIgnoreEmptyLines(true)
.withIgnoreSurroundingSpaces(true)
- .withQuoteChar('"')
+ .withQuote('"')
.withQuoteMode(QuoteMode.ALL);
final CSVFormat left = right
.withIgnoreEmptyLines(false);
@@ -154,7 +154,7 @@ public class CSVFormatTest {
.withCommentMarker('#')
.withEscape('+')
.withIgnoreSurroundingSpaces(true)
- .withQuoteChar('"')
+ .withQuote('"')
.withQuoteMode(QuoteMode.ALL);
final CSVFormat left = right
.withIgnoreSurroundingSpaces(false);
@@ -164,8 +164,8 @@ public class CSVFormatTest {
@Test
public void testEqualsQuoteChar() {
- final CSVFormat right = CSVFormat.newFormat('\'').withQuoteChar('"');
- final CSVFormat left = right.withQuoteChar('!');
+ final CSVFormat right = CSVFormat.newFormat('\'').withQuote('"');
+ final CSVFormat left = right.withQuote('!');
assertNotEquals(right, left);
}
@@ -173,7 +173,7 @@ public class CSVFormatTest {
@Test
public void testEqualsQuotePolicy() {
final CSVFormat right = CSVFormat.newFormat('\'')
- .withQuoteChar('"')
+ .withQuote('"')
.withQuoteMode(QuoteMode.ALL);
final CSVFormat left = right
.withQuoteMode(QuoteMode.MINIMAL);
@@ -189,7 +189,7 @@ public class CSVFormatTest {
.withEscape('+')
.withIgnoreEmptyLines(true)
.withIgnoreSurroundingSpaces(true)
- .withQuoteChar('"')
+ .withQuote('"')
.withQuoteMode(QuoteMode.ALL);
final CSVFormat left = right
.withRecordSeparator(LF);
@@ -205,7 +205,7 @@ public class CSVFormatTest {
.withEscape('+')
.withIgnoreEmptyLines(true)
.withIgnoreSurroundingSpaces(true)
- .withQuoteChar('"')
+ .withQuote('"')
.withQuoteMode(QuoteMode.ALL)
.withNullString("null");
final CSVFormat left = right
@@ -222,7 +222,7 @@ public class CSVFormatTest {
.withEscape('+')
.withIgnoreEmptyLines(true)
.withIgnoreSurroundingSpaces(true)
- .withQuoteChar('"')
+ .withQuote('"')
.withQuoteMode(QuoteMode.ALL)
.withNullString("null")
.withSkipHeaderRecord(true);
@@ -275,18 +275,18 @@ public class CSVFormatTest {
@Test(expected = IllegalArgumentException.class)
public void testQuoteCharSameAsCommentStartThrowsException() {
- CSVFormat.DEFAULT.withQuoteChar('!').withCommentMarker('!');
+ CSVFormat.DEFAULT.withQuote('!').withCommentMarker('!');
}
@Test(expected = IllegalArgumentException.class)
public void testQuoteCharSameAsCommentStartThrowsExceptionForWrapperType() {
// Cannot assume that callers won't use different Character objects
- CSVFormat.DEFAULT.withQuoteChar(new Character('!')).withCommentMarker('!');
+ CSVFormat.DEFAULT.withQuote(new Character('!')).withCommentMarker('!');
}
@Test(expected = IllegalArgumentException.class)
public void testQuoteCharSameAsDelimiterThrowsException() {
- CSVFormat.DEFAULT.withQuoteChar('!').withDelimiter('!');
+ CSVFormat.DEFAULT.withQuote('!').withDelimiter('!');
}
@Test(expected = IllegalArgumentException.class)
@@ -296,11 +296,11 @@ public class CSVFormatTest {
@Test
public void testRFC4180() {
- assertEquals(null, RFC4180.getCommentStart());
+ assertEquals(null, RFC4180.getCommentStartCharacter());
assertEquals(',', RFC4180.getDelimiter());
- assertEquals(null, RFC4180.getEscape());
+ assertEquals(null, RFC4180.getEscapeCharacter());
assertFalse(RFC4180.getIgnoreEmptyLines());
- assertEquals(Character.valueOf('"'), RFC4180.getQuoteChar());
+ assertEquals(Character.valueOf('"'), RFC4180.getQuoteCharacter());
assertEquals(null, RFC4180.getQuoteMode());
assertEquals("\r\n", RFC4180.getRecordSeparator());
}
@@ -320,10 +320,10 @@ public class CSVFormatTest {
assertNotNull(format);
assertEquals("delimiter", CSVFormat.DEFAULT.getDelimiter(), format.getDelimiter());
- assertEquals("encapsulator", CSVFormat.DEFAULT.getQuoteChar(), format.getQuoteChar());
- assertEquals("comment start", CSVFormat.DEFAULT.getCommentStart(), format.getCommentStart());
+ assertEquals("encapsulator", CSVFormat.DEFAULT.getQuoteCharacter(), format.getQuoteCharacter());
+ assertEquals("comment start", CSVFormat.DEFAULT.getCommentStartCharacter(), format.getCommentStartCharacter());
assertEquals("record separator", CSVFormat.DEFAULT.getRecordSeparator(), format.getRecordSeparator());
- assertEquals("escape", CSVFormat.DEFAULT.getEscape(), format.getEscape());
+ assertEquals("escape", CSVFormat.DEFAULT.getEscapeCharacter(), format.getEscapeCharacter());
assertEquals("trim", CSVFormat.DEFAULT.getIgnoreSurroundingSpaces(), format.getIgnoreSurroundingSpaces());
assertEquals("empty lines", CSVFormat.DEFAULT.getIgnoreEmptyLines(), format.getIgnoreEmptyLines());
}
@@ -331,7 +331,7 @@ public class CSVFormatTest {
@Test
public void testWithCommentStart() throws Exception {
final CSVFormat formatWithCommentStart = CSVFormat.DEFAULT.withCommentMarker('#');
- assertEquals( Character.valueOf('#'), formatWithCommentStart.getCommentStart());
+ assertEquals( Character.valueOf('#'), formatWithCommentStart.getCommentStartCharacter());
}
@Test(expected = IllegalArgumentException.class)
@@ -353,7 +353,7 @@ public class CSVFormatTest {
@Test
public void testWithEscape() throws Exception {
final CSVFormat formatWithEscape = CSVFormat.DEFAULT.withEscape('&');
- assertEquals(Character.valueOf('&'), formatWithEscape.getEscape());
+ assertEquals(Character.valueOf('&'), formatWithEscape.getEscapeCharacter());
}
@Test(expected = IllegalArgumentException.class)
@@ -394,13 +394,13 @@ public class CSVFormatTest {
@Test
public void testWithQuoteChar() throws Exception {
- final CSVFormat formatWithQuoteChar = CSVFormat.DEFAULT.withQuoteChar('"');
- assertEquals(Character.valueOf('"'), formatWithQuoteChar.getQuoteChar());
+ final CSVFormat formatWithQuoteChar = CSVFormat.DEFAULT.withQuote('"');
+ assertEquals(Character.valueOf('"'), formatWithQuoteChar.getQuoteCharacter());
}
@Test(expected = IllegalArgumentException.class)
public void testWithQuoteLFThrowsException() {
- CSVFormat.DEFAULT.withQuoteChar(LF);
+ CSVFormat.DEFAULT.withQuote(LF);
}
@Test
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=1612352&r1=1612351&r2=1612352&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 17:18:20 2014
@@ -112,7 +112,7 @@ public class CSVParserTest {
};
- final CSVFormat format = CSVFormat.newFormat(',').withQuoteChar('\'')
+ final CSVFormat format = CSVFormat.newFormat(',').withQuote('\'')
.withRecordSeparator(CRLF).withEscape('/').withIgnoreEmptyLines(true);
final CSVParser parser = CSVParser.parse(code, format);
@@ -274,7 +274,7 @@ public class CSVParserTest {
};
CSVFormat format = CSVFormat.DEFAULT;
- assertFalse(format.isCommentingEnabled());
+ assertFalse(format.isCommentStartCharacterSet());
CSVParser parser = CSVParser.parse(code, format);
List<CSVRecord> records = parser.getRecords();
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java?rev=1612352&r1=1612351&r2=1612352&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/CSVPrinterTest.java Mon Jul 21 17:18:20 2014
@@ -378,7 +378,7 @@ public class CSVPrinterTest {
@Test
public void testPlainQuoted() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar('\''));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote('\''));
printer.print("abc");
assertEquals("abc", sw.toString());
printer.close();
@@ -397,7 +397,7 @@ public class CSVPrinterTest {
@Test
public void testSingleQuoteQuoted() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar('\''));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote('\''));
printer.print("a'b'c");
printer.print("xyz");
assertEquals("'a''b''c',xyz", sw.toString());
@@ -407,7 +407,7 @@ public class CSVPrinterTest {
@Test
public void testDelimeterQuoted() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar('\''));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote('\''));
printer.print("a,b,c");
printer.print("xyz");
assertEquals("'a,b,c',xyz", sw.toString());
@@ -428,7 +428,7 @@ public class CSVPrinterTest {
@Test
public void testEOLQuoted() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar('\''));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote('\''));
printer.print("a\rb\nc");
printer.print("x\by\fz");
assertEquals("'a\rb\nc',x\by\fz", sw.toString());
@@ -438,7 +438,7 @@ public class CSVPrinterTest {
@Test
public void testPlainEscaped() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar(null).withEscape('!'));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null).withEscape('!'));
printer.print("abc");
printer.print("xyz");
assertEquals("abc,xyz", sw.toString());
@@ -448,7 +448,7 @@ public class CSVPrinterTest {
@Test
public void testDelimiterEscaped() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withEscape('!').withQuoteChar(null));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withEscape('!').withQuote(null));
printer.print("a,b,c");
printer.print("xyz");
assertEquals("a!,b!,c,xyz", sw.toString());
@@ -458,7 +458,7 @@ public class CSVPrinterTest {
@Test
public void testEOLEscaped() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar(null).withEscape('!'));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null).withEscape('!'));
printer.print("a\rb\nc");
printer.print("x\fy\bz");
assertEquals("a!rb!nc,x\fy\bz", sw.toString());
@@ -468,7 +468,7 @@ public class CSVPrinterTest {
@Test
public void testPlainPlain() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar(null));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null));
printer.print("abc");
printer.print("xyz");
assertEquals("abc,xyz", sw.toString());
@@ -478,7 +478,7 @@ public class CSVPrinterTest {
@Test
public void testDelimiterPlain() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar(null));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null));
printer.print("a,b,c");
printer.print("xyz");
assertEquals("a,b,c,xyz", sw.toString());
@@ -488,7 +488,7 @@ public class CSVPrinterTest {
@Test
public void testHeader() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar(null)
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null)
.withHeader("C1", "C2", "C3"));
printer.printRecord("a", "b", "c");
printer.printRecord("x", "y", "z");
@@ -499,7 +499,7 @@ public class CSVPrinterTest {
@Test
public void testEOLPlain() throws IOException {
final StringWriter sw = new StringWriter();
- final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuoteChar(null));
+ final CSVPrinter printer = new CSVPrinter(sw, CSVFormat.DEFAULT.withQuote(null));
printer.print("a\rb\nc");
printer.print("x\fy\bz");
assertEquals("a\rb\nc,x\fy\bz", sw.toString());
Modified: commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/LexerTest.java
URL: http://svn.apache.org/viewvc/commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/LexerTest.java?rev=1612352&r1=1612351&r2=1612352&view=diff
==============================================================================
--- commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/LexerTest.java (original)
+++ commons/proper/csv/trunk/src/test/java/org/apache/commons/csv/LexerTest.java Mon Jul 21 17:18:20 2014
@@ -198,7 +198,7 @@ public class LexerTest {
*/
final String code = "a,\\,,b\\\n\\,,";
final CSVFormat format = CSVFormat.DEFAULT;
- assertFalse(format.isEscaping());
+ assertFalse(format.isEscapeCharacterSet());
final Lexer parser = getLexer(code, format);
assertThat(parser.nextToken(new Token()), matches(TOKEN, "a"));
@@ -220,7 +220,7 @@ public class LexerTest {
*/
final String code = "a,\\,,b\\\\\n\\,,\\\nc,d\\\r\ne";
final CSVFormat format = formatWithEscaping.withIgnoreEmptyLines(false);
- assertTrue(format.isEscaping());
+ assertTrue(format.isEscapeCharacterSet());
final Lexer parser = getLexer(code, format);
assertThat(parser.nextToken(new Token()), matches(TOKEN, "a"));
@@ -279,7 +279,7 @@ public class LexerTest {
* ;;
*/
final String code = "a;'b and '' more\n'\n!comment;;;;\n;;";
- final CSVFormat format = CSVFormat.DEFAULT.withQuoteChar('\'').withCommentMarker('!').withDelimiter(';');
+ final CSVFormat format = CSVFormat.DEFAULT.withQuote('\'').withCommentMarker('!').withDelimiter(';');
final Lexer parser = getLexer(code, format);
assertThat(parser.nextToken(new Token()), matches(TOKEN, "a"));
assertThat(parser.nextToken(new Token()), matches(EORECORD, "b and ' more\n"));