Rename encapsulator to quote char.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/csv/trunk@1398187 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary D. Gregory 2012-10-15 03:37:34 +00:00
parent ddfe9df74f
commit 350d34d5cf
11 changed files with 20 additions and 20 deletions

View File

@ -110,7 +110,7 @@ final class CSVLexer extends Lexer {
// empty token return EORECORD("") // empty token return EORECORD("")
// noop: tkn.content.append(""); // noop: tkn.content.append("");
token.type = EORECORD; token.type = EORECORD;
} else if (isEncapsulator(c)) { } else if (isQuoteChar(c)) {
// consume encapsulated token // consume encapsulated token
encapsulatedTokenLexer(token); encapsulatedTokenLexer(token);
} else if (isEndOfFile(c)) { } else if (isEndOfFile(c)) {
@ -204,8 +204,8 @@ final class CSVLexer extends Lexer {
if (isEscape(c)) { if (isEscape(c)) {
tkn.content.append((char) readEscape()); tkn.content.append((char) readEscape());
} else if (isEncapsulator(c)) { } else if (isQuoteChar(c)) {
if (isEncapsulator(in.lookAhead())) { if (isQuoteChar(in.lookAhead())) {
// double or escaped encapsulator -> add single encapsulator to token // double or escaped encapsulator -> add single encapsulator to token
c = in.read(); c = in.read();
tkn.content.append((char) c); tkn.content.append((char) c);

View File

@ -43,7 +43,7 @@ abstract class Lexer {
private final char delimiter; private final char delimiter;
private final char escape; private final char escape;
private final char encapsulator; private final char quoteChar;
private final char commmentStart; private final char commmentStart;
final boolean ignoreSurroundingSpaces; final boolean ignoreSurroundingSpaces;
@ -59,7 +59,7 @@ abstract class Lexer {
this.in = in; this.in = in;
this.delimiter = format.getDelimiter(); this.delimiter = format.getDelimiter();
this.escape = mapNullToDisabled(format.getEscape()); this.escape = mapNullToDisabled(format.getEscape());
this.encapsulator = mapNullToDisabled(format.getQuoteChar()); this.quoteChar = mapNullToDisabled(format.getQuoteChar());
this.commmentStart = mapNullToDisabled(format.getCommentStart()); this.commmentStart = mapNullToDisabled(format.getCommentStart());
this.ignoreSurroundingSpaces = format.getIgnoreSurroundingSpaces(); this.ignoreSurroundingSpaces = format.getIgnoreSurroundingSpaces();
this.ignoreEmptyLines = format.getIgnoreEmptyLines(); this.ignoreEmptyLines = format.getIgnoreEmptyLines();
@ -153,8 +153,8 @@ abstract class Lexer {
return c == escape; return c == escape;
} }
boolean isEncapsulator(final int c) { boolean isQuoteChar(final int c) {
return c == encapsulator; return c == quoteChar;
} }
boolean isCommentStart(final int c) { boolean isCommentStart(final int c) {

View File

@ -110,7 +110,7 @@ class CSVLexer1306663 extends Lexer {
// empty token return EORECORD("") // empty token return EORECORD("")
//noop: tkn.content.append(""); //noop: tkn.content.append("");
tkn.type = EORECORD; tkn.type = EORECORD;
} else if (isEncapsulator(c)) { } else if (isQuoteChar(c)) {
// consume encapsulated token // consume encapsulated token
encapsulatedTokenLexer(tkn); encapsulatedTokenLexer(tkn);
} else if (isEndOfFile(c)) { } else if (isEndOfFile(c)) {
@ -196,8 +196,8 @@ class CSVLexer1306663 extends Lexer {
if (isEscape(c)) { if (isEscape(c)) {
tkn.content.append((char) readEscape()); tkn.content.append((char) readEscape());
} else if (isEncapsulator(c)) { } else if (isQuoteChar(c)) {
if (isEncapsulator(in.lookAhead())) { if (isQuoteChar(in.lookAhead())) {
// double or escaped encapsulator -> add single encapsulator to token // double or escaped encapsulator -> add single encapsulator to token
c = in.read(); c = in.read();
tkn.content.append((char) c); tkn.content.append((char) c);

View File

@ -110,7 +110,7 @@ class CSVLexer1306667 extends Lexer {
// empty token return EORECORD("") // empty token return EORECORD("")
//noop: tkn.content.append(""); //noop: tkn.content.append("");
tkn.type = EORECORD; tkn.type = EORECORD;
} else if (isEncapsulator(c)) { } else if (isQuoteChar(c)) {
// consume encapsulated token // consume encapsulated token
encapsulatedTokenLexer(tkn); encapsulatedTokenLexer(tkn);
} else if (isEndOfFile(c)) { } else if (isEndOfFile(c)) {
@ -196,8 +196,8 @@ class CSVLexer1306667 extends Lexer {
if (isEscape(c)) { if (isEscape(c)) {
tkn.content.append((char) readEscape()); tkn.content.append((char) readEscape());
} else if (isEncapsulator(c)) { } else if (isQuoteChar(c)) {
if (isEncapsulator(in.lookAhead())) { if (isQuoteChar(in.lookAhead())) {
// double or escaped encapsulator -> add single encapsulator to token // double or escaped encapsulator -> add single encapsulator to token
c = in.read(); c = in.read();
tkn.content.append((char) c); tkn.content.append((char) c);

View File

@ -64,7 +64,7 @@ class CSVLexer3 extends Lexer {
if (isCommentStart(intch)) { if (isCommentStart(intch)) {
return CharType.COMMENT_START; return CharType.COMMENT_START;
} }
if (isEncapsulator(intch)) { if (isQuoteChar(intch)) {
return CharType.ENCAP; return CharType.ENCAP;
} }
if (isEscape(intch)) { if (isEscape(intch)) {

View File

@ -1,5 +1,5 @@
testCSV85.csv CommentStart=# CheckComments testCSV85.csv CommentStart=# CheckComments
Delimiter=<,> Encapsulator=<"> CommentStart=<#> Delimiter=<,> QuoteChar=<"> CommentStart=<#>
# Comment 1 # Comment 1
5:[a, b, c, e, f]#Comment 1 5:[a, b, c, e, f]#Comment 1
# Very Long # Very Long

View File

@ -1,5 +1,5 @@
testCSV85.csv CommentStart=# IgnoreEmpty=true CheckComments testCSV85.csv CommentStart=# IgnoreEmpty=true CheckComments
Delimiter=<,> Encapsulator=<"> CommentStart=<#> EmptyLines:ignored Delimiter=<,> QuoteChar=<"> CommentStart=<#> EmptyLines:ignored
# Comment 1 # Comment 1
5:[a, b, c, e, f]#Comment 1 5:[a, b, c, e, f]#Comment 1
# Very Long # Very Long

View File

@ -1,5 +1,5 @@
test.csv IgnoreEmpty=true test.csv IgnoreEmpty=true
Delimiter=<,> Encapsulator=<"> EmptyLines:ignored Delimiter=<,> QuoteChar=<"> EmptyLines:ignored
4:[A, B, C, D] 4:[A, B, C, D]
1:[# plain values] 1:[# plain values]
4:[a, b, c, d] 4:[a, b, c, d]

View File

@ -1,5 +1,5 @@
test.csv IgnoreEmpty=true CommentStart=# 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:[a, b, c, d] 4:[a, b, c, d]
4:[ e , f , g, h ] 4:[ e , f , g, h ]

View File

@ -1,5 +1,5 @@
test.csv test.csv
Delimiter=<,> Encapsulator=<"> Delimiter=<,> QuoteChar=<">
4:[A, B, C, D] 4:[A, B, C, D]
1:[# plain values] 1:[# plain values]
4:[a, b, c, d] 4:[a, b, c, d]

View File

@ -1,5 +1,5 @@
test.csv IgnoreSpaces=true test.csv IgnoreSpaces=true
Delimiter=<,> Encapsulator=<"> SurroundingSpaces:ignored Delimiter=<,> QuoteChar=<"> SurroundingSpaces:ignored
4:[A, B, C, D] 4:[A, B, C, D]
1:[# plain values] 1:[# plain values]
4:[a, b, c, d] 4:[a, b, c, d]