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:
Sebastian Bazley 2009-03-15 16:27:34 +00:00
parent c06b74202d
commit f3a2199a83
2 changed files with 21 additions and 20 deletions

View File

@ -946,9 +946,9 @@ public class StrBuilder {
* @return this, to enable chaining
* @since 2.3
*/
public StrBuilder appendAll(Collection coll) {
public StrBuilder appendAll(Collection<?> coll) {
if (coll != null && coll.size() > 0) {
Iterator it = coll.iterator();
Iterator<?> it = coll.iterator();
while (it.hasNext()) {
append(it.next());
}
@ -965,7 +965,7 @@ public class StrBuilder {
* @return this, to enable chaining
* @since 2.3
*/
public StrBuilder appendAll(Iterator it) {
public StrBuilder appendAll(Iterator<?> it) {
if (it != null) {
while (it.hasNext()) {
append(it.next());
@ -1007,10 +1007,10 @@ public class StrBuilder {
* @param separator the separator to use, null means no separator
* @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) {
separator = (separator == null ? "" : separator);
Iterator it = coll.iterator();
Iterator<?> it = coll.iterator();
while (it.hasNext()) {
append(it.next());
if (it.hasNext()) {
@ -1031,7 +1031,7 @@ public class StrBuilder {
* @param separator the separator to use, null means no separator
* @return this, to enable chaining
*/
public StrBuilder appendWithSeparators(Iterator it, String separator) {
public StrBuilder appendWithSeparators(Iterator<?> it, String separator) {
if (it != null) {
separator = (separator == null ? "" : separator);
while (it.hasNext()) {
@ -1292,6 +1292,7 @@ public class StrBuilder {
* @return this, to enable chaining
* @throws IndexOutOfBoundsException if the index is invalid
*/
@SuppressWarnings("null") // str cannot be null
public StrBuilder insert(int index, String str) {
validateIndex(index);
if (str == null) {
@ -1303,7 +1304,7 @@ public class StrBuilder {
ensureCapacity(newSize);
System.arraycopy(buffer, index, buffer, index + strLen, size - index);
size = newSize;
str.getChars(0, strLen, buffer, index);
str.getChars(0, strLen, buffer, index); // str cannot be null here
}
return this;
}
@ -2576,7 +2577,7 @@ public class StrBuilder {
/** {@inheritDoc} */
@Override
protected List tokenize(char[] chars, int offset, int count) {
protected List<String> tokenize(char[] chars, int offset, int count) {
if (chars == null) {
return super.tokenize(StrBuilder.this.buffer, 0, StrBuilder.this.size());
} else {

View File

@ -455,9 +455,9 @@ public class StrTokenizer implements ListIterator, Cloneable {
*
* @return the tokens as a String array
*/
public List getTokenList() {
public List<String> getTokenList() {
checkTokenized();
List list = new ArrayList(tokens.length);
List<String> list = new ArrayList<String>(tokens.length);
for (int i = 0; i < tokens.length; i++) {
list.add(tokens[i]);
}
@ -612,11 +612,11 @@ public class StrTokenizer implements ListIterator, Cloneable {
if (tokens == null) {
if (chars == null) {
// still call tokenize as subclass may do some work
List split = tokenize(null, 0, 0);
tokens = (String[]) split.toArray(new String[split.size()]);
List<String> split = tokenize(null, 0, 0);
tokens = split.toArray(new String[split.size()]);
} else {
List split = tokenize(chars, 0, chars.length);
tokens = (String[]) split.toArray(new String[split.size()]);
List<String> split = tokenize(chars, 0, chars.length);
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
* @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) {
return Collections.EMPTY_LIST;
return Collections.emptyList();
}
StrBuilder buf = new StrBuilder();
List tokens = new ArrayList();
List<String> tokens = new ArrayList<String>();
int pos = offset;
// loop around the entire buffer
@ -668,7 +668,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
* @param list the list to add to
* @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 (isIgnoreEmptyTokens()) {
return;
@ -691,7 +691,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
* @return the starting position of the next field (the character
* 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
// field delimiter or the quote character
while (start < len) {
@ -742,7 +742,7 @@ public class StrTokenizer implements ListIterator, Cloneable {
* then the length of string
*/
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
// string or the end of the input