Improve unit test coverage, eating own dog food. TODO: Missing tests for many constructors.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@234385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0d0b5165e9
commit
b71a6cd002
|
@ -115,13 +115,13 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
private int tokenPos;
|
private int tokenPos;
|
||||||
|
|
||||||
/** The delimiter matcher */
|
/** The delimiter matcher */
|
||||||
private StrMatcher delim = StrMatcher.splitMatcher();
|
private StrMatcher delimMatcher = StrMatcher.splitMatcher();
|
||||||
/** The quote matcher */
|
/** The quote matcher */
|
||||||
private StrMatcher quote = StrMatcher.noneMatcher();
|
private StrMatcher quoteMatcher = StrMatcher.noneMatcher();
|
||||||
/** The ignored matcher */
|
/** The ignored matcher */
|
||||||
private StrMatcher ignored = StrMatcher.noneMatcher();
|
private StrMatcher ignoredMatcher = StrMatcher.noneMatcher();
|
||||||
/** The trimmer matcher */
|
/** The trimmer matcher */
|
||||||
private StrMatcher trimmer = StrMatcher.noneMatcher();
|
private StrMatcher trimmerMatcher = StrMatcher.noneMatcher();
|
||||||
|
|
||||||
/** Whether to return empty tokens as null */
|
/** Whether to return empty tokens as null */
|
||||||
private boolean emptyAsNull = false;
|
private boolean emptyAsNull = false;
|
||||||
|
@ -643,10 +643,10 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
*/
|
*/
|
||||||
private void addToken(List list, String tok) {
|
private void addToken(List list, String tok) {
|
||||||
if (tok == null || tok.length() == 0) {
|
if (tok == null || tok.length() == 0) {
|
||||||
if (ignoreEmptyTokens) {
|
if (this.isIgnoreEmptyTokens()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (emptyAsNull) {
|
if (this.isEmptyTokenAsNull()) {
|
||||||
tok = null;
|
tok = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -669,11 +669,11 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
// field delimiter or the quote character
|
// field delimiter or the quote character
|
||||||
while (start < len) {
|
while (start < len) {
|
||||||
int removeLen = Math.max(
|
int removeLen = Math.max(
|
||||||
ignored.isMatch(chars, start, start, len),
|
this.getIgnoredMatcher().isMatch(chars, start, start, len),
|
||||||
trimmer.isMatch(chars, start, start, len));
|
this.getTrimmerMatcher().isMatch(chars, start, start, len));
|
||||||
if (removeLen == 0 ||
|
if (removeLen == 0 ||
|
||||||
delim.isMatch(chars, start, start, len) > 0 ||
|
this.getDelimiterMatcher().isMatch(chars, start, start, len) > 0 ||
|
||||||
quote.isMatch(chars, start, start, len) > 0) {
|
this.getQuoteMatcher().isMatch(chars, start, start, len) > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
start += removeLen;
|
start += removeLen;
|
||||||
|
@ -686,14 +686,14 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle empty token
|
// handle empty token
|
||||||
int delimLen = delim.isMatch(chars, start, start, len);
|
int delimLen = this.getDelimiterMatcher().isMatch(chars, start, start, len);
|
||||||
if (delimLen > 0) {
|
if (delimLen > 0) {
|
||||||
addToken(tokens, "");
|
addToken(tokens, "");
|
||||||
return start + delimLen;
|
return start + delimLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle found token
|
// handle found token
|
||||||
int quoteLen = quote.isMatch(chars, start, start, len);
|
int quoteLen = this.getQuoteMatcher().isMatch(chars, start, start, len);
|
||||||
if (quoteLen > 0) {
|
if (quoteLen > 0) {
|
||||||
return readWithQuotes(chars, start + quoteLen, len, workArea, tokens, start, quoteLen);
|
return readWithQuotes(chars, start + quoteLen, len, workArea, tokens, start, quoteLen);
|
||||||
}
|
}
|
||||||
|
@ -756,7 +756,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
// Not in quoting mode
|
// Not in quoting mode
|
||||||
|
|
||||||
// check for delimiter, and thus end of token
|
// check for delimiter, and thus end of token
|
||||||
int delimLen = delim.isMatch(chars, pos, start, len);
|
int delimLen = this.getDelimiterMatcher().isMatch(chars, pos, start, len);
|
||||||
if (delimLen > 0) {
|
if (delimLen > 0) {
|
||||||
// return condition when end of token found
|
// return condition when end of token found
|
||||||
addToken(tokens, workArea.substring(0, trimStart));
|
addToken(tokens, workArea.substring(0, trimStart));
|
||||||
|
@ -773,7 +773,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for ignored (outside quotes), and ignore
|
// check for ignored (outside quotes), and ignore
|
||||||
int ignoredLen = ignored.isMatch(chars, pos, start, len);
|
int ignoredLen = this.getIgnoredMatcher().isMatch(chars, pos, start, len);
|
||||||
if (ignoredLen > 0) {
|
if (ignoredLen > 0) {
|
||||||
pos += ignoredLen;
|
pos += ignoredLen;
|
||||||
continue;
|
continue;
|
||||||
|
@ -782,7 +782,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
// check for trimmed character
|
// check for trimmed character
|
||||||
// don't yet know if its at the end, so copy to workArea
|
// don't yet know if its at the end, so copy to workArea
|
||||||
// use trimStart to keep track of trim at the end
|
// use trimStart to keep track of trim at the end
|
||||||
int trimmedLen = trimmer.isMatch(chars, pos, start, len);
|
int trimmedLen = this.getTrimmerMatcher().isMatch(chars, pos, start, len);
|
||||||
if (trimmedLen > 0) {
|
if (trimmedLen > 0) {
|
||||||
workArea.append(chars, pos, trimmedLen);
|
workArea.append(chars, pos, trimmedLen);
|
||||||
pos += trimmedLen;
|
pos += trimmedLen;
|
||||||
|
@ -828,7 +828,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @return the delimiter matcher in use
|
* @return the delimiter matcher in use
|
||||||
*/
|
*/
|
||||||
public StrMatcher getDelimiterMatcher() {
|
public StrMatcher getDelimiterMatcher() {
|
||||||
return delim;
|
return this.delimMatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -841,9 +841,9 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
*/
|
*/
|
||||||
public StrTokenizer setDelimiterMatcher(StrMatcher delim) {
|
public StrTokenizer setDelimiterMatcher(StrMatcher delim) {
|
||||||
if (delim == null) {
|
if (delim == null) {
|
||||||
this.delim = StrMatcher.noneMatcher();
|
this.delimMatcher = StrMatcher.noneMatcher();
|
||||||
} else {
|
} else {
|
||||||
this.delim = delim;
|
this.delimMatcher = delim;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -880,7 +880,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @return the quote matcher in use
|
* @return the quote matcher in use
|
||||||
*/
|
*/
|
||||||
public StrMatcher getQuoteMatcher() {
|
public StrMatcher getQuoteMatcher() {
|
||||||
return quote;
|
return quoteMatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -894,7 +894,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
*/
|
*/
|
||||||
public StrTokenizer setQuoteMatcher(StrMatcher quote) {
|
public StrTokenizer setQuoteMatcher(StrMatcher quote) {
|
||||||
if (quote != null) {
|
if (quote != null) {
|
||||||
this.quote = quote;
|
this.quoteMatcher = quote;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -924,7 +924,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @return the ignored matcher in use
|
* @return the ignored matcher in use
|
||||||
*/
|
*/
|
||||||
public StrMatcher getIgnoredMatcher() {
|
public StrMatcher getIgnoredMatcher() {
|
||||||
return ignored;
|
return ignoredMatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -938,7 +938,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
*/
|
*/
|
||||||
public StrTokenizer setIgnoredMatcher(StrMatcher ignored) {
|
public StrTokenizer setIgnoredMatcher(StrMatcher ignored) {
|
||||||
if (ignored != null) {
|
if (ignored != null) {
|
||||||
this.ignored = ignored;
|
this.ignoredMatcher = ignored;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -968,7 +968,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @return the trimmer matcher in use
|
* @return the trimmer matcher in use
|
||||||
*/
|
*/
|
||||||
public StrMatcher getTrimmerMatcher() {
|
public StrMatcher getTrimmerMatcher() {
|
||||||
return trimmer;
|
return trimmerMatcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -982,7 +982,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
*/
|
*/
|
||||||
public StrTokenizer setTrimmerMatcher(StrMatcher trimmer) {
|
public StrTokenizer setTrimmerMatcher(StrMatcher trimmer) {
|
||||||
if (trimmer != null) {
|
if (trimmer != null) {
|
||||||
this.trimmer = trimmer;
|
this.trimmerMatcher = trimmer;
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -995,7 +995,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @return true if empty tokens are returned as null
|
* @return true if empty tokens are returned as null
|
||||||
*/
|
*/
|
||||||
public boolean isEmptyTokenAsNull() {
|
public boolean isEmptyTokenAsNull() {
|
||||||
return emptyAsNull;
|
return this.emptyAsNull;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue