mirror of
https://github.com/apache/struts.git
synced 2026-08-07 15:46:57 +00:00
WW-2282 Apply a number of "FindBugs" performance optimizations submitted by Giovanni Azua Garcia. Most (or all) of these are line for line substitutions.
git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@591174 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -231,31 +231,31 @@ public class Date extends ContextBean {
|
||||
int years = days / 365;
|
||||
|
||||
if (years > 0) {
|
||||
args.add(new Long(years));
|
||||
args.add(new Long(day));
|
||||
args.add(Long.valueOf(years));
|
||||
args.add(Long.valueOf(day));
|
||||
args.add(sb);
|
||||
args.add(null);
|
||||
sb.append(tp.getText(DATETAG_PROPERTY_YEARS, DATETAG_DEFAULT_YEARS, args));
|
||||
} else if (day > 0) {
|
||||
args.add(new Long(day));
|
||||
args.add(new Long(hour));
|
||||
args.add(Long.valueOf(day));
|
||||
args.add(Long.valueOf(hour));
|
||||
args.add(sb);
|
||||
args.add(null);
|
||||
sb.append(tp.getText(DATETAG_PROPERTY_DAYS, DATETAG_DEFAULT_DAYS, args));
|
||||
} else if (hour > 0) {
|
||||
args.add(new Long(hour));
|
||||
args.add(new Long(min));
|
||||
args.add(Long.valueOf(hour));
|
||||
args.add(Long.valueOf(min));
|
||||
args.add(sb);
|
||||
args.add(null);
|
||||
sb.append(tp.getText(DATETAG_PROPERTY_HOURS, DATETAG_DEFAULT_HOURS, args));
|
||||
} else if (min > 0) {
|
||||
args.add(new Long(min));
|
||||
args.add(new Long(sec));
|
||||
args.add(Long.valueOf(min));
|
||||
args.add(Long.valueOf(sec));
|
||||
args.add(sb);
|
||||
args.add(null);
|
||||
sb.append(tp.getText(DATETAG_PROPERTY_MINUTES, DATETAG_DEFAULT_MINUTES, args));
|
||||
} else {
|
||||
args.add(new Long(sec));
|
||||
args.add(Long.valueOf(sec));
|
||||
args.add(sb);
|
||||
args.add(null);
|
||||
sb.append(tp.getText(DATETAG_PROPERTY_SECONDS, DATETAG_DEFAULT_SECONDS, args));
|
||||
|
||||
@@ -79,7 +79,7 @@ public class Debug extends UIBean {
|
||||
return result;
|
||||
}
|
||||
|
||||
private class DebugMapEntry implements Map.Entry {
|
||||
private static class DebugMapEntry implements Map.Entry {
|
||||
private Object key;
|
||||
private Object value;
|
||||
|
||||
|
||||
@@ -172,13 +172,13 @@ public abstract class DoubleListUIBean extends ListUIBean {
|
||||
if (doubleValue != null) {
|
||||
addParameter("doubleNameValue", findValue(doubleValue, valueClazz));
|
||||
} else if (doubleName != null) {
|
||||
addParameter("doubleNameValue", findValue(doubleName.toString(), valueClazz));
|
||||
addParameter("doubleNameValue", findValue(doubleName, valueClazz));
|
||||
}
|
||||
} else {
|
||||
if (doubleValue != null) {
|
||||
addParameter("doubleNameValue", findValue(doubleValue));
|
||||
} else if (doubleName != null) {
|
||||
addParameter("doubleNameValue", findValue(doubleName.toString()));
|
||||
addParameter("doubleNameValue", findValue(doubleName));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,11 +94,11 @@ public abstract class ListUIBean extends UIBean {
|
||||
}
|
||||
|
||||
if (value instanceof Collection) {
|
||||
addParameter("listSize", new Integer(((Collection) value).size()));
|
||||
addParameter("listSize", Integer.valueOf(((Collection) value).size()));
|
||||
} else if (value instanceof Map) {
|
||||
addParameter("listSize", new Integer(((Map) value).size()));
|
||||
addParameter("listSize", Integer.valueOf(((Map) value).size()));
|
||||
} else if (value != null && value.getClass().isArray()) {
|
||||
addParameter("listSize", new Integer(Array.getLength(value)));
|
||||
addParameter("listSize", Integer.valueOf(Array.getLength(value)));
|
||||
}
|
||||
|
||||
if (listKey != null) {
|
||||
|
||||
@@ -887,7 +887,7 @@ public abstract class UIBean extends Component {
|
||||
String value = null;
|
||||
if (configEntry.length > 1) {
|
||||
value = configEntry[1].trim();
|
||||
tooltipConfig.put(key, value.toString());
|
||||
tooltipConfig.put(key, value);
|
||||
}
|
||||
else {
|
||||
LOG.warn("component "+component+" tooltip config param "+key+" has no value defined, skipped");
|
||||
|
||||
@@ -285,7 +285,7 @@ public class BeanSelectionProvider implements ConfigurationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
class ObjectFactoryDelegateFactory implements Factory {
|
||||
static class ObjectFactoryDelegateFactory implements Factory {
|
||||
String name;
|
||||
Class type;
|
||||
ObjectFactoryDelegateFactory(String name, Class type) {
|
||||
|
||||
@@ -112,11 +112,11 @@ public class MethodConfigurationProvider implements ConfigurationProvider {
|
||||
|
||||
boolean added = false;
|
||||
for (Object namespace : namespaces) {
|
||||
Map actions = (Map) allActionConfigs.get(namespace);
|
||||
Set actionNames = actions.keySet();
|
||||
for (Object actionName : actionNames) {
|
||||
ActionConfig actionConfig = (ActionConfig) actions.get(actionName);
|
||||
added = added | addDynamicMethods(actions, (String) actionName, actionConfig);
|
||||
Map<Object, Object> actions = (Map) allActionConfigs.get(namespace);
|
||||
for (Map.Entry<Object, Object> actionEntry : actions.entrySet()) {
|
||||
String actionName = (String) actionEntry.getKey();
|
||||
ActionConfig actionConfig = (ActionConfig) actionEntry.getValue();
|
||||
added = added | addDynamicMethods(actions, actionName, actionConfig);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,10 +85,10 @@ public class ActionContextCleanUp implements Filter {
|
||||
try {
|
||||
Integer count = (Integer)request.getAttribute(COUNTER);
|
||||
if (count == null) {
|
||||
count = new Integer(1);
|
||||
count = Integer.valueOf(1);
|
||||
}
|
||||
else {
|
||||
count = new Integer(count.intValue()+1);
|
||||
count = Integer.valueOf(count.intValue()+1);
|
||||
}
|
||||
request.setAttribute(COUNTER, count);
|
||||
|
||||
@@ -98,7 +98,7 @@ public class ActionContextCleanUp implements Filter {
|
||||
} finally {
|
||||
int counterVal = ((Integer)request.getAttribute(COUNTER)).intValue();
|
||||
counterVal -= 1;
|
||||
request.setAttribute(COUNTER, new Integer(counterVal));
|
||||
request.setAttribute(COUNTER, Integer.valueOf(counterVal));
|
||||
cleanUp(request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ public class ApplicationMap extends AbstractMap implements Serializable {
|
||||
}
|
||||
|
||||
public Object setValue(Object obj) {
|
||||
context.setAttribute(key.toString(), obj);
|
||||
context.setAttribute(key, obj);
|
||||
|
||||
return value;
|
||||
}
|
||||
@@ -136,7 +136,7 @@ public class ApplicationMap extends AbstractMap implements Serializable {
|
||||
}
|
||||
|
||||
public Object setValue(Object obj) {
|
||||
context.setAttribute(key.toString(), obj);
|
||||
context.setAttribute(key, obj);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -745,7 +745,7 @@ Caused by: com.opensymphony.xwork2.inject.ContainerImpl$MissingDependencyExcepti
|
||||
/**
|
||||
* Provide an accessor class for static XWork utility.
|
||||
*/
|
||||
public class Locator {
|
||||
public static class Locator {
|
||||
public Location getLocation(Object obj) {
|
||||
Location loc = LocationUtils.getLocation(obj);
|
||||
if (loc == null) {
|
||||
|
||||
@@ -97,7 +97,7 @@ public class RequestMap extends AbstractMap implements Serializable {
|
||||
}
|
||||
|
||||
public Object setValue(Object obj) {
|
||||
request.setAttribute(key.toString(), obj);
|
||||
request.setAttribute(key, obj);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ public class SessionMap extends AbstractMap implements Serializable {
|
||||
}
|
||||
|
||||
public Object setValue(Object obj) {
|
||||
session.setAttribute(key.toString(), obj);
|
||||
session.setAttribute(key, obj);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public class ScopeInterceptor extends AbstractInterceptor implements PreResultLi
|
||||
*/
|
||||
public void setAutoCreateSession(String value) {
|
||||
if (value != null && value.length() > 0) {
|
||||
this.autoCreateSession = new Boolean(value).booleanValue();
|
||||
this.autoCreateSession = Boolean.valueOf(value).booleanValue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-4
@@ -393,12 +393,12 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
}
|
||||
} else if (bean instanceof Map) {
|
||||
|
||||
Map map = (Map) bean;
|
||||
Map<Object, Object> map = (Map) bean;
|
||||
|
||||
// Loop through keys and call ourselves
|
||||
for (Object key : map.keySet()) {
|
||||
Object Objvalue = map.get(key);
|
||||
serializeIt(Objvalue, key.toString(), writer, stack);
|
||||
for (Map.Entry<Object, Object> entry : map.entrySet()) {
|
||||
Object objValue = entry.getValue();
|
||||
serializeIt(objValue, entry.getKey().toString(), writer, stack);
|
||||
}
|
||||
} else if (bean.getClass().isArray()) {
|
||||
// It's an array, loop through it and keep calling ourselves
|
||||
@@ -449,3 +449,4 @@ public class DebuggingInterceptor implements Interceptor {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ public class Counter implements java.util.Iterator, Serializable {
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
return new Long(getNext());
|
||||
return Long.valueOf(getNext());
|
||||
}
|
||||
|
||||
public void remove() {
|
||||
|
||||
@@ -37,7 +37,7 @@ public abstract class IteratorFilterSupport {
|
||||
|
||||
|
||||
// Wrapper for enumerations
|
||||
public class EnumerationIterator implements Iterator {
|
||||
public static class EnumerationIterator implements Iterator {
|
||||
Enumeration enumeration;
|
||||
|
||||
public EnumerationIterator(Enumeration aEnum) {
|
||||
|
||||
@@ -66,7 +66,7 @@ public class MapAdapter extends AbstractAdapterElement {
|
||||
return children;
|
||||
}
|
||||
|
||||
class EntryElement extends AbstractAdapterElement {
|
||||
static class EntryElement extends AbstractAdapterElement {
|
||||
Object key, value;
|
||||
|
||||
public EntryElement( AdapterFactory adapterFactory,
|
||||
|
||||
Reference in New Issue
Block a user