tiny simplifications regarding usage of Iterator
This commit is contained in:
committed by
Juergen Hoeller
parent
8f972a5a60
commit
4cc7b9b9fc
@@ -21,7 +21,6 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
@@ -230,9 +229,8 @@ public class BatchSqlUpdate extends SqlUpdate {
|
||||
*/
|
||||
public int[] getRowsAffected() {
|
||||
int[] result = new int[this.rowsAffected.size()];
|
||||
int i = 0;
|
||||
for (Iterator<Integer> it = this.rowsAffected.iterator(); it.hasNext(); i++) {
|
||||
result[i] = it.next();
|
||||
for (int i = 0; i < this.rowsAffected.size(); i++) {
|
||||
result[i] = this.rowsAffected.get(i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -390,7 +390,7 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
result.append(UriUtils.encodePathSegment(value.toString(), encodingScheme));
|
||||
endLastMatch = matcher.end();
|
||||
}
|
||||
result.append(targetUrl.substring(endLastMatch, targetUrl.length()));
|
||||
result.append(targetUrl.substring(endLastMatch));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -456,18 +456,17 @@ public class RedirectView extends AbstractUrlBasedView implements SmartView {
|
||||
boolean first = (targetUrl.toString().indexOf('?') < 0);
|
||||
for (Map.Entry<String, Object> entry : queryProperties(model).entrySet()) {
|
||||
Object rawValue = entry.getValue();
|
||||
Iterator<Object> valueIter;
|
||||
Collection<Object> values;
|
||||
if (rawValue != null && rawValue.getClass().isArray()) {
|
||||
valueIter = Arrays.asList(ObjectUtils.toObjectArray(rawValue)).iterator();
|
||||
values = Arrays.asList(ObjectUtils.toObjectArray(rawValue));
|
||||
}
|
||||
else if (rawValue instanceof Collection) {
|
||||
valueIter = ((Collection<Object>) rawValue).iterator();
|
||||
values = ((Collection<Object>) rawValue);
|
||||
}
|
||||
else {
|
||||
valueIter = Collections.singleton(rawValue).iterator();
|
||||
values = Collections.singleton(rawValue);
|
||||
}
|
||||
while (valueIter.hasNext()) {
|
||||
Object value = valueIter.next();
|
||||
for (Object value : values) {
|
||||
if (first) {
|
||||
targetUrl.append('?');
|
||||
first = false;
|
||||
|
||||
Reference in New Issue
Block a user