It's confusing to re-use field names locally
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1533551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4be45b6dcc
commit
1d97f23c08
|
@ -948,12 +948,12 @@ public class ToStringBuilder implements Builder<String> {
|
||||||
* </code> method. Appends the class name followed by
|
* </code> method. Appends the class name followed by
|
||||||
* {@link System#identityHashCode(java.lang.Object)}.</p>
|
* {@link System#identityHashCode(java.lang.Object)}.</p>
|
||||||
*
|
*
|
||||||
* @param object the <code>Object</code> whose class name and id to output
|
* @param srcObject the <code>Object</code> whose class name and id to output
|
||||||
* @return this
|
* @return this
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
public ToStringBuilder appendAsObjectToString(final Object object) {
|
public ToStringBuilder appendAsObjectToString(final Object srcObject) {
|
||||||
ObjectUtils.identityToString(this.getStringBuffer(), object);
|
ObjectUtils.identityToString(this.getStringBuffer(), srcObject);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -247,13 +247,13 @@ public class EventListenerSupport<L> implements Serializable {
|
||||||
private void readObject(final ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
private void readObject(final ObjectInputStream objectInputStream) throws IOException, ClassNotFoundException {
|
||||||
@SuppressWarnings("unchecked") // Will throw CCE here if not correct
|
@SuppressWarnings("unchecked") // Will throw CCE here if not correct
|
||||||
final
|
final
|
||||||
L[] listeners = (L[]) objectInputStream.readObject();
|
L[] srcListeners = (L[]) objectInputStream.readObject();
|
||||||
|
|
||||||
this.listeners = new CopyOnWriteArrayList<L>(listeners);
|
this.listeners = new CopyOnWriteArrayList<L>(srcListeners);
|
||||||
|
|
||||||
@SuppressWarnings("unchecked") // Will throw CCE here if not correct
|
@SuppressWarnings("unchecked") // Will throw CCE here if not correct
|
||||||
final
|
final
|
||||||
Class<L> listenerInterface = (Class<L>) listeners.getClass().getComponentType();
|
Class<L> listenerInterface = (Class<L>) srcListeners.getClass().getComponentType();
|
||||||
|
|
||||||
initializeTransientFields(listenerInterface, Thread.currentThread().getContextClassLoader());
|
initializeTransientFields(listenerInterface, Thread.currentThread().getContextClassLoader());
|
||||||
}
|
}
|
||||||
|
|
|
@ -738,10 +738,10 @@ public class StrSubstitutor {
|
||||||
* represents a boolean flag as to whether any change occurred.
|
* represents a boolean flag as to whether any change occurred.
|
||||||
*/
|
*/
|
||||||
private int substitute(final StrBuilder buf, final int offset, final int length, List<String> priorVariables) {
|
private int substitute(final StrBuilder buf, final int offset, final int length, List<String> priorVariables) {
|
||||||
final StrMatcher prefixMatcher = getVariablePrefixMatcher();
|
final StrMatcher pfxMatcher = getVariablePrefixMatcher();
|
||||||
final StrMatcher suffixMatcher = getVariableSuffixMatcher();
|
final StrMatcher suffMatcher = getVariableSuffixMatcher();
|
||||||
final char escape = getEscapeChar();
|
final char escape = getEscapeChar();
|
||||||
final StrMatcher valueDelimiterMatcher = getValueDelimiterMatcher();
|
final StrMatcher valueDelimMatcher = getValueDelimiterMatcher();
|
||||||
final boolean substitutionInVariablesEnabled = isEnableSubstitutionInVariables();
|
final boolean substitutionInVariablesEnabled = isEnableSubstitutionInVariables();
|
||||||
|
|
||||||
final boolean top = priorVariables == null;
|
final boolean top = priorVariables == null;
|
||||||
|
@ -751,7 +751,7 @@ public class StrSubstitutor {
|
||||||
int bufEnd = offset + length;
|
int bufEnd = offset + length;
|
||||||
int pos = offset;
|
int pos = offset;
|
||||||
while (pos < bufEnd) {
|
while (pos < bufEnd) {
|
||||||
final int startMatchLen = prefixMatcher.isMatch(chars, pos, offset,
|
final int startMatchLen = pfxMatcher.isMatch(chars, pos, offset,
|
||||||
bufEnd);
|
bufEnd);
|
||||||
if (startMatchLen == 0) {
|
if (startMatchLen == 0) {
|
||||||
pos++;
|
pos++;
|
||||||
|
@ -772,7 +772,7 @@ public class StrSubstitutor {
|
||||||
int nestedVarCount = 0;
|
int nestedVarCount = 0;
|
||||||
while (pos < bufEnd) {
|
while (pos < bufEnd) {
|
||||||
if (substitutionInVariablesEnabled
|
if (substitutionInVariablesEnabled
|
||||||
&& (endMatchLen = prefixMatcher.isMatch(chars,
|
&& (endMatchLen = pfxMatcher.isMatch(chars,
|
||||||
pos, offset, bufEnd)) != 0) {
|
pos, offset, bufEnd)) != 0) {
|
||||||
// found a nested variable start
|
// found a nested variable start
|
||||||
nestedVarCount++;
|
nestedVarCount++;
|
||||||
|
@ -780,7 +780,7 @@ public class StrSubstitutor {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
endMatchLen = suffixMatcher.isMatch(chars, pos, offset,
|
endMatchLen = suffMatcher.isMatch(chars, pos, offset,
|
||||||
bufEnd);
|
bufEnd);
|
||||||
if (endMatchLen == 0) {
|
if (endMatchLen == 0) {
|
||||||
pos++;
|
pos++;
|
||||||
|
@ -801,16 +801,16 @@ public class StrSubstitutor {
|
||||||
String varName = varNameExpr;
|
String varName = varNameExpr;
|
||||||
String varDefaultValue = null;
|
String varDefaultValue = null;
|
||||||
|
|
||||||
if (valueDelimiterMatcher != null) {
|
if (valueDelimMatcher != null) {
|
||||||
final char [] varNameExprChars = varNameExpr.toCharArray();
|
final char [] varNameExprChars = varNameExpr.toCharArray();
|
||||||
int valueDelimiterMatchLen = 0;
|
int valueDelimiterMatchLen = 0;
|
||||||
for (int i = 0; i < varNameExprChars.length; i++) {
|
for (int i = 0; i < varNameExprChars.length; i++) {
|
||||||
// if there's any nested variable when nested variable substitution disabled, then stop resolving name and default value.
|
// if there's any nested variable when nested variable substitution disabled, then stop resolving name and default value.
|
||||||
if (!substitutionInVariablesEnabled
|
if (!substitutionInVariablesEnabled
|
||||||
&& prefixMatcher.isMatch(varNameExprChars, i, i, varNameExprChars.length) != 0) {
|
&& pfxMatcher.isMatch(varNameExprChars, i, i, varNameExprChars.length) != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ((valueDelimiterMatchLen = valueDelimiterMatcher.isMatch(varNameExprChars, i)) != 0) {
|
if ((valueDelimiterMatchLen = valueDelimMatcher.isMatch(varNameExprChars, i)) != 0) {
|
||||||
varName = varNameExpr.substring(0, i);
|
varName = varNameExpr.substring(0, i);
|
||||||
varDefaultValue = varNameExpr.substring(i + valueDelimiterMatchLen);
|
varDefaultValue = varNameExpr.substring(i + valueDelimiterMatchLen);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -627,30 +627,30 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
||||||
* equal to the length of the array to this method, however a subclass
|
* equal to the length of the array to this method, however a subclass
|
||||||
* may pass other values, or even an entirely different array.
|
* may pass other values, or even an entirely different array.
|
||||||
*
|
*
|
||||||
* @param chars the character array being tokenized, may be null
|
* @param srcChars the character array being tokenized, may be null
|
||||||
* @param offset the start position within the character array, must be valid
|
* @param offset the start position within the character array, must be valid
|
||||||
* @param count the number of characters to tokenize, must be valid
|
* @param count the number of characters to tokenize, must be valid
|
||||||
* @return the modifiable list of String tokens, unmodifiable if null array or zero count
|
* @return the modifiable list of String tokens, unmodifiable if null array or zero count
|
||||||
*/
|
*/
|
||||||
protected List<String> tokenize(final char[] chars, final int offset, final int count) {
|
protected List<String> tokenize(final char[] srcChars, final int offset, final int count) {
|
||||||
if (chars == null || count == 0) {
|
if (srcChars == null || count == 0) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
final StrBuilder buf = new StrBuilder();
|
final StrBuilder buf = new StrBuilder();
|
||||||
final List<String> tokens = new ArrayList<String>();
|
final List<String> tokenList = new ArrayList<String>();
|
||||||
int pos = offset;
|
int pos = offset;
|
||||||
|
|
||||||
// loop around the entire buffer
|
// loop around the entire buffer
|
||||||
while (pos >= 0 && pos < count) {
|
while (pos >= 0 && pos < count) {
|
||||||
// find next token
|
// find next token
|
||||||
pos = readNextToken(chars, pos, count, buf, tokens);
|
pos = readNextToken(srcChars, pos, count, buf, tokenList);
|
||||||
|
|
||||||
// handle case where end of string is a delimiter
|
// handle case where end of string is a delimiter
|
||||||
if (pos >= count) {
|
if (pos >= count) {
|
||||||
addToken(tokens, "");
|
addToken(tokenList, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return tokens;
|
return tokenList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -674,24 +674,24 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
||||||
/**
|
/**
|
||||||
* Reads character by character through the String to get the next token.
|
* Reads character by character through the String to get the next token.
|
||||||
*
|
*
|
||||||
* @param chars the character array being tokenized
|
* @param srcChars the character array being tokenized
|
||||||
* @param start the first character of field
|
* @param start the first character of field
|
||||||
* @param len the length of the character array being tokenized
|
* @param len the length of the character array being tokenized
|
||||||
* @param workArea a temporary work area
|
* @param workArea a temporary work area
|
||||||
* @param tokens the list of parsed tokens
|
* @param tokenList the list of parsed tokens
|
||||||
* @return the starting position of the next field (the character
|
* @return the starting position of the next field (the character
|
||||||
* immediately after the delimiter), or -1 if end of string found
|
* immediately after the delimiter), or -1 if end of string found
|
||||||
*/
|
*/
|
||||||
private int readNextToken(final char[] chars, int start, final int len, final StrBuilder workArea, final List<String> tokens) {
|
private int readNextToken(final char[] srcChars, int start, final int len, final StrBuilder workArea, final List<String> tokenList) {
|
||||||
// skip all leading whitespace, unless it is the
|
// skip all leading whitespace, unless it is the
|
||||||
// field delimiter or the quote character
|
// field delimiter or the quote character
|
||||||
while (start < len) {
|
while (start < len) {
|
||||||
final int removeLen = Math.max(
|
final int removeLen = Math.max(
|
||||||
getIgnoredMatcher().isMatch(chars, start, start, len),
|
getIgnoredMatcher().isMatch(srcChars, start, start, len),
|
||||||
getTrimmerMatcher().isMatch(chars, start, start, len));
|
getTrimmerMatcher().isMatch(srcChars, start, start, len));
|
||||||
if (removeLen == 0 ||
|
if (removeLen == 0 ||
|
||||||
getDelimiterMatcher().isMatch(chars, start, start, len) > 0 ||
|
getDelimiterMatcher().isMatch(srcChars, start, start, len) > 0 ||
|
||||||
getQuoteMatcher().isMatch(chars, start, start, len) > 0) {
|
getQuoteMatcher().isMatch(srcChars, start, start, len) > 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
start += removeLen;
|
start += removeLen;
|
||||||
|
@ -699,41 +699,41 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
||||||
|
|
||||||
// handle reaching end
|
// handle reaching end
|
||||||
if (start >= len) {
|
if (start >= len) {
|
||||||
addToken(tokens, "");
|
addToken(tokenList, "");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle empty token
|
// handle empty token
|
||||||
final int delimLen = getDelimiterMatcher().isMatch(chars, start, start, len);
|
final int delimLen = getDelimiterMatcher().isMatch(srcChars, start, start, len);
|
||||||
if (delimLen > 0) {
|
if (delimLen > 0) {
|
||||||
addToken(tokens, "");
|
addToken(tokenList, "");
|
||||||
return start + delimLen;
|
return start + delimLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle found token
|
// handle found token
|
||||||
final int quoteLen = getQuoteMatcher().isMatch(chars, start, start, len);
|
final int quoteLen = getQuoteMatcher().isMatch(srcChars, start, start, len);
|
||||||
if (quoteLen > 0) {
|
if (quoteLen > 0) {
|
||||||
return readWithQuotes(chars, start + quoteLen, len, workArea, tokens, start, quoteLen);
|
return readWithQuotes(srcChars, start + quoteLen, len, workArea, tokenList, start, quoteLen);
|
||||||
}
|
}
|
||||||
return readWithQuotes(chars, start, len, workArea, tokens, 0, 0);
|
return readWithQuotes(srcChars, start, len, workArea, tokenList, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a possibly quoted string token.
|
* Reads a possibly quoted string token.
|
||||||
*
|
*
|
||||||
* @param chars the character array being tokenized
|
* @param srcChars the character array being tokenized
|
||||||
* @param start the first character of field
|
* @param start the first character of field
|
||||||
* @param len the length of the character array being tokenized
|
* @param len the length of the character array being tokenized
|
||||||
* @param workArea a temporary work area
|
* @param workArea a temporary work area
|
||||||
* @param tokens the list of parsed tokens
|
* @param tokenList the list of parsed tokens
|
||||||
* @param quoteStart the start position of the matched quote, 0 if no quoting
|
* @param quoteStart the start position of the matched quote, 0 if no quoting
|
||||||
* @param quoteLen the length of the matched quote, 0 if no quoting
|
* @param quoteLen the length of the matched quote, 0 if no quoting
|
||||||
* @return the starting position of the next field (the character
|
* @return the starting position of the next field (the character
|
||||||
* immediately after the delimiter, or if end of string found,
|
* immediately after the delimiter, or if end of string found,
|
||||||
* then the length of string
|
* then the length of string
|
||||||
*/
|
*/
|
||||||
private int readWithQuotes(final char[] chars, final int start, final int len, final StrBuilder workArea,
|
private int readWithQuotes(final char[] srcChars, final int start, final int len, final StrBuilder workArea,
|
||||||
final List<String> tokens, final int quoteStart, final int quoteLen) {
|
final List<String> tokenList, final int quoteStart, final int quoteLen) {
|
||||||
// Loop until we've found the end of the quoted
|
// Loop until we've found the end of the quoted
|
||||||
// string or the end of the input
|
// string or the end of the input
|
||||||
workArea.clear();
|
workArea.clear();
|
||||||
|
@ -752,10 +752,10 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
||||||
// followed by a second quote. If so, then we need
|
// followed by a second quote. If so, then we need
|
||||||
// to actually put the quote character into the token
|
// to actually put the quote character into the token
|
||||||
// rather than end the token.
|
// rather than end the token.
|
||||||
if (isQuote(chars, pos, len, quoteStart, quoteLen)) {
|
if (isQuote(srcChars, pos, len, quoteStart, quoteLen)) {
|
||||||
if (isQuote(chars, pos + quoteLen, len, quoteStart, quoteLen)) {
|
if (isQuote(srcChars, pos + quoteLen, len, quoteStart, quoteLen)) {
|
||||||
// matched pair of quotes, thus an escaped quote
|
// matched pair of quotes, thus an escaped quote
|
||||||
workArea.append(chars, pos, quoteLen);
|
workArea.append(srcChars, pos, quoteLen);
|
||||||
pos += quoteLen * 2;
|
pos += quoteLen * 2;
|
||||||
trimStart = workArea.size();
|
trimStart = workArea.size();
|
||||||
continue;
|
continue;
|
||||||
|
@ -768,29 +768,29 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy regular character from inside quotes
|
// copy regular character from inside quotes
|
||||||
workArea.append(chars[pos++]);
|
workArea.append(srcChars[pos++]);
|
||||||
trimStart = workArea.size();
|
trimStart = workArea.size();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Not in quoting mode
|
// Not in quoting mode
|
||||||
|
|
||||||
// check for delimiter, and thus end of token
|
// check for delimiter, and thus end of token
|
||||||
final int delimLen = getDelimiterMatcher().isMatch(chars, pos, start, len);
|
final int delimLen = getDelimiterMatcher().isMatch(srcChars, 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(tokenList, workArea.substring(0, trimStart));
|
||||||
return pos + delimLen;
|
return pos + delimLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for quote, and thus back into quoting mode
|
// check for quote, and thus back into quoting mode
|
||||||
if (quoteLen > 0 && isQuote(chars, pos, len, quoteStart, quoteLen)) {
|
if (quoteLen > 0 && isQuote(srcChars, pos, len, quoteStart, quoteLen)) {
|
||||||
quoting = true;
|
quoting = true;
|
||||||
pos += quoteLen;
|
pos += quoteLen;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for ignored (outside quotes), and ignore
|
// check for ignored (outside quotes), and ignore
|
||||||
final int ignoredLen = getIgnoredMatcher().isMatch(chars, pos, start, len);
|
final int ignoredLen = getIgnoredMatcher().isMatch(srcChars, pos, start, len);
|
||||||
if (ignoredLen > 0) {
|
if (ignoredLen > 0) {
|
||||||
pos += ignoredLen;
|
pos += ignoredLen;
|
||||||
continue;
|
continue;
|
||||||
|
@ -799,21 +799,21 @@ public class StrTokenizer implements ListIterator<String>, 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
|
||||||
final int trimmedLen = getTrimmerMatcher().isMatch(chars, pos, start, len);
|
final int trimmedLen = getTrimmerMatcher().isMatch(srcChars, pos, start, len);
|
||||||
if (trimmedLen > 0) {
|
if (trimmedLen > 0) {
|
||||||
workArea.append(chars, pos, trimmedLen);
|
workArea.append(srcChars, pos, trimmedLen);
|
||||||
pos += trimmedLen;
|
pos += trimmedLen;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy regular character from outside quotes
|
// copy regular character from outside quotes
|
||||||
workArea.append(chars[pos++]);
|
workArea.append(srcChars[pos++]);
|
||||||
trimStart = workArea.size();
|
trimStart = workArea.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// return condition when end of string found
|
// return condition when end of string found
|
||||||
addToken(tokens, workArea.substring(0, trimStart));
|
addToken(tokenList, workArea.substring(0, trimStart));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -821,16 +821,16 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
|
||||||
* Checks if the characters at the index specified match the quote
|
* Checks if the characters at the index specified match the quote
|
||||||
* already matched in readNextToken().
|
* already matched in readNextToken().
|
||||||
*
|
*
|
||||||
* @param chars the character array being tokenized
|
* @param srcChars the character array being tokenized
|
||||||
* @param pos the position to check for a quote
|
* @param pos the position to check for a quote
|
||||||
* @param len the length of the character array being tokenized
|
* @param len the length of the character array being tokenized
|
||||||
* @param quoteStart the start position of the matched quote, 0 if no quoting
|
* @param quoteStart the start position of the matched quote, 0 if no quoting
|
||||||
* @param quoteLen the length of the matched quote, 0 if no quoting
|
* @param quoteLen the length of the matched quote, 0 if no quoting
|
||||||
* @return true if a quote is matched
|
* @return true if a quote is matched
|
||||||
*/
|
*/
|
||||||
private boolean isQuote(final char[] chars, final int pos, final int len, final int quoteStart, final int quoteLen) {
|
private boolean isQuote(final char[] srcChars, final int pos, final int len, final int quoteStart, final int quoteLen) {
|
||||||
for (int i = 0; i < quoteLen; i++) {
|
for (int i = 0; i < quoteLen; i++) {
|
||||||
if (pos + i >= len || chars[pos + i] != chars[quoteStart + i]) {
|
if (pos + i >= len || srcChars[pos + i] != srcChars[quoteStart + i]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue