Java 5 code style
This commit is contained in:
@@ -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.
|
||||
@@ -59,7 +59,7 @@ public abstract class ServletRequestUtils {
|
||||
if (request.getParameter(name) == null) {
|
||||
return null;
|
||||
}
|
||||
return new Integer(getRequiredIntParameter(request, name));
|
||||
return getRequiredIntParameter(request, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,7 +137,7 @@ public abstract class ServletRequestUtils {
|
||||
if (request.getParameter(name) == null) {
|
||||
return null;
|
||||
}
|
||||
return new Long(getRequiredLongParameter(request, name));
|
||||
return getRequiredLongParameter(request, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,7 +215,7 @@ public abstract class ServletRequestUtils {
|
||||
if (request.getParameter(name) == null) {
|
||||
return null;
|
||||
}
|
||||
return new Float(getRequiredFloatParameter(request, name));
|
||||
return getRequiredFloatParameter(request, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -293,7 +293,7 @@ public abstract class ServletRequestUtils {
|
||||
if (request.getParameter(name) == null) {
|
||||
return null;
|
||||
}
|
||||
return new Double(getRequiredDoubleParameter(request, name));
|
||||
return getRequiredDoubleParameter(request, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -373,7 +373,7 @@ public abstract class ServletRequestUtils {
|
||||
if (request.getParameter(name) == null) {
|
||||
return null;
|
||||
}
|
||||
return (getRequiredBooleanParameter(request, name) ? Boolean.TRUE : Boolean.FALSE);
|
||||
return (getRequiredBooleanParameter(request, name));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -516,9 +516,9 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
|
||||
private abstract static class ParameterParser {
|
||||
private abstract static class ParameterParser<T> {
|
||||
|
||||
protected final Object parse(String name, String parameter) throws ServletRequestBindingException {
|
||||
protected final T parse(String name, String parameter) throws ServletRequestBindingException {
|
||||
validateRequiredParameter(name, parameter);
|
||||
try {
|
||||
return doParse(parameter);
|
||||
@@ -540,11 +540,11 @@ public abstract class ServletRequestUtils {
|
||||
|
||||
protected abstract String getType();
|
||||
|
||||
protected abstract Object doParse(String parameter) throws NumberFormatException;
|
||||
protected abstract T doParse(String parameter) throws NumberFormatException;
|
||||
}
|
||||
|
||||
|
||||
private static class IntParser extends ParameterParser {
|
||||
private static class IntParser extends ParameterParser<Integer> {
|
||||
|
||||
@Override
|
||||
protected String getType() {
|
||||
@@ -552,12 +552,12 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doParse(String s) throws NumberFormatException {
|
||||
protected Integer doParse(String s) throws NumberFormatException {
|
||||
return Integer.valueOf(s);
|
||||
}
|
||||
|
||||
public int parseInt(String name, String parameter) throws ServletRequestBindingException {
|
||||
return ((Number) parse(name, parameter)).intValue();
|
||||
return parse(name, parameter);
|
||||
}
|
||||
|
||||
public int[] parseInts(String name, String[] values) throws ServletRequestBindingException {
|
||||
@@ -571,7 +571,7 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
|
||||
private static class LongParser extends ParameterParser {
|
||||
private static class LongParser extends ParameterParser<Long> {
|
||||
|
||||
@Override
|
||||
protected String getType() {
|
||||
@@ -579,12 +579,12 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doParse(String parameter) throws NumberFormatException {
|
||||
protected Long doParse(String parameter) throws NumberFormatException {
|
||||
return Long.valueOf(parameter);
|
||||
}
|
||||
|
||||
public long parseLong(String name, String parameter) throws ServletRequestBindingException {
|
||||
return ((Number) parse(name, parameter)).longValue();
|
||||
return parse(name, parameter);
|
||||
}
|
||||
|
||||
public long[] parseLongs(String name, String[] values) throws ServletRequestBindingException {
|
||||
@@ -598,7 +598,7 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
|
||||
private static class FloatParser extends ParameterParser {
|
||||
private static class FloatParser extends ParameterParser<Float> {
|
||||
|
||||
@Override
|
||||
protected String getType() {
|
||||
@@ -606,12 +606,12 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doParse(String parameter) throws NumberFormatException {
|
||||
protected Float doParse(String parameter) throws NumberFormatException {
|
||||
return Float.valueOf(parameter);
|
||||
}
|
||||
|
||||
public float parseFloat(String name, String parameter) throws ServletRequestBindingException {
|
||||
return ((Number) parse(name, parameter)).floatValue();
|
||||
return parse(name, parameter);
|
||||
}
|
||||
|
||||
public float[] parseFloats(String name, String[] values) throws ServletRequestBindingException {
|
||||
@@ -625,7 +625,7 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
|
||||
private static class DoubleParser extends ParameterParser {
|
||||
private static class DoubleParser extends ParameterParser<Double> {
|
||||
|
||||
@Override
|
||||
protected String getType() {
|
||||
@@ -633,12 +633,12 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doParse(String parameter) throws NumberFormatException {
|
||||
protected Double doParse(String parameter) throws NumberFormatException {
|
||||
return Double.valueOf(parameter);
|
||||
}
|
||||
|
||||
public double parseDouble(String name, String parameter) throws ServletRequestBindingException {
|
||||
return ((Number) parse(name, parameter)).doubleValue();
|
||||
return parse(name, parameter);
|
||||
}
|
||||
|
||||
public double[] parseDoubles(String name, String[] values) throws ServletRequestBindingException {
|
||||
@@ -652,7 +652,7 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
|
||||
private static class BooleanParser extends ParameterParser {
|
||||
private static class BooleanParser extends ParameterParser<Boolean> {
|
||||
|
||||
@Override
|
||||
protected String getType() {
|
||||
@@ -660,13 +660,13 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doParse(String parameter) throws NumberFormatException {
|
||||
protected Boolean doParse(String parameter) throws NumberFormatException {
|
||||
return (parameter.equalsIgnoreCase("true") || parameter.equalsIgnoreCase("on") ||
|
||||
parameter.equalsIgnoreCase("yes") || parameter.equals("1") ? Boolean.TRUE : Boolean.FALSE);
|
||||
parameter.equalsIgnoreCase("yes") || parameter.equals("1"));
|
||||
}
|
||||
|
||||
public boolean parseBoolean(String name, String parameter) throws ServletRequestBindingException {
|
||||
return ((Boolean) parse(name, parameter)).booleanValue();
|
||||
return parse(name, parameter);
|
||||
}
|
||||
|
||||
public boolean[] parseBooleans(String name, String[] values) throws ServletRequestBindingException {
|
||||
@@ -680,7 +680,7 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
|
||||
private static class StringParser extends ParameterParser {
|
||||
private static class StringParser extends ParameterParser<String> {
|
||||
|
||||
@Override
|
||||
protected String getType() {
|
||||
@@ -688,7 +688,7 @@ public abstract class ServletRequestUtils {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doParse(String parameter) throws NumberFormatException {
|
||||
protected String doParse(String parameter) throws NumberFormatException {
|
||||
return parameter;
|
||||
}
|
||||
|
||||
@@ -699,8 +699,8 @@ public abstract class ServletRequestUtils {
|
||||
|
||||
public String[] validateRequiredStrings(String name, String[] values) throws ServletRequestBindingException {
|
||||
validateRequiredParameter(name, values);
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
validateRequiredParameter(name, values[i]);
|
||||
for (String value : values) {
|
||||
validateRequiredParameter(name, value);
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ public class SimpleMappingExceptionResolver implements HandlerExceptionResolver,
|
||||
* @see javax.servlet.http.HttpServletResponse#SC_NOT_FOUND
|
||||
*/
|
||||
public void setDefaultStatusCode(int defaultStatusCode) {
|
||||
this.defaultStatusCode = new Integer(defaultStatusCode);
|
||||
this.defaultStatusCode = defaultStatusCode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -218,8 +218,8 @@ public class SimpleMappingExceptionResolver implements HandlerExceptionResolver,
|
||||
return true;
|
||||
}
|
||||
if (this.mappedHandlerClasses != null) {
|
||||
for (int i = 0; i < this.mappedHandlerClasses.length; i++) {
|
||||
if (this.mappedHandlerClasses[i].isInstance(handler)) {
|
||||
for (Class handlerClass : this.mappedHandlerClasses) {
|
||||
if (handlerClass.isInstance(handler)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -259,7 +259,7 @@ public class SimpleMappingExceptionResolver implements HandlerExceptionResolver,
|
||||
// Only apply it if we're processing a top-level request.
|
||||
Integer statusCode = determineStatusCode(request, viewName);
|
||||
if (statusCode != null) {
|
||||
applyStatusCodeIfPossible(request, response, statusCode.intValue());
|
||||
applyStatusCodeIfPossible(request, response, statusCode);
|
||||
}
|
||||
return getModelAndView(viewName, ex, request);
|
||||
}
|
||||
@@ -362,7 +362,7 @@ public class SimpleMappingExceptionResolver implements HandlerExceptionResolver,
|
||||
}
|
||||
|
||||
private int getDepth(String exceptionMapping, Class exceptionClass, int depth) {
|
||||
if (exceptionClass.getName().indexOf(exceptionMapping) != -1) {
|
||||
if (exceptionClass.getName().contains(exceptionMapping)) {
|
||||
// Found it!
|
||||
return depth;
|
||||
}
|
||||
@@ -407,7 +407,7 @@ public class SimpleMappingExceptionResolver implements HandlerExceptionResolver,
|
||||
logger.debug("Applying HTTP status code " + statusCode);
|
||||
}
|
||||
response.setStatus(statusCode);
|
||||
request.setAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE, new Integer(statusCode));
|
||||
request.setAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE, statusCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,9 +44,9 @@ abstract class TagIdGenerator {
|
||||
public static String nextId(String name, PageContext pageContext) {
|
||||
String attributeName = PAGE_CONTEXT_ATTRIBUTE_PREFIX + name;
|
||||
Integer currentCount = (Integer) pageContext.getAttribute(attributeName);
|
||||
currentCount = (currentCount != null ? new Integer(currentCount.intValue() + 1) : new Integer(1));
|
||||
currentCount = (currentCount != null ? currentCount + 1 : 1);
|
||||
pageContext.setAttribute(attributeName, currentCount);
|
||||
return (name + currentCount.intValue());
|
||||
return (name + currentCount);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user