Genericize
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@754686 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c06b74202d
commit
f3a2199a83
|
@ -946,9 +946,9 @@ public class StrBuilder {
|
||||||
* @return this, to enable chaining
|
* @return this, to enable chaining
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
public StrBuilder appendAll(Collection coll) {
|
public StrBuilder appendAll(Collection<?> coll) {
|
||||||
if (coll != null && coll.size() > 0) {
|
if (coll != null && coll.size() > 0) {
|
||||||
Iterator it = coll.iterator();
|
Iterator<?> it = coll.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
append(it.next());
|
append(it.next());
|
||||||
}
|
}
|
||||||
|
@ -965,7 +965,7 @@ public class StrBuilder {
|
||||||
* @return this, to enable chaining
|
* @return this, to enable chaining
|
||||||
* @since 2.3
|
* @since 2.3
|
||||||
*/
|
*/
|
||||||
public StrBuilder appendAll(Iterator it) {
|
public StrBuilder appendAll(Iterator<?> it) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
append(it.next());
|
append(it.next());
|
||||||
|
@ -1007,10 +1007,10 @@ public class StrBuilder {
|
||||||
* @param separator the separator to use, null means no separator
|
* @param separator the separator to use, null means no separator
|
||||||
* @return this, to enable chaining
|
* @return this, to enable chaining
|
||||||
*/
|
*/
|
||||||
public StrBuilder appendWithSeparators(Collection coll, String separator) {
|
public StrBuilder appendWithSeparators(Collection<?> coll, String separator) {
|
||||||
if (coll != null && coll.size() > 0) {
|
if (coll != null && coll.size() > 0) {
|
||||||
separator = (separator == null ? "" : separator);
|
separator = (separator == null ? "" : separator);
|
||||||
Iterator it = coll.iterator();
|
Iterator<?> it = coll.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
append(it.next());
|
append(it.next());
|
||||||
if (it.hasNext()) {
|
if (it.hasNext()) {
|
||||||
|
@ -1031,7 +1031,7 @@ public class StrBuilder {
|
||||||
* @param separator the separator to use, null means no separator
|
* @param separator the separator to use, null means no separator
|
||||||
* @return this, to enable chaining
|
* @return this, to enable chaining
|
||||||
*/
|
*/
|
||||||
public StrBuilder appendWithSeparators(Iterator it, String separator) {
|
public StrBuilder appendWithSeparators(Iterator<?> it, String separator) {
|
||||||
if (it != null) {
|
if (it != null) {
|
||||||
separator = (separator == null ? "" : separator);
|
separator = (separator == null ? "" : separator);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
|
@ -1292,6 +1292,7 @@ public class StrBuilder {
|
||||||
* @return this, to enable chaining
|
* @return this, to enable chaining
|
||||||
* @throws IndexOutOfBoundsException if the index is invalid
|
* @throws IndexOutOfBoundsException if the index is invalid
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("null") // str cannot be null
|
||||||
public StrBuilder insert(int index, String str) {
|
public StrBuilder insert(int index, String str) {
|
||||||
validateIndex(index);
|
validateIndex(index);
|
||||||
if (str == null) {
|
if (str == null) {
|
||||||
|
@ -1303,7 +1304,7 @@ public class StrBuilder {
|
||||||
ensureCapacity(newSize);
|
ensureCapacity(newSize);
|
||||||
System.arraycopy(buffer, index, buffer, index + strLen, size - index);
|
System.arraycopy(buffer, index, buffer, index + strLen, size - index);
|
||||||
size = newSize;
|
size = newSize;
|
||||||
str.getChars(0, strLen, buffer, index);
|
str.getChars(0, strLen, buffer, index); // str cannot be null here
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -2576,7 +2577,7 @@ public class StrBuilder {
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
protected List tokenize(char[] chars, int offset, int count) {
|
protected List<String> tokenize(char[] chars, int offset, int count) {
|
||||||
if (chars == null) {
|
if (chars == null) {
|
||||||
return super.tokenize(StrBuilder.this.buffer, 0, StrBuilder.this.size());
|
return super.tokenize(StrBuilder.this.buffer, 0, StrBuilder.this.size());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -455,9 +455,9 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
*
|
*
|
||||||
* @return the tokens as a String array
|
* @return the tokens as a String array
|
||||||
*/
|
*/
|
||||||
public List getTokenList() {
|
public List<String> getTokenList() {
|
||||||
checkTokenized();
|
checkTokenized();
|
||||||
List list = new ArrayList(tokens.length);
|
List<String> list = new ArrayList<String>(tokens.length);
|
||||||
for (int i = 0; i < tokens.length; i++) {
|
for (int i = 0; i < tokens.length; i++) {
|
||||||
list.add(tokens[i]);
|
list.add(tokens[i]);
|
||||||
}
|
}
|
||||||
|
@ -612,11 +612,11 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
if (tokens == null) {
|
if (tokens == null) {
|
||||||
if (chars == null) {
|
if (chars == null) {
|
||||||
// still call tokenize as subclass may do some work
|
// still call tokenize as subclass may do some work
|
||||||
List split = tokenize(null, 0, 0);
|
List<String> split = tokenize(null, 0, 0);
|
||||||
tokens = (String[]) split.toArray(new String[split.size()]);
|
tokens = split.toArray(new String[split.size()]);
|
||||||
} else {
|
} else {
|
||||||
List split = tokenize(chars, 0, chars.length);
|
List<String> split = tokenize(chars, 0, chars.length);
|
||||||
tokens = (String[]) split.toArray(new String[split.size()]);
|
tokens = split.toArray(new String[split.size()]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -641,12 +641,12 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @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 tokenize(char[] chars, int offset, int count) {
|
protected List<String> tokenize(char[] chars, int offset, int count) {
|
||||||
if (chars == null || count == 0) {
|
if (chars == null || count == 0) {
|
||||||
return Collections.EMPTY_LIST;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
StrBuilder buf = new StrBuilder();
|
StrBuilder buf = new StrBuilder();
|
||||||
List tokens = new ArrayList();
|
List<String> tokens = new ArrayList<String>();
|
||||||
int pos = offset;
|
int pos = offset;
|
||||||
|
|
||||||
// loop around the entire buffer
|
// loop around the entire buffer
|
||||||
|
@ -668,7 +668,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @param list the list to add to
|
* @param list the list to add to
|
||||||
* @param tok the token to add
|
* @param tok the token to add
|
||||||
*/
|
*/
|
||||||
private void addToken(List list, String tok) {
|
private void addToken(List<String> list, String tok) {
|
||||||
if (tok == null || tok.length() == 0) {
|
if (tok == null || tok.length() == 0) {
|
||||||
if (isIgnoreEmptyTokens()) {
|
if (isIgnoreEmptyTokens()) {
|
||||||
return;
|
return;
|
||||||
|
@ -691,7 +691,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* @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(char[] chars, int start, int len, StrBuilder workArea, List tokens) {
|
private int readNextToken(char[] chars, int start, int len, StrBuilder workArea, List<String> tokens) {
|
||||||
// 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) {
|
||||||
|
@ -742,7 +742,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
|
||||||
* then the length of string
|
* then the length of string
|
||||||
*/
|
*/
|
||||||
private int readWithQuotes(char[] chars, int start, int len, StrBuilder workArea,
|
private int readWithQuotes(char[] chars, int start, int len, StrBuilder workArea,
|
||||||
List tokens, int quoteStart, int quoteLen)
|
List<String> tokens, int quoteStart, 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
|
||||||
|
|
Loading…
Reference in New Issue