Java 5 code style
This commit is contained in:
@@ -143,8 +143,8 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
|
||||
if (codes == null) {
|
||||
codes = new String[0];
|
||||
}
|
||||
for (int i = 0; i < codes.length; i++) {
|
||||
String msg = getMessageInternal(codes[i], resolvable.getArguments(), locale);
|
||||
for (String code : codes) {
|
||||
String msg = getMessageInternal(code, resolvable.getArguments(), locale);
|
||||
if (msg != null) {
|
||||
return msg;
|
||||
}
|
||||
@@ -291,13 +291,13 @@ public abstract class AbstractMessageSource extends MessageSourceSupport impleme
|
||||
if (args == null) {
|
||||
return new Object[0];
|
||||
}
|
||||
List resolvedArgs = new ArrayList(args.length);
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
if (args[i] instanceof MessageSourceResolvable) {
|
||||
resolvedArgs.add(getMessage((MessageSourceResolvable) args[i], locale));
|
||||
List<Object> resolvedArgs = new ArrayList<Object>(args.length);
|
||||
for (Object arg : args) {
|
||||
if (arg instanceof MessageSourceResolvable) {
|
||||
resolvedArgs.add(getMessage((MessageSourceResolvable) arg, locale));
|
||||
}
|
||||
else {
|
||||
resolvedArgs.add(args[i]);
|
||||
resolvedArgs.add(arg);
|
||||
}
|
||||
}
|
||||
return resolvedArgs.toArray(new Object[resolvedArgs.size()]);
|
||||
|
||||
@@ -16,10 +16,9 @@
|
||||
|
||||
package org.springframework.jmx.support;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.NotificationFilter;
|
||||
import javax.management.NotificationListener;
|
||||
@@ -46,7 +45,7 @@ public class NotificationListenerHolder {
|
||||
|
||||
private Object handback;
|
||||
|
||||
protected Set mappedObjectNames;
|
||||
protected Set<Object> mappedObjectNames;
|
||||
|
||||
|
||||
/**
|
||||
@@ -122,15 +121,8 @@ public class NotificationListenerHolder {
|
||||
* @see #setMappedObjectName
|
||||
*/
|
||||
public void setMappedObjectNames(Object[] mappedObjectNames) {
|
||||
if (mappedObjectNames != null) {
|
||||
this.mappedObjectNames = new LinkedHashSet(mappedObjectNames.length);
|
||||
for (int i = 0; i < mappedObjectNames.length; i++) {
|
||||
this.mappedObjectNames.add(mappedObjectNames[i]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.mappedObjectNames = null;
|
||||
}
|
||||
this.mappedObjectNames = (mappedObjectNames != null ?
|
||||
new LinkedHashSet<Object>(Arrays.asList(mappedObjectNames)) : null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,8 +137,8 @@ public class NotificationListenerHolder {
|
||||
}
|
||||
ObjectName[] resolved = new ObjectName[this.mappedObjectNames.size()];
|
||||
int i = 0;
|
||||
for (Iterator it = this.mappedObjectNames.iterator(); it.hasNext();) {
|
||||
resolved[i] = ObjectNameManager.getInstance(it.next());
|
||||
for (Object objectName : this.mappedObjectNames) {
|
||||
resolved[i] = ObjectNameManager.getInstance(objectName);
|
||||
i++;
|
||||
}
|
||||
return resolved;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2007 the original author or authors.
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,7 +45,7 @@ public abstract class RemoteInvocationUtils {
|
||||
public static void fillInClientStackTraceIfPossible(Throwable ex) {
|
||||
if (ex != null) {
|
||||
StackTraceElement[] clientStack = new Throwable().getStackTrace();
|
||||
Set visitedExceptions = new HashSet();
|
||||
Set<Throwable> visitedExceptions = new HashSet<Throwable>();
|
||||
Throwable exToUpdate = ex;
|
||||
while (exToUpdate != null && !visitedExceptions.contains(exToUpdate)) {
|
||||
StackTraceElement[] serverStack = exToUpdate.getStackTrace();
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.validation;
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.EmptyStackException;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
@@ -38,7 +37,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
|
||||
private String nestedPath = "";
|
||||
|
||||
private final Stack nestedPathStack = new Stack();
|
||||
private final Stack<String> nestedPathStack = new Stack<String>();
|
||||
|
||||
|
||||
public void setNestedPath(String nestedPath) {
|
||||
@@ -57,7 +56,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
|
||||
public void popNestedPath() throws IllegalArgumentException {
|
||||
try {
|
||||
String formerNestedPath = (String) this.nestedPathStack.pop();
|
||||
String formerNestedPath = this.nestedPathStack.pop();
|
||||
doSetNestedPath(formerNestedPath);
|
||||
}
|
||||
catch (EmptyStackException ex) {
|
||||
@@ -131,8 +130,8 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
return getAllErrors().size();
|
||||
}
|
||||
|
||||
public List getAllErrors() {
|
||||
List result = new LinkedList();
|
||||
public List<ObjectError> getAllErrors() {
|
||||
List<ObjectError> result = new LinkedList<ObjectError>();
|
||||
result.addAll(getGlobalErrors());
|
||||
result.addAll(getFieldErrors());
|
||||
return Collections.unmodifiableList(result);
|
||||
@@ -172,13 +171,12 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
return getFieldErrors(field).size();
|
||||
}
|
||||
|
||||
public List getFieldErrors(String field) {
|
||||
List fieldErrors = getFieldErrors();
|
||||
List result = new LinkedList();
|
||||
public List<FieldError> getFieldErrors(String field) {
|
||||
List<FieldError> fieldErrors = getFieldErrors();
|
||||
List<FieldError> result = new LinkedList<FieldError>();
|
||||
String fixedField = fixedField(field);
|
||||
for (Iterator it = fieldErrors.iterator(); it.hasNext();) {
|
||||
Object error = it.next();
|
||||
if (isMatchingFieldError(fixedField, (FieldError) error)) {
|
||||
for (FieldError error : fieldErrors) {
|
||||
if (isMatchingFieldError(fixedField, error)) {
|
||||
result.add(error);
|
||||
}
|
||||
}
|
||||
@@ -198,6 +196,7 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the given FieldError matches the given field.
|
||||
* @param field the field that we are looking up FieldErrors for
|
||||
@@ -214,9 +213,8 @@ public abstract class AbstractErrors implements Errors, Serializable {
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder(getClass().getName());
|
||||
sb.append(": ").append(getErrorCount()).append(" errors");
|
||||
Iterator it = getAllErrors().iterator();
|
||||
while (it.hasNext()) {
|
||||
sb.append('\n').append(it.next());
|
||||
for (ObjectError error : getAllErrors()) {
|
||||
sb.append('\n').append(error);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user