From 350d34d5cfe45c4e7036422e0e2e0f6039eb6f98 Mon Sep 17 00:00:00 2001 From: "Gary D. Gregory" Date: Mon, 15 Oct 2012 03:37:34 +0000 Subject: [PATCH] Rename encapsulator to quote char. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398187 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/java/org/apache/commons/csv/CSVLexer.java | 6 +++--- src/main/java/org/apache/commons/csv/Lexer.java | 8 ++++---- src/test/java/org/apache/commons/csv/CSVLexer1306663.java | 6 +++--- src/test/java/org/apache/commons/csv/CSVLexer1306667.java | 6 +++--- src/test/java/org/apache/commons/csv/CSVLexer3.java | 2 +- src/test/resources/CSVFileParser/testCSV85_default.txt | 2 +- .../resources/CSVFileParser/testCSV85_ignoreEmpty.txt | 2 +- src/test/resources/CSVFileParser/test_default.txt | 2 +- src/test/resources/CSVFileParser/test_default_comment.txt | 2 +- src/test/resources/CSVFileParser/test_rfc4180.txt | 2 +- src/test/resources/CSVFileParser/test_rfc4180_trim.txt | 2 +- 11 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/apache/commons/csv/CSVLexer.java b/src/main/java/org/apache/commons/csv/CSVLexer.java index e5c5f6ad..609c4e6b 100644 --- a/src/main/java/org/apache/commons/csv/CSVLexer.java +++ b/src/main/java/org/apache/commons/csv/CSVLexer.java @@ -110,7 +110,7 @@ final class CSVLexer extends Lexer { // empty token return EORECORD("") // noop: tkn.content.append(""); token.type = EORECORD; - } else if (isEncapsulator(c)) { + } else if (isQuoteChar(c)) { // consume encapsulated token encapsulatedTokenLexer(token); } else if (isEndOfFile(c)) { @@ -204,8 +204,8 @@ final class CSVLexer extends Lexer { if (isEscape(c)) { tkn.content.append((char) readEscape()); - } else if (isEncapsulator(c)) { - if (isEncapsulator(in.lookAhead())) { + } else if (isQuoteChar(c)) { + if (isQuoteChar(in.lookAhead())) { // double or escaped encapsulator -> add single encapsulator to token c = in.read(); tkn.content.append((char) c); diff --git a/src/main/java/org/apache/commons/csv/Lexer.java b/src/main/java/org/apache/commons/csv/Lexer.java index fb75367a..dc303eb8 100644 --- a/src/main/java/org/apache/commons/csv/Lexer.java +++ b/src/main/java/org/apache/commons/csv/Lexer.java @@ -43,7 +43,7 @@ abstract class Lexer { private final char delimiter; private final char escape; - private final char encapsulator; + private final char quoteChar; private final char commmentStart; final boolean ignoreSurroundingSpaces; @@ -59,7 +59,7 @@ abstract class Lexer { this.in = in; this.delimiter = format.getDelimiter(); this.escape = mapNullToDisabled(format.getEscape()); - this.encapsulator = mapNullToDisabled(format.getQuoteChar()); + this.quoteChar = mapNullToDisabled(format.getQuoteChar()); this.commmentStart = mapNullToDisabled(format.getCommentStart()); this.ignoreSurroundingSpaces = format.getIgnoreSurroundingSpaces(); this.ignoreEmptyLines = format.getIgnoreEmptyLines(); @@ -153,8 +153,8 @@ abstract class Lexer { return c == escape; } - boolean isEncapsulator(final int c) { - return c == encapsulator; + boolean isQuoteChar(final int c) { + return c == quoteChar; } boolean isCommentStart(final int c) { diff --git a/src/test/java/org/apache/commons/csv/CSVLexer1306663.java b/src/test/java/org/apache/commons/csv/CSVLexer1306663.java index 460fa8d7..a40fcf89 100644 --- a/src/test/java/org/apache/commons/csv/CSVLexer1306663.java +++ b/src/test/java/org/apache/commons/csv/CSVLexer1306663.java @@ -110,7 +110,7 @@ class CSVLexer1306663 extends Lexer { // empty token return EORECORD("") //noop: tkn.content.append(""); tkn.type = EORECORD; - } else if (isEncapsulator(c)) { + } else if (isQuoteChar(c)) { // consume encapsulated token encapsulatedTokenLexer(tkn); } else if (isEndOfFile(c)) { @@ -196,8 +196,8 @@ class CSVLexer1306663 extends Lexer { if (isEscape(c)) { tkn.content.append((char) readEscape()); - } else if (isEncapsulator(c)) { - if (isEncapsulator(in.lookAhead())) { + } else if (isQuoteChar(c)) { + if (isQuoteChar(in.lookAhead())) { // double or escaped encapsulator -> add single encapsulator to token c = in.read(); tkn.content.append((char) c); diff --git a/src/test/java/org/apache/commons/csv/CSVLexer1306667.java b/src/test/java/org/apache/commons/csv/CSVLexer1306667.java index 94370b1c..53a3c3ed 100644 --- a/src/test/java/org/apache/commons/csv/CSVLexer1306667.java +++ b/src/test/java/org/apache/commons/csv/CSVLexer1306667.java @@ -110,7 +110,7 @@ class CSVLexer1306667 extends Lexer { // empty token return EORECORD("") //noop: tkn.content.append(""); tkn.type = EORECORD; - } else if (isEncapsulator(c)) { + } else if (isQuoteChar(c)) { // consume encapsulated token encapsulatedTokenLexer(tkn); } else if (isEndOfFile(c)) { @@ -196,8 +196,8 @@ class CSVLexer1306667 extends Lexer { if (isEscape(c)) { tkn.content.append((char) readEscape()); - } else if (isEncapsulator(c)) { - if (isEncapsulator(in.lookAhead())) { + } else if (isQuoteChar(c)) { + if (isQuoteChar(in.lookAhead())) { // double or escaped encapsulator -> add single encapsulator to token c = in.read(); tkn.content.append((char) c); diff --git a/src/test/java/org/apache/commons/csv/CSVLexer3.java b/src/test/java/org/apache/commons/csv/CSVLexer3.java index 2c71503c..5a25c859 100644 --- a/src/test/java/org/apache/commons/csv/CSVLexer3.java +++ b/src/test/java/org/apache/commons/csv/CSVLexer3.java @@ -64,7 +64,7 @@ class CSVLexer3 extends Lexer { if (isCommentStart(intch)) { return CharType.COMMENT_START; } - if (isEncapsulator(intch)) { + if (isQuoteChar(intch)) { return CharType.ENCAP; } if (isEscape(intch)) { diff --git a/src/test/resources/CSVFileParser/testCSV85_default.txt b/src/test/resources/CSVFileParser/testCSV85_default.txt index f8348af0..33a58848 100644 --- a/src/test/resources/CSVFileParser/testCSV85_default.txt +++ b/src/test/resources/CSVFileParser/testCSV85_default.txt @@ -1,5 +1,5 @@ testCSV85.csv CommentStart=# CheckComments -Delimiter=<,> Encapsulator=<"> CommentStart=<#> +Delimiter=<,> QuoteChar=<"> CommentStart=<#> # Comment 1 5:[a, b, c, e, f]#Comment 1 # Very Long diff --git a/src/test/resources/CSVFileParser/testCSV85_ignoreEmpty.txt b/src/test/resources/CSVFileParser/testCSV85_ignoreEmpty.txt index 43a32493..5f100822 100644 --- a/src/test/resources/CSVFileParser/testCSV85_ignoreEmpty.txt +++ b/src/test/resources/CSVFileParser/testCSV85_ignoreEmpty.txt @@ -1,5 +1,5 @@ testCSV85.csv CommentStart=# IgnoreEmpty=true CheckComments -Delimiter=<,> Encapsulator=<"> CommentStart=<#> EmptyLines:ignored +Delimiter=<,> QuoteChar=<"> CommentStart=<#> EmptyLines:ignored # Comment 1 5:[a, b, c, e, f]#Comment 1 # Very Long diff --git a/src/test/resources/CSVFileParser/test_default.txt b/src/test/resources/CSVFileParser/test_default.txt index e612fb81..1092c738 100644 --- a/src/test/resources/CSVFileParser/test_default.txt +++ b/src/test/resources/CSVFileParser/test_default.txt @@ -1,5 +1,5 @@ test.csv IgnoreEmpty=true -Delimiter=<,> Encapsulator=<"> EmptyLines:ignored +Delimiter=<,> QuoteChar=<"> EmptyLines:ignored 4:[A, B, C, D] 1:[# plain values] 4:[a, b, c, d] diff --git a/src/test/resources/CSVFileParser/test_default_comment.txt b/src/test/resources/CSVFileParser/test_default_comment.txt index 72003624..faa69266 100644 --- a/src/test/resources/CSVFileParser/test_default_comment.txt +++ b/src/test/resources/CSVFileParser/test_default_comment.txt @@ -1,5 +1,5 @@ test.csv IgnoreEmpty=true CommentStart=# -Delimiter=<,> Encapsulator=<"> CommentStart=<#> EmptyLines:ignored +Delimiter=<,> QuoteChar=<"> CommentStart=<#> EmptyLines:ignored 4:[A, B, C, D] 4:[a, b, c, d] 4:[ e , f , g, h ] diff --git a/src/test/resources/CSVFileParser/test_rfc4180.txt b/src/test/resources/CSVFileParser/test_rfc4180.txt index 9fcbf304..2a6fd158 100644 --- a/src/test/resources/CSVFileParser/test_rfc4180.txt +++ b/src/test/resources/CSVFileParser/test_rfc4180.txt @@ -1,5 +1,5 @@ test.csv -Delimiter=<,> Encapsulator=<"> +Delimiter=<,> QuoteChar=<"> 4:[A, B, C, D] 1:[# plain values] 4:[a, b, c, d] diff --git a/src/test/resources/CSVFileParser/test_rfc4180_trim.txt b/src/test/resources/CSVFileParser/test_rfc4180_trim.txt index b1e38b85..88d8b0ce 100644 --- a/src/test/resources/CSVFileParser/test_rfc4180_trim.txt +++ b/src/test/resources/CSVFileParser/test_rfc4180_trim.txt @@ -1,5 +1,5 @@ test.csv IgnoreSpaces=true -Delimiter=<,> Encapsulator=<"> SurroundingSpaces:ignored +Delimiter=<,> QuoteChar=<"> SurroundingSpaces:ignored 4:[A, B, C, D] 1:[# plain values] 4:[a, b, c, d]