Java 5 code style

This commit is contained in:
Juergen Hoeller 2008-11-28 11:39:36 +00:00
parent fda7100866
commit f8c690c542
55 changed files with 356 additions and 445 deletions

View File

@ -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.
@ -52,7 +52,7 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
}
public void setOrder(int order) {
this.order = new Integer(order);
this.order = order;
}
@ -70,7 +70,7 @@ public class AspectJPointcutAdvisor implements PointcutAdvisor, Ordered {
public int getOrder() {
if (this.order != null) {
return this.order.intValue();
return this.order;
}
else {
return this.advice.getOrder();

View File

@ -159,11 +159,11 @@ final class JdkDynamicAopProxy implements AopProxy, InvocationHandler, Serializa
try {
if (!this.equalsDefined && AopUtils.isEqualsMethod(method)) {
// The target does not implement the equals(Object) method itself.
return (equals(args[0]) ? Boolean.TRUE : Boolean.FALSE);
return equals(args[0]);
}
if (!this.hashCodeDefined && AopUtils.isHashCodeMethod(method)) {
// The target does not implement the hashCode() method itself.
return new Integer(hashCode());
return hashCode();
}
if (!this.advised.opaque && method.getDeclaringClass().isInterface() &&
method.getDeclaringClass().isAssignableFrom(Advised.class)) {

View File

@ -345,11 +345,11 @@ public class ServiceLocatorFactoryBean implements FactoryBean, BeanFactoryAware,
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (ReflectionUtils.isEqualsMethod(method)) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (ReflectionUtils.isHashCodeMethod(method)) {
// Use hashCode of service locator proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (ReflectionUtils.isToStringMethod(method)) {
return "Service locator: " + serviceLocatorInterface.getName();

View File

@ -227,7 +227,7 @@ public class MBeanExporter extends MBeanRegistrationSupport
* @see #AUTODETECT_NONE
*/
public void setAutodetectMode(int autodetectMode) {
if (!constants.getValues(CONSTANT_PREFIX_AUTODETECT).contains(new Integer(autodetectMode))) {
if (!constants.getValues(CONSTANT_PREFIX_AUTODETECT).contains(autodetectMode)) {
throw new IllegalArgumentException("Only values of autodetect constants allowed");
}
this.autodetectMode = autodetectMode;

View File

@ -98,7 +98,7 @@ public abstract class AbstractReflectiveMBeanInfoAssembler extends AbstractMBean
* accessors or mutators for attributes.
* @see #FIELD_VISIBILITY
*/
protected static final Integer ATTRIBUTE_OPERATION_VISIBILITY = new Integer(4);
protected static final int ATTRIBUTE_OPERATION_VISIBILITY = 4;
/**
* Constant identifier for the class field in a JMX {@link Descriptor}.

View File

@ -175,10 +175,10 @@ public abstract class BshScriptUtils {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (ReflectionUtils.isEqualsMethod(method)) {
return (isProxyForSameBshObject(args[0]) ? Boolean.TRUE : Boolean.FALSE);
return (isProxyForSameBshObject(args[0]));
}
else if (ReflectionUtils.isHashCodeMethod(method)) {
return new Integer(this.xt.hashCode());
return this.xt.hashCode();
}
else if (ReflectionUtils.isToStringMethod(method)) {
return "BeanShell object [" + this.xt + "]";

View File

@ -162,7 +162,7 @@ public abstract class JRubyScriptUtils {
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (ReflectionUtils.isEqualsMethod(method)) {
return (isProxyForSameRubyObject(args[0]) ? Boolean.TRUE : Boolean.FALSE);
return (isProxyForSameRubyObject(args[0]));
}
else if (ReflectionUtils.isHashCodeMethod(method)) {
return this.rubyObject.hashCode();

View File

@ -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.
@ -105,6 +105,16 @@ public class ToStringCreator {
return append(fieldName, new Integer(value));
}
/**
* Append a long field value.
* @param fieldName the name of the field, usually the member variable name
* @param value the field value
* @return this, to support call-chaining
*/
public ToStringCreator append(String fieldName, long value) {
return append(fieldName, new Long(value));
}
/**
* Append a float field value.
* @param fieldName the name of the field, usually the member variable name
@ -125,16 +135,6 @@ public class ToStringCreator {
return append(fieldName, new Double(value));
}
/**
* Append a long field value.
* @param fieldName the name of the field, usually the member variable name
* @param value the field value
* @return this, to support call-chaining
*/
public ToStringCreator append(String fieldName, long value) {
return append(fieldName, new Long(value));
}
/**
* Append a boolean field value.
* @param fieldName the name of the field, usually the member variable name
@ -142,7 +142,7 @@ public class ToStringCreator {
* @return this, to support call-chaining
*/
public ToStringCreator append(String fieldName, boolean value) {
return append(fieldName, value ? Boolean.TRUE : Boolean.FALSE);
return append(fieldName, Boolean.valueOf(value));
}
/**

View File

@ -63,24 +63,24 @@ public abstract class NumberUtils {
if (value < Byte.MIN_VALUE || value > Byte.MAX_VALUE) {
raiseOverflowException(number, targetClass);
}
return new Byte(number.byteValue());
return number.byteValue();
}
else if (targetClass.equals(Short.class)) {
long value = number.longValue();
if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) {
raiseOverflowException(number, targetClass);
}
return new Short(number.shortValue());
return number.shortValue();
}
else if (targetClass.equals(Integer.class)) {
long value = number.longValue();
if (value < Integer.MIN_VALUE || value > Integer.MAX_VALUE) {
raiseOverflowException(number, targetClass);
}
return new Integer(number.intValue());
return number.intValue();
}
else if (targetClass.equals(Long.class)) {
return new Long(number.longValue());
return number.longValue();
}
else if (targetClass.equals(BigInteger.class)) {
if (number instanceof BigDecimal) {
@ -93,10 +93,10 @@ public abstract class NumberUtils {
}
}
else if (targetClass.equals(Float.class)) {
return new Float(number.floatValue());
return number.floatValue();
}
else if (targetClass.equals(Double.class)) {
return new Double(number.doubleValue());
return number.doubleValue();
}
else if (targetClass.equals(BigDecimal.class)) {
// always use BigDecimal(String) here to avoid unpredictability of BigDecimal(double)

View File

@ -1272,7 +1272,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
}
else if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of PersistenceManager proxy.

View File

@ -30,9 +30,9 @@ import org.springframework.util.Assert;
*/
public abstract class AbstractSqlParameterSource implements SqlParameterSource {
private final Map sqlTypes = new HashMap();
private final Map<String, Integer> sqlTypes = new HashMap<String, Integer>();
private final Map typeNames = new HashMap();
private final Map<String, String> typeNames = new HashMap<String, String>();
/**
@ -42,7 +42,7 @@ public abstract class AbstractSqlParameterSource implements SqlParameterSource {
*/
public void registerSqlType(String paramName, int sqlType) {
Assert.notNull(paramName, "Parameter name must not be null");
this.sqlTypes.put(paramName, new Integer(sqlType));
this.sqlTypes.put(paramName, sqlType);
}
/**
@ -63,9 +63,9 @@ public abstract class AbstractSqlParameterSource implements SqlParameterSource {
*/
public int getSqlType(String paramName) {
Assert.notNull(paramName, "Parameter name must not be null");
Integer sqlType = (Integer) this.sqlTypes.get(paramName);
Integer sqlType = this.sqlTypes.get(paramName);
if (sqlType != null) {
return sqlType.intValue();
return sqlType;
}
return TYPE_UNKNOWN;
}
@ -78,7 +78,7 @@ public abstract class AbstractSqlParameterSource implements SqlParameterSource {
*/
public String getTypeName(String paramName) {
Assert.notNull(paramName, "Parameter name must not be null");
return (String) this.typeNames.get(paramName);
return this.typeNames.get(paramName);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2005 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.
@ -51,10 +51,11 @@ import org.springframework.jdbc.support.lob.LobHandler;
* @since 1.0.2
* @see org.springframework.jdbc.support.lob.LobCreator
*/
public abstract class AbstractLobCreatingPreparedStatementCallback implements PreparedStatementCallback {
public abstract class AbstractLobCreatingPreparedStatementCallback implements PreparedStatementCallback<Integer> {
private final LobHandler lobHandler;
/**
* Create a new AbstractLobCreatingPreparedStatementCallback for the
* given LobHandler.
@ -64,11 +65,12 @@ public abstract class AbstractLobCreatingPreparedStatementCallback implements Pr
this.lobHandler = lobHandler;
}
public final Object doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
public final Integer doInPreparedStatement(PreparedStatement ps) throws SQLException, DataAccessException {
LobCreator lobCreator = this.lobHandler.getLobCreator();
try {
setValues(ps, lobCreator);
return new Integer(ps.executeUpdate());
return ps.executeUpdate();
}
finally {
lobCreator.close();

View File

@ -170,7 +170,7 @@ public abstract class DataSourceUtils {
logger.debug("Changing isolation level of JDBC Connection [" + con + "] to " +
definition.getIsolationLevel());
}
previousIsolationLevel = new Integer(con.getTransactionIsolation());
previousIsolationLevel = con.getTransactionIsolation();
con.setTransactionIsolation(definition.getIsolationLevel());
}

View File

@ -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.
@ -101,11 +101,10 @@ public class IsolationLevelDataSourceAdapter extends UserCredentialsDataSourceAd
* @see org.springframework.transaction.support.TransactionSynchronizationManager#getCurrentTransactionIsolationLevel()
*/
public void setIsolationLevel(int isolationLevel) {
if (!constants.getValues(DefaultTransactionDefinition.PREFIX_ISOLATION).contains(new Integer(isolationLevel))) {
if (!constants.getValues(DefaultTransactionDefinition.PREFIX_ISOLATION).contains(isolationLevel)) {
throw new IllegalArgumentException("Only values of isolation constants allowed");
}
this.isolationLevel =
(isolationLevel != TransactionDefinition.ISOLATION_DEFAULT ? new Integer(isolationLevel) : null);
this.isolationLevel = (isolationLevel != TransactionDefinition.ISOLATION_DEFAULT ? isolationLevel : null);
}
/**
@ -128,11 +127,11 @@ public class IsolationLevelDataSourceAdapter extends UserCredentialsDataSourceAd
Connection con = super.doGetConnection(username, password);
Boolean readOnlyToUse = getCurrentReadOnlyFlag();
if (readOnlyToUse != null) {
con.setReadOnly(readOnlyToUse.booleanValue());
con.setReadOnly(readOnlyToUse);
}
Integer isolationLevelToUse = getCurrentIsolationLevel();
if (isolationLevelToUse != null) {
con.setTransactionIsolation(isolationLevelToUse.intValue());
con.setTransactionIsolation(isolationLevelToUse);
}
return con;
}

View File

@ -118,7 +118,7 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
* @see java.sql.Connection#setAutoCommit
*/
public void setDefaultAutoCommit(boolean defaultAutoCommit) {
this.defaultAutoCommit = new Boolean(defaultAutoCommit);
this.defaultAutoCommit = defaultAutoCommit;
}
/**
@ -135,7 +135,7 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
* @see java.sql.Connection#setTransactionIsolation
*/
public void setDefaultTransactionIsolation(int defaultTransactionIsolation) {
this.defaultTransactionIsolation = new Integer(defaultTransactionIsolation);
this.defaultTransactionIsolation = defaultTransactionIsolation;
}
/**
@ -187,10 +187,10 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
*/
protected synchronized void checkDefaultConnectionProperties(Connection con) throws SQLException {
if (this.defaultAutoCommit == null) {
this.defaultAutoCommit = new Boolean(con.getAutoCommit());
this.defaultAutoCommit = con.getAutoCommit();
}
if (this.defaultTransactionIsolation == null) {
this.defaultTransactionIsolation = new Integer(con.getTransactionIsolation());
this.defaultTransactionIsolation = con.getTransactionIsolation();
}
}
@ -281,13 +281,13 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
if (method.getName().equals("equals")) {
// We must avoid fetching a target Connection for "equals".
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// We must avoid fetching a target Connection for "hashCode",
// and we must return the same hash code even when the target
// Connection has been fetched: use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("getTargetConnection")) {
// Handle getTargetConnection method: return underlying connection.
@ -346,7 +346,7 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
return null;
}
else if (method.getName().equals("isClosed")) {
return (this.closed ? Boolean.TRUE : Boolean.FALSE);
return (this.closed);
}
else if (method.getName().equals("close")) {
// Ignore: no target connection yet.
@ -397,15 +397,15 @@ public class LazyConnectionDataSourceProxy extends DelegatingDataSource {
checkDefaultConnectionProperties(this.target);
// Apply kept transaction settings, if any.
if (this.readOnly.booleanValue()) {
this.target.setReadOnly(this.readOnly.booleanValue());
if (this.readOnly) {
this.target.setReadOnly(this.readOnly);
}
if (this.transactionIsolation != null &&
!this.transactionIsolation.equals(defaultTransactionIsolation())) {
this.target.setTransactionIsolation(this.transactionIsolation.intValue());
this.target.setTransactionIsolation(this.transactionIsolation);
}
if (this.autoCommit != null && this.autoCommit.booleanValue() != this.target.getAutoCommit()) {
this.target.setAutoCommit(this.autoCommit.booleanValue());
if (this.autoCommit != null && this.autoCommit != this.target.getAutoCommit()) {
this.target.setAutoCommit(this.autoCommit);
}
}

View File

@ -166,7 +166,7 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
* Set whether the returned Connection's "autoCommit" setting should be overridden.
*/
public void setAutoCommit(boolean autoCommit) {
this.autoCommit = (autoCommit ? Boolean.TRUE : Boolean.FALSE);
this.autoCommit = (autoCommit);
}
/**
@ -270,8 +270,8 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
*/
protected void prepareConnection(Connection con) throws SQLException {
Boolean autoCommit = getAutoCommitValue();
if (autoCommit != null && con.getAutoCommit() != autoCommit.booleanValue()) {
con.setAutoCommit(autoCommit.booleanValue());
if (autoCommit != null && con.getAutoCommit() != autoCommit) {
con.setAutoCommit(autoCommit);
}
}
@ -319,11 +319,11 @@ public class SingleConnectionDataSource extends DriverManagerDataSource
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("close")) {
// Handle close method: don't pass the call on.

View File

@ -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.
@ -180,11 +180,11 @@ public class TransactionAwareDataSourceProxy extends DelegatingDataSource {
if (method.getName().equals("equals")) {
// Only considered as equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("toString")) {
// Allow for differentiating between the proxy and the raw Connection.

View File

@ -158,7 +158,7 @@ public class BatchSqlUpdate extends SqlUpdate {
* @see #flush
*/
@Override
public int update(Object[] params) throws DataAccessException {
public int update(Object... params) throws DataAccessException {
validateParameters(params);
this.parameterQueue.add(params.clone());

View File

@ -1,12 +1,12 @@
/*
* Copyright 2002-2005 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.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,7 +19,6 @@ package org.springframework.jdbc.object;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import javax.sql.DataSource;
/**
@ -36,7 +35,7 @@ import javax.sql.DataSource;
* @author Jean-Pierre Pawlak
* @see MappingSqlQueryWithParameters
*/
public abstract class MappingSqlQuery extends MappingSqlQueryWithParameters {
public abstract class MappingSqlQuery<T> extends MappingSqlQueryWithParameters<T> {
/**
* Constructor that allows use as a JavaBean.
@ -53,13 +52,14 @@ public abstract class MappingSqlQuery extends MappingSqlQueryWithParameters {
super(ds, sql);
}
/**
* This method is implemented to invoke the simpler mapRow
* template method, ignoring parameters.
* @see #mapRow(ResultSet, int)
*/
@Override
protected final Object mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context)
protected final T mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context)
throws SQLException {
return mapRow(rs, rowNum);
@ -78,6 +78,6 @@ public abstract class MappingSqlQuery extends MappingSqlQueryWithParameters {
* Subclasses can simply not catch SQLExceptions, relying on the
* framework to clean up.
*/
protected abstract Object mapRow(ResultSet rs, int rowNum) throws SQLException;
protected abstract T mapRow(ResultSet rs, int rowNum) throws SQLException;
}

View File

@ -1,12 +1,12 @@
/*
* Copyright 2002-2005 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.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -19,7 +19,6 @@ package org.springframework.jdbc.object;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.jdbc.core.RowMapper;
@ -48,7 +47,7 @@ import org.springframework.jdbc.core.RowMapper;
* @see org.springframework.jdbc.object.MappingSqlQuery
* @see org.springframework.jdbc.object.SqlQuery
*/
public abstract class MappingSqlQueryWithParameters extends SqlQuery {
public abstract class MappingSqlQueryWithParameters<T> extends SqlQuery<T> {
/**
* Constructor to allow use as a JavaBean
@ -71,7 +70,7 @@ public abstract class MappingSqlQueryWithParameters extends SqlQuery {
* implementation of the mapRow() method.
*/
@Override
protected RowMapper newRowMapper(Object[] parameters, Map context) {
protected RowMapper<T> newRowMapper(Object[] parameters, Map context) {
return new RowMapperImpl(parameters, context);
}
@ -90,7 +89,7 @@ public abstract class MappingSqlQueryWithParameters extends SqlQuery {
* Subclasses can simply not catch SQLExceptions, relying on the
* framework to clean up.
*/
protected abstract Object mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context)
protected abstract T mapRow(ResultSet rs, int rowNum, Object[] parameters, Map context)
throws SQLException;
@ -98,7 +97,7 @@ public abstract class MappingSqlQueryWithParameters extends SqlQuery {
* Implementation of RowMapper that calls the enclosing
* class's <code>mapRow</code> method for each row.
*/
protected class RowMapperImpl implements RowMapper {
protected class RowMapperImpl implements RowMapper<T> {
private final Object[] params;
@ -112,7 +111,7 @@ public abstract class MappingSqlQueryWithParameters extends SqlQuery {
this.context = context;
}
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
public T mapRow(ResultSet rs, int rowNum) throws SQLException {
return MappingSqlQueryWithParameters.this.mapRow(rs, rowNum, this.params, this.context);
}
}

View File

@ -305,7 +305,7 @@ public abstract class RdbmsOperation implements InitializingBean {
/**
* Return a list of the declared {@link SqlParameter} objects.
*/
protected List getDeclaredParameters() {
protected List<SqlParameter> getDeclaredParameters() {
return this.declaredParameters;
}
@ -398,7 +398,7 @@ public abstract class RdbmsOperation implements InitializingBean {
* @param parameters parameter Map supplied. May be <code>null</code>.
* @throws InvalidDataAccessApiUsageException if the parameters are invalid
*/
protected void validateNamedParameters(Map<String, Object> parameters) throws InvalidDataAccessApiUsageException {
protected void validateNamedParameters(Map<String, ?> parameters) throws InvalidDataAccessApiUsageException {
checkCompiled();
Map paramsToUse = (parameters != null ? parameters : Collections.emptyMap());
int declaredInParameters = 0;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2006 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.
@ -18,14 +18,12 @@ package org.springframework.jdbc.object;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import org.springframework.jdbc.core.CallableStatementCreator;
import org.springframework.jdbc.core.CallableStatementCreatorFactory;
import org.springframework.jdbc.core.ParameterMapper;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.jdbc.core.SqlReturnResultSet;
/**
* RdbmsOperation using a JdbcTemplate and representing a SQL-based
@ -130,7 +128,7 @@ public abstract class SqlCall extends RdbmsOperation {
this.callString = getSql();
}
else {
List parameters = getDeclaredParameters();
List<SqlParameter> parameters = getDeclaredParameters();
int parameterCount = 0;
if (isFunction()) {
this.callString = "{? = call " + getSql() + "(";
@ -139,8 +137,7 @@ public abstract class SqlCall extends RdbmsOperation {
else {
this.callString = "{call " + getSql() + "(";
}
for (int i = 0; i < parameters.size(); i++) {
SqlParameter parameter = (SqlParameter) parameters.get(i);
for (SqlParameter parameter : parameters) {
if (!(parameter.isResultsParameter())) {
if (parameterCount > 0) {
this.callString += ", ";
@ -184,7 +181,7 @@ public abstract class SqlCall extends RdbmsOperation {
* with this parameters.
* @param inParams parameters. May be <code>null</code>.
*/
protected CallableStatementCreator newCallableStatementCreator(Map inParams) {
protected CallableStatementCreator newCallableStatementCreator(Map<String, ?> inParams) {
return this.callableStatementFactory.newCallableStatementCreator(inParams);
}

View File

@ -1,12 +1,12 @@
/*
* Copyright 2002-2005 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.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -18,13 +18,10 @@ package org.springframework.jdbc.object;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import javax.sql.DataSource;
import org.springframework.dao.TypeMismatchDataAccessException;
import org.springframework.jdbc.core.SingleColumnRowMapper;
import org.springframework.jdbc.support.JdbcUtils;
/**
* SQL "function" wrapper for a query that returns a single row of results.
@ -50,9 +47,9 @@ import org.springframework.jdbc.support.JdbcUtils;
* @author Jean-Pierre Pawlak
* @see org.springframework.jdbc.object.StoredProcedure
*/
public class SqlFunction extends MappingSqlQuery {
public class SqlFunction<T> extends MappingSqlQuery<T> {
private final SingleColumnRowMapper rowMapper = new SingleColumnRowMapper();
private final SingleColumnRowMapper<T> rowMapper = new SingleColumnRowMapper<T>();
/**
@ -104,7 +101,7 @@ public class SqlFunction extends MappingSqlQuery {
* @see #setResultType(Class)
* @see java.sql.Types
*/
public SqlFunction(DataSource ds, String sql, int[] types, Class resultType) {
public SqlFunction(DataSource ds, String sql, int[] types, Class<T> resultType) {
setRowsExpected(1);
setDataSource(ds);
setSql(sql);
@ -118,7 +115,7 @@ public class SqlFunction extends MappingSqlQuery {
* <p>If not specified, the result value will be exposed as
* returned by the JDBC driver.
*/
public void setResultType(Class resultType) {
public void setResultType(Class<T> resultType) {
this.rowMapper.setRequiredType(resultType);
}
@ -129,7 +126,7 @@ public class SqlFunction extends MappingSqlQuery {
* of rows returned, this is treated as an error.
*/
@Override
protected Object mapRow(ResultSet rs, int rowNum) throws SQLException {
protected T mapRow(ResultSet rs, int rowNum) throws SQLException {
return this.rowMapper.mapRow(rs, rowNum);
}
@ -139,7 +136,7 @@ public class SqlFunction extends MappingSqlQuery {
* @return the value of the function
*/
public int run() {
return run(null);
return run(new Object[0]);
}
/**
@ -148,7 +145,7 @@ public class SqlFunction extends MappingSqlQuery {
* @return the value of the function
*/
public int run(int parameter) {
return run(new Object[] {new Integer(parameter)});
return run(new Object[] {parameter});
}
/**
@ -158,7 +155,7 @@ public class SqlFunction extends MappingSqlQuery {
* object wrapper types for primitives.
* @return the value of the function
*/
public int run(Object[] parameters) {
public int run(Object... parameters) {
Object obj = super.findObject(parameters);
if (!(obj instanceof Number)) {
throw new TypeMismatchDataAccessException("Couldn't convert result object [" + obj + "] to int");

View File

@ -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.
@ -52,7 +52,7 @@ import org.springframework.jdbc.core.namedparam.ParsedSql;
* @author Thomas Risberg
* @see SqlUpdate
*/
public abstract class SqlQuery extends SqlOperation {
public abstract class SqlQuery<T> extends SqlOperation {
/** The number of rows to expect; if 0, unknown. */
private int rowsExpected = 0;
@ -106,9 +106,9 @@ public abstract class SqlQuery extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public List execute(Object[] params, Map context) throws DataAccessException {
public List<T> execute(Object[] params, Map context) throws DataAccessException {
validateParameters(params);
RowMapper rowMapper = newRowMapper(params, context);
RowMapper<T> rowMapper = newRowMapper(params, context);
return getJdbcTemplate().query(newPreparedStatementCreator(params), rowMapper);
}
@ -118,7 +118,7 @@ public abstract class SqlQuery extends SqlOperation {
* be represented by their Object wrapper type. The ordering of parameters is
* significant.
*/
public List execute(Object[] params) throws DataAccessException {
public List<T> execute(Object... params) throws DataAccessException {
return execute(params, null);
}
@ -126,14 +126,14 @@ public abstract class SqlQuery extends SqlOperation {
* Convenient method to execute without parameters.
* @param context the contextual information for object creation
*/
public List execute(Map context) throws DataAccessException {
public List<T> execute(Map context) throws DataAccessException {
return execute((Object[]) null, context);
}
/**
* Convenient method to execute without parameters nor context.
*/
public List execute() throws DataAccessException {
public List<T> execute() throws DataAccessException {
return execute((Object[]) null);
}
@ -142,15 +142,15 @@ public abstract class SqlQuery extends SqlOperation {
* @param p1 single int parameter
* @param context the contextual information for object creation
*/
public List execute(int p1, Map context) throws DataAccessException {
return execute(new Object[] {new Integer(p1)}, context);
public List<T> execute(int p1, Map context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
/**
* Convenient method to execute with a single int parameter.
* @param p1 single int parameter
*/
public List execute(int p1) throws DataAccessException {
public List<T> execute(int p1) throws DataAccessException {
return execute(p1, null);
}
@ -160,8 +160,8 @@ public abstract class SqlQuery extends SqlOperation {
* @param p2 second int parameter
* @param context the contextual information for object creation
*/
public List execute(int p1, int p2, Map context) throws DataAccessException {
return execute(new Object[] {new Integer(p1), new Integer(p2)}, context);
public List<T> execute(int p1, int p2, Map context) throws DataAccessException {
return execute(new Object[] {p1, p2}, context);
}
/**
@ -169,7 +169,7 @@ public abstract class SqlQuery extends SqlOperation {
* @param p1 first int parameter
* @param p2 second int parameter
*/
public List execute(int p1, int p2) throws DataAccessException {
public List<T> execute(int p1, int p2) throws DataAccessException {
return execute(p1, p2, null);
}
@ -178,15 +178,15 @@ public abstract class SqlQuery extends SqlOperation {
* @param p1 single long parameter
* @param context the contextual information for object creation
*/
public List execute(long p1, Map context) throws DataAccessException {
return execute(new Object[] {new Long(p1)}, context);
public List<T> execute(long p1, Map context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
/**
* Convenient method to execute with a single long parameter.
* @param p1 single long parameter
*/
public List execute(long p1) throws DataAccessException {
public List<T> execute(long p1) throws DataAccessException {
return execute(p1, null);
}
@ -195,7 +195,7 @@ public abstract class SqlQuery extends SqlOperation {
* @param p1 single String parameter
* @param context the contextual information for object creation
*/
public List execute(String p1, Map context) throws DataAccessException {
public List<T> execute(String p1, Map context) throws DataAccessException {
return execute(new Object[] {p1}, context);
}
@ -203,7 +203,7 @@ public abstract class SqlQuery extends SqlOperation {
* Convenient method to execute with a single String parameter.
* @param p1 single String parameter
*/
public List execute(String p1) throws DataAccessException {
public List<T> execute(String p1) throws DataAccessException {
return execute(p1, null);
}
@ -219,13 +219,13 @@ public abstract class SqlQuery extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public List executeByNamedParam(Map paramMap, Map context) throws DataAccessException {
public List<T> executeByNamedParam(Map<String, ?> paramMap, Map context) throws DataAccessException {
validateNamedParameters(paramMap);
ParsedSql parsedSql = getParsedSql();
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
String sqlToUse = NamedParameterUtils.substituteNamedParameters(parsedSql, paramSource);
Object[] params = NamedParameterUtils.buildValueArray(parsedSql, paramSource, getDeclaredParameters());
RowMapper rowMapper = newRowMapper(params, context);
RowMapper<T> rowMapper = newRowMapper(params, context);
return getJdbcTemplate().query(newPreparedStatementCreator(sqlToUse, params), rowMapper);
}
@ -235,7 +235,7 @@ public abstract class SqlQuery extends SqlOperation {
* the SqlParameters. Primitive parameters must be represented by their Object wrapper
* type. The ordering of parameters is not significant.
*/
public List executeByNamedParam(Map paramMap) throws DataAccessException {
public List<T> executeByNamedParam(Map<String, ?> paramMap) throws DataAccessException {
return executeByNamedParam(paramMap, null);
}
@ -248,15 +248,15 @@ public abstract class SqlQuery extends SqlOperation {
* choose to treat this as an error and throw an exception.
* @see org.springframework.dao.support.DataAccessUtils#singleResult
*/
public Object findObject(Object[] params, Map context) throws DataAccessException {
List results = execute(params, context);
public T findObject(Object[] params, Map context) throws DataAccessException {
List<T> results = execute(params, context);
return DataAccessUtils.singleResult(results);
}
/**
* Convenient method to find a single object without context.
*/
public Object findObject(Object[] params) throws DataAccessException {
public T findObject(Object... params) throws DataAccessException {
return findObject(params, null);
}
@ -264,14 +264,14 @@ public abstract class SqlQuery extends SqlOperation {
* Convenient method to find a single object given a single int parameter
* and a context.
*/
public Object findObject(int p1, Map context) throws DataAccessException {
return findObject(new Object[] {new Integer(p1)}, context);
public T findObject(int p1, Map context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
/**
* Convenient method to find a single object given a single int parameter.
*/
public Object findObject(int p1) throws DataAccessException {
public T findObject(int p1) throws DataAccessException {
return findObject(p1, null);
}
@ -279,14 +279,14 @@ public abstract class SqlQuery extends SqlOperation {
* Convenient method to find a single object given two int parameters
* and a context.
*/
public Object findObject(int p1, int p2, Map context) throws DataAccessException {
return findObject(new Object[] {new Integer(p1), new Integer(p2)}, context);
public T findObject(int p1, int p2, Map context) throws DataAccessException {
return findObject(new Object[] {p1, p2}, context);
}
/**
* Convenient method to find a single object given two int parameters.
*/
public Object findObject(int p1, int p2) throws DataAccessException {
public T findObject(int p1, int p2) throws DataAccessException {
return findObject(p1, p2, null);
}
@ -294,14 +294,14 @@ public abstract class SqlQuery extends SqlOperation {
* Convenient method to find a single object given a single long parameter
* and a context.
*/
public Object findObject(long p1, Map context) throws DataAccessException {
return findObject(new Object[] {new Long(p1)}, context);
public T findObject(long p1, Map context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
/**
* Convenient method to find a single object given a single long parameter.
*/
public Object findObject(long p1) throws DataAccessException {
public T findObject(long p1) throws DataAccessException {
return findObject(p1, null);
}
@ -309,14 +309,14 @@ public abstract class SqlQuery extends SqlOperation {
* Convenient method to find a single object given a single String parameter
* and a context.
*/
public Object findObject(String p1, Map context) throws DataAccessException {
public T findObject(String p1, Map context) throws DataAccessException {
return findObject(new Object[] {p1}, context);
}
/**
* Convenient method to find a single object given a single String parameter.
*/
public Object findObject(String p1) throws DataAccessException {
public T findObject(String p1) throws DataAccessException {
return findObject(p1, null);
}
@ -331,8 +331,8 @@ public abstract class SqlQuery extends SqlOperation {
* @return a List of objects, one per row of the ResultSet. Normally all these
* will be of the same class, although it is possible to use different types.
*/
public Object findObjectByNamedParam(Map paramMap, Map context) throws DataAccessException {
List results = executeByNamedParam(paramMap, context);
public T findObjectByNamedParam(Map<String, ?> paramMap, Map context) throws DataAccessException {
List<T> results = executeByNamedParam(paramMap, context);
return DataAccessUtils.singleResult(results);
}
@ -342,7 +342,7 @@ public abstract class SqlQuery extends SqlOperation {
* matching named parameters specified in the SQL statement.
* Ordering is not significant.
*/
public Object findObjectByNamedParam(Map paramMap) throws DataAccessException {
public T findObjectByNamedParam(Map<String, ?> paramMap) throws DataAccessException {
return findObjectByNamedParam(paramMap, null);
}
@ -358,6 +358,6 @@ public abstract class SqlQuery extends SqlOperation {
* but it can be useful for creating the objects of the result list.
* @see #execute
*/
protected abstract RowMapper newRowMapper(Object[] parameters, Map context);
protected abstract RowMapper<T> newRowMapper(Object[] parameters, Map context);
}

View File

@ -163,7 +163,7 @@ public class SqlUpdate extends SqlOperation {
* @param params array of parameters objects
* @return the number of rows affected by the update
*/
public int update(Object[] params) throws DataAccessException {
public int update(Object... params) throws DataAccessException {
validateParameters(params);
int rowsAffected = getJdbcTemplate().update(newPreparedStatementCreator(params));
checkRowsAffected(rowsAffected);
@ -195,28 +195,28 @@ public class SqlUpdate extends SqlOperation {
* Convenient method to execute an update given one int arg.
*/
public int update(int p1) throws DataAccessException {
return update(new Object[] {new Integer(p1)});
return update(new Object[] {p1});
}
/**
* Convenient method to execute an update given two int args.
*/
public int update(int p1, int p2) throws DataAccessException {
return update(new Object[] {new Integer(p1), new Integer(p2)});
return update(new Object[] {p1, p2});
}
/**
* Convenient method to execute an update given one long arg.
*/
public int update(long p1) throws DataAccessException {
return update(new Object[] {new Long(p1)});
return update(new Object[] {p1});
}
/**
* Convenient method to execute an update given two long args.
*/
public int update(long p1, long p2) throws DataAccessException {
return update(new Object[] {new Long(p1), new Long(p2)});
return update(new Object[] {p1, p2});
}
/**

View File

@ -1,12 +1,12 @@
/*
* Copyright 2002-2005 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.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -35,7 +35,7 @@ import org.springframework.jdbc.core.RowMapper;
* @author Thomas Risberg
* @see org.springframework.jdbc.object.SqlQuery
*/
public abstract class UpdatableSqlQuery extends SqlQuery {
public abstract class UpdatableSqlQuery<T> extends SqlQuery<T> {
/**
* Constructor to allow use as a JavaBean
@ -54,12 +54,13 @@ public abstract class UpdatableSqlQuery extends SqlQuery {
setUpdatableResults(true);
}
/**
* Implementation of the superclass template method. This invokes the subclass's
* implementation of the <code>updateRow()</code> method.
*/
@Override
protected RowMapper newRowMapper(Object[] parameters, Map context) {
protected RowMapper<T> newRowMapper(Object[] parameters, Map context) {
return new RowMapperImpl(context);
}
@ -78,14 +79,14 @@ public abstract class UpdatableSqlQuery extends SqlQuery {
* Subclasses can simply not catch SQLExceptions, relying on the
* framework to clean up.
*/
protected abstract Object updateRow(ResultSet rs, int rowNum, Map context) throws SQLException;
protected abstract T updateRow(ResultSet rs, int rowNum, Map context) throws SQLException;
/**
* Implementation of RowMapper that calls the enclosing
* class's <code>updateRow()</code> method for each row.
*/
protected class RowMapperImpl implements RowMapper {
protected class RowMapperImpl implements RowMapper<T> {
private final Map context;
@ -93,8 +94,8 @@ public abstract class UpdatableSqlQuery extends SqlQuery {
this.context = context;
}
public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
Object result = updateRow(rs, rowNum, this.context);
public T mapRow(ResultSet rs, int rowNum) throws SQLException {
T result = updateRow(rs, rowNum, this.context);
rs.updateRow();
return result;
}

View File

@ -142,32 +142,32 @@ public abstract class JdbcUtils {
value = rs.getString(index);
}
else if (boolean.class.equals(requiredType) || Boolean.class.equals(requiredType)) {
value = Boolean.valueOf(rs.getBoolean(index));
value = rs.getBoolean(index);
wasNullCheck = true;
}
else if (byte.class.equals(requiredType) || Byte.class.equals(requiredType)) {
value = new Byte(rs.getByte(index));
value = rs.getByte(index);
wasNullCheck = true;
}
else if (short.class.equals(requiredType) || Short.class.equals(requiredType)) {
value = new Short(rs.getShort(index));
value = rs.getShort(index);
wasNullCheck = true;
}
else if (int.class.equals(requiredType) || Integer.class.equals(requiredType)) {
value = new Integer(rs.getInt(index));
value = rs.getInt(index);
wasNullCheck = true;
}
else if (long.class.equals(requiredType) || Long.class.equals(requiredType)) {
value = new Long(rs.getLong(index));
value = rs.getLong(index);
wasNullCheck = true;
}
else if (float.class.equals(requiredType) || Float.class.equals(requiredType)) {
value = new Float(rs.getFloat(index));
value = rs.getFloat(index);
wasNullCheck = true;
}
else if (double.class.equals(requiredType) || Double.class.equals(requiredType) ||
Number.class.equals(requiredType)) {
value = new Double(rs.getDouble(index));
value = rs.getDouble(index);
wasNullCheck = true;
}
else if (byte[].class.equals(requiredType)) {

View File

@ -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.
@ -96,9 +96,9 @@ public class OracleLobHandler extends AbstractLobHandler {
private Class clobClass;
private final Map durationSessionConstants = new HashMap(2);
private final Map<Class, Integer> durationSessionConstants = new HashMap<Class, Integer>(2);
private final Map modeReadWriteConstants = new HashMap(2);
private final Map<Class, Integer> modeReadWriteConstants = new HashMap<Class, Integer>(2);
/**
@ -128,7 +128,7 @@ public class OracleLobHandler extends AbstractLobHandler {
* @see oracle.sql.CLOB#createTemporary
*/
public void setCache(boolean cache) {
this.cache = new Boolean(cache);
this.cache = cache;
}
@ -149,16 +149,16 @@ public class OracleLobHandler extends AbstractLobHandler {
// Initialize oracle.sql.BLOB class
this.blobClass = con.getClass().getClassLoader().loadClass(BLOB_CLASS_NAME);
this.durationSessionConstants.put(
this.blobClass, new Integer(this.blobClass.getField(DURATION_SESSION_FIELD_NAME).getInt(null)));
this.blobClass, this.blobClass.getField(DURATION_SESSION_FIELD_NAME).getInt(null));
this.modeReadWriteConstants.put(
this.blobClass, new Integer(this.blobClass.getField(MODE_READWRITE_FIELD_NAME).getInt(null)));
this.blobClass, this.blobClass.getField(MODE_READWRITE_FIELD_NAME).getInt(null));
// Initialize oracle.sql.CLOB class
this.clobClass = con.getClass().getClassLoader().loadClass(CLOB_CLASS_NAME);
this.durationSessionConstants.put(
this.clobClass, new Integer(this.clobClass.getField(DURATION_SESSION_FIELD_NAME).getInt(null)));
this.clobClass, this.clobClass.getField(DURATION_SESSION_FIELD_NAME).getInt(null));
this.modeReadWriteConstants.put(
this.clobClass, new Integer(this.clobClass.getField(MODE_READWRITE_FIELD_NAME).getInt(null)));
this.clobClass, this.clobClass.getField(MODE_READWRITE_FIELD_NAME).getInt(null));
}
catch (Exception ex) {
throw new InvalidDataAccessApiUsageException(
@ -219,8 +219,8 @@ public class OracleLobHandler extends AbstractLobHandler {
if (content != null) {
Blob blob = (Blob) createLob(ps, false, new LobCallback() {
public void populateLob(Object lob) throws Exception {
Method methodToInvoke = lob.getClass().getMethod("getBinaryOutputStream", new Class[0]);
OutputStream out = (OutputStream) methodToInvoke.invoke(lob, (Object[]) null);
Method methodToInvoke = lob.getClass().getMethod("getBinaryOutputStream");
OutputStream out = (OutputStream) methodToInvoke.invoke(lob);
FileCopyUtils.copy(content, out);
}
});
@ -389,11 +389,10 @@ public class OracleLobHandler extends AbstractLobHandler {
return blob;
*/
Method createTemporary = lobClass.getMethod(
"createTemporary", new Class[] {Connection.class, boolean.class, int.class});
Object lob = createTemporary.invoke(
null, new Object[] {con, cache, durationSessionConstants.get(lobClass)});
Method open = lobClass.getMethod("open", new Class[] {int.class});
open.invoke(lob, new Object[] {modeReadWriteConstants.get(lobClass)});
"createTemporary", Connection.class, boolean.class, int.class);
Object lob = createTemporary.invoke(null, con, cache, durationSessionConstants.get(lobClass));
Method open = lobClass.getMethod("open", int.class);
open.invoke(lob, modeReadWriteConstants.get(lobClass));
return lob;
}
@ -408,8 +407,8 @@ public class OracleLobHandler extends AbstractLobHandler {
blob.freeTemporary();
*/
Object lob = it.next();
Method freeTemporary = lob.getClass().getMethod("freeTemporary", new Class[0]);
freeTemporary.invoke(lob, new Object[0]);
Method freeTemporary = lob.getClass().getMethod("freeTemporary");
freeTemporary.invoke(lob);
it.remove();
}
}

View File

@ -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.
@ -220,8 +220,8 @@ abstract class AbstractListenerContainerParser implements BeanDefinitionParser {
parserContext.getReaderContext().error("Invalid listener container 'destination-type': " +
"only \"queue\", \"topic\" and \"durableTopic\" supported.", ele);
}
configDef.getPropertyValues().addPropertyValue("pubSubDomain", Boolean.valueOf(pubSubDomain));
configDef.getPropertyValues().addPropertyValue("subscriptionDurable", Boolean.valueOf(subscriptionDurable));
configDef.getPropertyValues().addPropertyValue("pubSubDomain", pubSubDomain);
configDef.getPropertyValues().addPropertyValue("subscriptionDurable", subscriptionDurable);
if (ele.hasAttribute(CLIENT_ID_ATTRIBUTE)) {
String clientId = ele.getAttribute(CLIENT_ID_ATTRIBUTE);
@ -250,7 +250,7 @@ abstract class AbstractListenerContainerParser implements BeanDefinitionParser {
parserContext.getReaderContext().error("Invalid listener container 'acknowledge' setting [" +
acknowledge + "]: only \"auto\", \"client\", \"dups-ok\" and \"transacted\" supported.", ele);
}
return new Integer(acknowledgeMode);
return acknowledgeMode;
}
else {
return null;
@ -258,7 +258,7 @@ abstract class AbstractListenerContainerParser implements BeanDefinitionParser {
}
protected boolean indicatesPubSubConfig(BeanDefinition configDef) {
return ((Boolean) configDef.getPropertyValues().getPropertyValue("pubSubDomain").getValue()).booleanValue();
return (Boolean) configDef.getPropertyValues().getPropertyValue("pubSubDomain").getValue();
}
protected int[] parseConcurrency(Element ele, ParserContext parserContext) {

View File

@ -89,7 +89,7 @@ class JcaListenerContainerParser extends AbstractListenerContainerParser {
int[] concurrency = parseConcurrency(containerEle, parserContext);
if (concurrency != null) {
configDef.getPropertyValues().addPropertyValue("maxConcurrency", new Integer(concurrency[1]));
configDef.getPropertyValues().addPropertyValue("maxConcurrency", concurrency[1]);
}
String prefetch = containerEle.getAttribute(PREFETCH_ATTRIBUTE);

View File

@ -114,7 +114,7 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
Integer acknowledgeMode = parseAcknowledgeMode(containerEle, parserContext);
if (acknowledgeMode != null) {
if (acknowledgeMode.intValue() == Session.SESSION_TRANSACTED) {
if (acknowledgeMode == Session.SESSION_TRANSACTED) {
containerDef.getPropertyValues().addPropertyValue("sessionTransacted", Boolean.TRUE);
}
else {
@ -137,11 +137,11 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
int[] concurrency = parseConcurrency(containerEle, parserContext);
if (concurrency != null) {
if (containerType.startsWith("default")) {
containerDef.getPropertyValues().addPropertyValue("concurrentConsumers", new Integer(concurrency[0]));
containerDef.getPropertyValues().addPropertyValue("maxConcurrentConsumers", new Integer(concurrency[1]));
containerDef.getPropertyValues().addPropertyValue("concurrentConsumers", concurrency[0]);
containerDef.getPropertyValues().addPropertyValue("maxConcurrentConsumers", concurrency[1]);
}
else {
containerDef.getPropertyValues().addPropertyValue("concurrentConsumers", new Integer(concurrency[1]));
containerDef.getPropertyValues().addPropertyValue("concurrentConsumers", concurrency[1]);
}
}

View File

@ -281,7 +281,7 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
String methodName = method.getName();
if (methodName.equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (methodName.equals("hashCode")) {
// Use hashCode of Session proxy.

View File

@ -473,7 +473,7 @@ public class SingleConnectionFactory
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.

View File

@ -223,11 +223,11 @@ public class TransactionAwareConnectionFactoryProxy
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (Session.class.equals(method.getReturnType())) {
Session session = ConnectionFactoryUtils.getTransactionalSession(
@ -295,11 +295,11 @@ public class TransactionAwareConnectionFactoryProxy
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("commit")) {
throw new TransactionInProgressException("Commit call not allowed within a managed transaction");

View File

@ -1279,7 +1279,7 @@ public class HibernateTemplate extends HibernateAccessor implements HibernateOpe
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Session proxy.

View File

@ -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.
@ -145,8 +145,8 @@ public class OpenSessionInViewInterceptor extends HibernateAccessor implements W
// Do not modify the Session: just mark the request accordingly.
String participateAttributeName = getParticipateAttributeName();
Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
int newCount = (count != null) ? count.intValue() + 1 : 1;
request.setAttribute(getParticipateAttributeName(), new Integer(newCount), WebRequest.SCOPE_REQUEST);
int newCount = (count != null ? count + 1 : 1);
request.setAttribute(getParticipateAttributeName(), newCount, WebRequest.SCOPE_REQUEST);
}
else {
if (isSingleSession()) {
@ -197,8 +197,8 @@ public class OpenSessionInViewInterceptor extends HibernateAccessor implements W
Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
if (count != null) {
// Do not modify the Session: just clear the marker.
if (count.intValue() > 1) {
request.setAttribute(participateAttributeName, new Integer(count.intValue() - 1), WebRequest.SCOPE_REQUEST);
if (count > 1) {
request.setAttribute(participateAttributeName, count - 1, WebRequest.SCOPE_REQUEST);
}
else {
request.removeAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2006 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.
@ -31,7 +31,7 @@ import com.ibatis.sqlmap.client.SqlMapExecutor;
* @see SqlMapClientTemplate
* @see org.springframework.jdbc.datasource.DataSourceTransactionManager
*/
public interface SqlMapClientCallback {
public interface SqlMapClientCallback<T> {
/**
* Gets called by <code>SqlMapClientTemplate.execute</code> with an active
@ -57,6 +57,6 @@ public interface SqlMapClientCallback {
* @see SqlMapClientTemplate#executeWithListResult
* @see SqlMapClientTemplate#executeWithMapResult
*/
Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException;
T doInSqlMapClient(SqlMapExecutor executor) throws SQLException;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2002-2006 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.
@ -103,24 +103,6 @@ public interface SqlMapClientOperations {
void queryWithRowHandler(String statementName, Object parameterObject, RowHandler rowHandler)
throws DataAccessException;
/**
* @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForPaginatedList(String, int)
* @deprecated as of iBATIS 2.3.0
* @throws org.springframework.dao.DataAccessException in case of errors
*/
@Deprecated
PaginatedList queryForPaginatedList(String statementName, int pageSize)
throws DataAccessException;
/**
* @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForPaginatedList(String, Object, int)
* @deprecated as of iBATIS 2.3.0
* @throws org.springframework.dao.DataAccessException in case of errors
*/
@Deprecated
PaginatedList queryForPaginatedList(String statementName, Object parameterObject, int pageSize)
throws DataAccessException;
/**
* @see com.ibatis.sqlmap.client.SqlMapExecutor#queryForMap(String, Object, String)
* @throws org.springframework.dao.DataAccessException in case of errors

View File

@ -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.
@ -20,18 +20,14 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import javax.sql.DataSource;
import com.ibatis.common.util.PaginatedList;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapExecutor;
import com.ibatis.sqlmap.client.SqlMapSession;
import com.ibatis.sqlmap.client.event.RowHandler;
import com.ibatis.sqlmap.engine.impl.ExtendedSqlMapClient;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.jdbc.CannotGetJdbcConnectionException;
import org.springframework.jdbc.JdbcUpdateAffectedIncorrectNumberOfRowsException;
import org.springframework.jdbc.datasource.DataSourceUtils;
@ -89,8 +85,6 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
private SqlMapClient sqlMapClient;
private boolean lazyLoadingAvailable = true;
/**
* Create a new SqlMapClientTemplate.
@ -148,11 +142,6 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
if (this.sqlMapClient == null) {
throw new IllegalArgumentException("Property 'sqlMapClient' is required");
}
if (this.sqlMapClient instanceof ExtendedSqlMapClient) {
// Check whether iBATIS lazy loading is available, that is,
// whether a DataSource was specified on the SqlMapClient itself.
this.lazyLoadingAvailable = (((ExtendedSqlMapClient) this.sqlMapClient).getDelegate().getTxManager() != null);
}
super.afterPropertiesSet();
}
@ -163,7 +152,7 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
* @return a result object returned by the action, or <code>null</code>
* @throws DataAccessException in case of SQL Maps errors
*/
public Object execute(SqlMapClientCallback action) throws DataAccessException {
public <T> T execute(SqlMapClientCallback<T> action) throws DataAccessException {
Assert.notNull(action, "Callback object must not be null");
Assert.notNull(this.sqlMapClient, "No SqlMapClient specified");
@ -246,9 +235,12 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
* @param action callback object that specifies the data access action
* @return the List result
* @throws DataAccessException in case of SQL Maps errors
* @deprecated as of Spring 3.0 - not really needed anymore with generic
* {@link #execute} method
*/
public List executeWithListResult(SqlMapClientCallback action) throws DataAccessException {
return (List) execute(action);
@Deprecated
public List executeWithListResult(SqlMapClientCallback<List> action) throws DataAccessException {
return execute(action);
}
/**
@ -257,9 +249,12 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
* @param action callback object that specifies the data access action
* @return the Map result
* @throws DataAccessException in case of SQL Maps errors
* @deprecated as of Spring 3.0 - not really needed anymore with generic
* {@link #execute} method
*/
public Map executeWithMapResult(SqlMapClientCallback action) throws DataAccessException {
return (Map) execute(action);
@Deprecated
public Map executeWithMapResult(SqlMapClientCallback<Map> action) throws DataAccessException {
return execute(action);
}
@ -270,7 +265,7 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
public Object queryForObject(final String statementName, final Object parameterObject)
throws DataAccessException {
return execute(new SqlMapClientCallback() {
return execute(new SqlMapClientCallback<Object>() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.queryForObject(statementName, parameterObject);
}
@ -281,7 +276,7 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
final String statementName, final Object parameterObject, final Object resultObject)
throws DataAccessException {
return execute(new SqlMapClientCallback() {
return execute(new SqlMapClientCallback<Object>() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.queryForObject(statementName, parameterObject, resultObject);
}
@ -295,8 +290,8 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
public List queryForList(final String statementName, final Object parameterObject)
throws DataAccessException {
return executeWithListResult(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return execute(new SqlMapClientCallback<List>() {
public List doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.queryForList(statementName, parameterObject);
}
});
@ -312,8 +307,8 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
final String statementName, final Object parameterObject, final int skipResults, final int maxResults)
throws DataAccessException {
return executeWithListResult(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return execute(new SqlMapClientCallback<List>() {
public List doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.queryForList(statementName, parameterObject, skipResults, maxResults);
}
});
@ -329,7 +324,7 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
final String statementName, final Object parameterObject, final RowHandler rowHandler)
throws DataAccessException {
execute(new SqlMapClientCallback() {
execute(new SqlMapClientCallback<Object>() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
executor.queryWithRowHandler(statementName, parameterObject, rowHandler);
return null;
@ -337,44 +332,12 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
});
}
/**
* @deprecated as of iBATIS 2.3.0
*/
@Deprecated
public PaginatedList queryForPaginatedList(String statementName, int pageSize)
throws DataAccessException {
return queryForPaginatedList(statementName, null, pageSize);
}
/**
* @deprecated as of iBATIS 2.3.0
*/
@Deprecated
public PaginatedList queryForPaginatedList(
final String statementName, final Object parameterObject, final int pageSize)
throws DataAccessException {
// Throw exception if lazy loading will not work.
if (!this.lazyLoadingAvailable) {
throw new InvalidDataAccessApiUsageException(
"SqlMapClient needs to have DataSource to allow for lazy loading" +
" - specify SqlMapClientFactoryBean's 'dataSource' property");
}
return (PaginatedList) execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.queryForPaginatedList(statementName, parameterObject, pageSize);
}
});
}
public Map queryForMap(
final String statementName, final Object parameterObject, final String keyProperty)
throws DataAccessException {
return executeWithMapResult(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return execute(new SqlMapClientCallback<Map>() {
public Map doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.queryForMap(statementName, parameterObject, keyProperty);
}
});
@ -384,8 +347,8 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
final String statementName, final Object parameterObject, final String keyProperty, final String valueProperty)
throws DataAccessException {
return executeWithMapResult(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return execute(new SqlMapClientCallback<Map>() {
public Map doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.queryForMap(statementName, parameterObject, keyProperty, valueProperty);
}
});
@ -398,7 +361,7 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
public Object insert(final String statementName, final Object parameterObject)
throws DataAccessException {
return execute(new SqlMapClientCallback() {
return execute(new SqlMapClientCallback<Object>() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.insert(statementName, parameterObject);
}
@ -412,12 +375,11 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
public int update(final String statementName, final Object parameterObject)
throws DataAccessException {
Integer result = (Integer) execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return new Integer(executor.update(statementName, parameterObject));
return execute(new SqlMapClientCallback<Integer>() {
public Integer doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.update(statementName, parameterObject);
}
});
return result.intValue();
}
public void update(String statementName, Object parameterObject, int requiredRowsAffected)
@ -437,12 +399,11 @@ public class SqlMapClientTemplate extends JdbcAccessor implements SqlMapClientOp
public int delete(final String statementName, final Object parameterObject)
throws DataAccessException {
Integer result = (Integer) execute(new SqlMapClientCallback() {
public Object doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return new Integer(executor.delete(statementName, parameterObject));
return execute(new SqlMapClientCallback<Integer>() {
public Integer doInSqlMapClient(SqlMapExecutor executor) throws SQLException {
return executor.delete(statementName, parameterObject);
}
});
return result.intValue();
}
public void delete(String statementName, Object parameterObject, int requiredRowsAffected)

View File

@ -574,11 +574,11 @@ public class JdoTemplate extends JdoAccessor implements JdoOperations {
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of PersistenceManager proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("close")) {
// Handle close method: suppress, not valid.

View File

@ -148,18 +148,18 @@ public class TransactionAwarePersistenceManagerFactoryProxy implements FactoryBe
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of PersistenceManagerFactory proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("getPersistenceManager")) {
PersistenceManagerFactory target = getTargetPersistenceManagerFactory();
PersistenceManager pm =
PersistenceManagerFactoryUtils.doGetPersistenceManager(target, isAllowCreate());
Class[] ifcs = ClassUtils.getAllInterfacesForClass(pm.getClass(), getClass().getClassLoader());
return (PersistenceManager) Proxy.newProxyInstance(
return Proxy.newProxyInstance(
pm.getClass().getClassLoader(), ifcs, new TransactionAwareInvocationHandler(pm, target));
}
@ -194,11 +194,11 @@ public class TransactionAwarePersistenceManagerFactoryProxy implements FactoryBe
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of PersistenceManager proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("close")) {
// Handle close method: only close if not within a transaction.

View File

@ -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.
@ -94,8 +94,8 @@ public class OpenPersistenceManagerInViewInterceptor implements WebRequestInterc
// Do not modify the PersistenceManager: just mark the request accordingly.
String participateAttributeName = getParticipateAttributeName();
Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
int newCount = (count != null) ? count.intValue() + 1 : 1;
request.setAttribute(getParticipateAttributeName(), new Integer(newCount), WebRequest.SCOPE_REQUEST);
int newCount = (count != null ? count + 1 : 1);
request.setAttribute(getParticipateAttributeName(), newCount, WebRequest.SCOPE_REQUEST);
}
else {
logger.debug("Opening JDO PersistenceManager in OpenPersistenceManagerInViewInterceptor");
@ -114,8 +114,8 @@ public class OpenPersistenceManagerInViewInterceptor implements WebRequestInterc
Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
if (count != null) {
// Do not modify the PersistenceManager: just clear the marker.
if (count.intValue() > 1) {
request.setAttribute(participateAttributeName, new Integer(count.intValue() - 1), WebRequest.SCOPE_REQUEST);
if (count > 1) {
request.setAttribute(participateAttributeName, count - 1, WebRequest.SCOPE_REQUEST);
}
else {
request.removeAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);

View File

@ -415,7 +415,7 @@ public abstract class AbstractEntityManagerFactoryBean implements
try {
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of EntityManagerFactory proxy.

View File

@ -247,10 +247,10 @@ public class JpaTemplate extends JpaAccessor implements JpaOperations {
public boolean contains(final Object entity) throws DataAccessException {
Boolean result = (Boolean) execute(new JpaCallback() {
public Object doInJpa(EntityManager em) throws PersistenceException {
return new Boolean(em.contains(entity));
return em.contains(entity);
}
}, true);
return result.booleanValue();
return result;
}
public void refresh(final Object entity) throws DataAccessException {
@ -388,11 +388,11 @@ public class JpaTemplate extends JpaAccessor implements JpaOperations {
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of EntityManager proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("close")) {
// Handle close method: suppress, not valid.

View File

@ -72,8 +72,8 @@ public class OpenEntityManagerInViewInterceptor extends EntityManagerFactoryAcce
// do not modify the EntityManager: just mark the request accordingly
String participateAttributeName = getParticipateAttributeName();
Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
int newCount = (count != null) ? count.intValue() + 1 : 1;
request.setAttribute(getParticipateAttributeName(), new Integer(newCount), WebRequest.SCOPE_REQUEST);
int newCount = (count != null ? count + 1 : 1);
request.setAttribute(getParticipateAttributeName(), newCount, WebRequest.SCOPE_REQUEST);
}
else {
logger.debug("Opening JPA EntityManager in OpenEntityManagerInViewInterceptor");
@ -95,8 +95,8 @@ public class OpenEntityManagerInViewInterceptor extends EntityManagerFactoryAcce
Integer count = (Integer) request.getAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);
if (count != null) {
// Do not modify the EntityManager: just clear the marker.
if (count.intValue() > 1) {
request.setAttribute(participateAttributeName, new Integer(count.intValue() - 1), WebRequest.SCOPE_REQUEST);
if (count > 1) {
request.setAttribute(participateAttributeName, count - 1, WebRequest.SCOPE_REQUEST);
}
else {
request.removeAttribute(participateAttributeName, WebRequest.SCOPE_REQUEST);

View File

@ -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.
@ -25,8 +25,6 @@ import java.util.Map;
import javax.sql.DataSource;
import com.ibatis.common.util.PaginatedArrayList;
import com.ibatis.common.util.PaginatedList;
import com.ibatis.sqlmap.client.SqlMapClient;
import com.ibatis.sqlmap.client.SqlMapExecutor;
import com.ibatis.sqlmap.client.SqlMapSession;
@ -266,26 +264,6 @@ public class SqlMapClientTests extends TestCase {
template.executorControl.verify();
}
public void testQueryForPaginatedList() throws SQLException {
PaginatedList result = new PaginatedArrayList(10);
TestSqlMapClientTemplate template = new TestSqlMapClientTemplate();
template.executor.queryForPaginatedList("myStatement", null, 10);
template.executorControl.setReturnValue(result, 1);
template.executorControl.replay();
assertEquals(result, template.queryForPaginatedList("myStatement", 10));
template.executorControl.verify();
}
public void testQueryForPaginatedListWithParameter() throws SQLException {
PaginatedList result = new PaginatedArrayList(10);
TestSqlMapClientTemplate template = new TestSqlMapClientTemplate();
template.executor.queryForPaginatedList("myStatement", "myParameter", 10);
template.executorControl.setReturnValue(result, 1);
template.executorControl.replay();
assertEquals(result, template.queryForPaginatedList("myStatement", "myParameter", 10));
template.executorControl.verify();
}
public void testQueryForMap() throws SQLException {
Map result = new HashMap();
TestSqlMapClientTemplate template = new TestSqlMapClientTemplate();

View File

@ -230,11 +230,11 @@ public class SingleConnectionFactory extends DelegatingConnectionFactory impleme
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("close")) {
// Handle close method: don't pass the call on.

View File

@ -132,11 +132,11 @@ public class TransactionAwareConnectionFactoryProxy extends DelegatingConnection
if (method.getName().equals("equals")) {
// Only consider equal when proxies are identical.
return (proxy == args[0] ? Boolean.TRUE : Boolean.FALSE);
return (proxy == args[0]);
}
else if (method.getName().equals("hashCode")) {
// Use hashCode of Connection proxy.
return new Integer(System.identityHashCode(proxy));
return System.identityHashCode(proxy);
}
else if (method.getName().equals("getLocalTransaction")) {
if (ConnectionFactoryUtils.isConnectionTransactional(this.target, this.connectionFactory)) {

View File

@ -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.
@ -99,12 +99,12 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
protected UserTransaction retrieveUserTransaction() throws TransactionSystemException {
try {
Class transactionUtilityClass = getClass().getClassLoader().loadClass(TRANSACTION_UTILITY_CLASS_NAME);
Method getInstanceMethod = transactionUtilityClass.getMethod("getInstance", new Class[0]);
Object transactionUtility = getInstanceMethod.invoke(null, new Object[0]);
Method getInstanceMethod = transactionUtilityClass.getMethod("getInstance");
Object transactionUtility = getInstanceMethod.invoke(null);
logger.debug("Retrieving JTA UserTransaction from OC4J TransactionUtility");
Method getUserTransactionMethod =
transactionUtility.getClass().getMethod("getOC4JUserTransaction", new Class[0]);
return (UserTransaction) getUserTransactionMethod.invoke(transactionUtility, new Object[0]);
transactionUtility.getClass().getMethod("getOC4JUserTransaction");
return (UserTransaction) getUserTransactionMethod.invoke(transactionUtility);
}
catch (ClassNotFoundException ex) {
logger.debug("Could not find OC4J 10.1.3.2 TransactionUtility: " + ex);
@ -144,9 +144,9 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
// Cache reflective Method references for later use.
if (transactionManagerClass.isInstance(getUserTransaction())) {
this.beginWithNameMethod = ClassUtils.getMethodIfAvailable(
transactionManagerClass, "begin", new Class[] {String.class});
transactionManagerClass, "begin", String.class);
this.setTransactionIsolationMethod = ClassUtils.getMethodIfAvailable(
transactionClass, "setTransactionIsolation", new Class[] {int.class});
transactionClass, "setTransactionIsolation", int.class);
logger.info("Support for OC4J transaction names and isolation levels available");
}
else {
@ -169,7 +169,7 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
otm.begin(definition.getName());
*/
try {
this.beginWithNameMethod.invoke(txObject.getUserTransaction(), new Object[] {definition.getName()});
this.beginWithNameMethod.invoke(txObject.getUserTransaction(), definition.getName());
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@ -195,8 +195,7 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
oracle.j2ee.transaction.OC4JTransaction otx = (oracle.j2ee.transaction.OC4JTransaction) tx;
otx.setTransactionIsolation(definition.getIsolationLevel());
*/
Integer isolationLevel = new Integer(definition.getIsolationLevel());
this.setTransactionIsolationMethod.invoke(tx, new Object[] {isolationLevel});
this.setTransactionIsolationMethod.invoke(tx, definition.getIsolationLevel());
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@ -222,7 +221,7 @@ public class OC4JJtaTransactionManager extends JtaTransactionManager {
ut.setTransactionTimeout(timeout);
}
try {
this.beginWithNameMethod.invoke(ut, new Object[] {name});
this.beginWithNameMethod.invoke(ut, name);
}
catch (InvocationTargetException ex) {
if (ex.getTargetException() instanceof NotSupportedException) {

View File

@ -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.
@ -117,8 +117,8 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
try {
logger.debug("Retrieving JTA UserTransaction from WebLogic TransactionHelper/TxHelper");
Method getUserTransactionMethod =
this.transactionHelperClass.getMethod("getUserTransaction", new Class[0]);
return (UserTransaction) getUserTransactionMethod.invoke(this.transactionHelper, new Object[0]);
this.transactionHelperClass.getMethod("getUserTransaction");
return (UserTransaction) getUserTransactionMethod.invoke(this.transactionHelper);
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@ -135,9 +135,8 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
loadWebLogicTransactionHelperClass();
try {
logger.debug("Retrieving JTA TransactionManager from WebLogic TransactionHelper/TxHelper");
Method getTransactionManagerMethod =
this.transactionHelperClass.getMethod("getTransactionManager", new Class[0]);
return (TransactionManager) getTransactionManagerMethod.invoke(this.transactionHelper, new Object[0]);
Method getTransactionManagerMethod = this.transactionHelperClass.getMethod("getTransactionManager");
return (TransactionManager) getTransactionManagerMethod.invoke(this.transactionHelper);
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@ -158,7 +157,7 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
getClass().getClassLoader().loadClass(TRANSACTION_HELPER_CLASS_NAME);
Method getTransactionHelperMethod =
this.transactionHelperClass.getMethod("getTransactionHelper", new Class[0]);
this.transactionHelper = getTransactionHelperMethod.invoke(null, new Object[0]);
this.transactionHelper = getTransactionHelperMethod.invoke(null);
logger.debug("WebLogic 8.1+ TransactionHelper found");
}
catch (ClassNotFoundException ex) {
@ -246,16 +245,14 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
weblogic.transaction.UserTransaction wut = (weblogic.transaction.UserTransaction) ut;
wut.begin(definition.getName(), timeout);
*/
this.beginWithNameAndTimeoutMethod.invoke(txObject.getUserTransaction(),
new Object[] {definition.getName(), new Integer(timeout)});
this.beginWithNameAndTimeoutMethod.invoke(txObject.getUserTransaction(), definition.getName(), timeout);
}
else {
/*
weblogic.transaction.UserTransaction wut = (weblogic.transaction.UserTransaction) ut;
wut.begin(definition.getName());
*/
this.beginWithNameMethod.invoke(txObject.getUserTransaction(),
new Object[] {definition.getName()});
this.beginWithNameMethod.invoke(txObject.getUserTransaction(), definition.getName());
}
}
catch (InvocationTargetException ex) {
@ -279,12 +276,12 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
if (definition.getIsolationLevel() != TransactionDefinition.ISOLATION_DEFAULT) {
try {
Transaction tx = getTransactionManager().getTransaction();
Integer isolationLevel = new Integer(definition.getIsolationLevel());
Integer isolationLevel = definition.getIsolationLevel();
/*
weblogic.transaction.Transaction wtx = (weblogic.transaction.Transaction) tx;
wtx.setProperty(ISOLATION_LEVEL_KEY, isolationLevel);
*/
this.setPropertyMethod.invoke(tx, new Object[] {ISOLATION_LEVEL_KEY, isolationLevel});
this.setPropertyMethod.invoke(tx, ISOLATION_LEVEL_KEY, isolationLevel);
}
catch (InvocationTargetException ex) {
throw new TransactionSystemException(
@ -323,7 +320,7 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
wtm.forceResume(suspendedTransaction);
*/
try {
this.forceResumeMethod.invoke(getTransactionManager(), new Object[] {suspendedTransaction});
this.forceResumeMethod.invoke(getTransactionManager(), suspendedTransaction);
}
catch (InvocationTargetException ex2) {
throw new TransactionSystemException(
@ -342,10 +339,10 @@ public class WebLogicJtaTransactionManager extends JtaTransactionManager {
if (this.weblogicUserTransactionAvailable && name != null) {
try {
if (timeout >= 0) {
this.beginWithNameAndTimeoutMethod.invoke(getUserTransaction(), new Object[] {name, new Integer(timeout)});
this.beginWithNameAndTimeoutMethod.invoke(getUserTransaction(), name, timeout);
}
else {
this.beginWithNameMethod.invoke(getUserTransaction(), new Object[] {name});
this.beginWithNameMethod.invoke(getUserTransaction(), name);
}
}
catch (InvocationTargetException ex) {

View File

@ -127,7 +127,7 @@ public class DefaultTransactionDefinition implements TransactionDefinition, Seri
* @see #PROPAGATION_REQUIRED
*/
public final void setPropagationBehavior(int propagationBehavior) {
if (!constants.getValues(PREFIX_PROPAGATION).contains(new Integer(propagationBehavior))) {
if (!constants.getValues(PREFIX_PROPAGATION).contains(propagationBehavior)) {
throw new IllegalArgumentException("Only values of propagation constants allowed");
}
this.propagationBehavior = propagationBehavior;
@ -161,7 +161,7 @@ public class DefaultTransactionDefinition implements TransactionDefinition, Seri
* @see #ISOLATION_DEFAULT
*/
public final void setIsolationLevel(int isolationLevel) {
if (!constants.getValues(PREFIX_ISOLATION).contains(new Integer(isolationLevel))) {
if (!constants.getValues(PREFIX_ISOLATION).contains(isolationLevel)) {
throw new IllegalArgumentException("Only values of isolation constants allowed");
}
this.isolationLevel = isolationLevel;

View File

@ -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.
@ -60,7 +60,7 @@ public abstract class PortletRequestUtils {
if (request.getParameter(name) == null) {
return null;
}
return new Integer(getRequiredIntParameter(request, name));
return getRequiredIntParameter(request, name);
}
/**
@ -138,7 +138,7 @@ public abstract class PortletRequestUtils {
if (request.getParameter(name) == null) {
return null;
}
return new Long(getRequiredLongParameter(request, name));
return getRequiredLongParameter(request, name);
}
/**
@ -216,7 +216,7 @@ public abstract class PortletRequestUtils {
if (request.getParameter(name) == null) {
return null;
}
return new Float(getRequiredFloatParameter(request, name));
return getRequiredFloatParameter(request, name);
}
/**
@ -294,7 +294,7 @@ public abstract class PortletRequestUtils {
if (request.getParameter(name) == null) {
return null;
}
return new Double(getRequiredDoubleParameter(request, name));
return getRequiredDoubleParameter(request, name);
}
/**
@ -374,7 +374,7 @@ public abstract class PortletRequestUtils {
if (request.getParameter(name) == null) {
return null;
}
return (getRequiredBooleanParameter(request, name) ? Boolean.TRUE : Boolean.FALSE);
return (getRequiredBooleanParameter(request, name));
}
/**
@ -518,9 +518,9 @@ public abstract class PortletRequestUtils {
}
private abstract static class ParameterParser {
private abstract static class ParameterParser<T> {
protected final Object parse(String name, String parameter) throws PortletRequestBindingException {
protected final T parse(String name, String parameter) throws PortletRequestBindingException {
validateRequiredParameter(name, parameter);
try {
return doParse(parameter);
@ -542,11 +542,11 @@ public abstract class PortletRequestUtils {
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() {
@ -554,12 +554,12 @@ public abstract class PortletRequestUtils {
}
@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 PortletRequestBindingException {
return ((Number) parse(name, parameter)).intValue();
return parse(name, parameter);
}
public int[] parseInts(String name, String[] values) throws PortletRequestBindingException {
@ -573,7 +573,7 @@ public abstract class PortletRequestUtils {
}
private static class LongParser extends ParameterParser {
private static class LongParser extends ParameterParser<Long> {
@Override
protected String getType() {
@ -581,12 +581,12 @@ public abstract class PortletRequestUtils {
}
@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 PortletRequestBindingException {
return ((Number) parse(name, parameter)).longValue();
return parse(name, parameter);
}
public long[] parseLongs(String name, String[] values) throws PortletRequestBindingException {
@ -600,7 +600,7 @@ public abstract class PortletRequestUtils {
}
private static class FloatParser extends ParameterParser {
private static class FloatParser extends ParameterParser<Float> {
@Override
protected String getType() {
@ -608,12 +608,12 @@ public abstract class PortletRequestUtils {
}
@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 PortletRequestBindingException {
return ((Number) parse(name, parameter)).floatValue();
return parse(name, parameter);
}
public float[] parseFloats(String name, String[] values) throws PortletRequestBindingException {
@ -627,7 +627,7 @@ public abstract class PortletRequestUtils {
}
private static class DoubleParser extends ParameterParser {
private static class DoubleParser extends ParameterParser<Double> {
@Override
protected String getType() {
@ -635,12 +635,12 @@ public abstract class PortletRequestUtils {
}
@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 PortletRequestBindingException {
return ((Number) parse(name, parameter)).doubleValue();
return parse(name, parameter);
}
public double[] parseDoubles(String name, String[] values) throws PortletRequestBindingException {
@ -654,7 +654,7 @@ public abstract class PortletRequestUtils {
}
private static class BooleanParser extends ParameterParser {
private static class BooleanParser extends ParameterParser<Boolean> {
@Override
protected String getType() {
@ -662,13 +662,13 @@ public abstract class PortletRequestUtils {
}
@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 PortletRequestBindingException {
return ((Boolean) parse(name, parameter)).booleanValue();
return parse(name, parameter);
}
public boolean[] parseBooleans(String name, String[] values) throws PortletRequestBindingException {
@ -682,7 +682,7 @@ public abstract class PortletRequestUtils {
}
private static class StringParser extends ParameterParser {
private static class StringParser extends ParameterParser<String> {
@Override
protected String getType() {
@ -690,7 +690,7 @@ public abstract class PortletRequestUtils {
}
@Override
protected Object doParse(String parameter) throws NumberFormatException {
protected String doParse(String parameter) throws NumberFormatException {
return parameter;
}
@ -701,8 +701,8 @@ public abstract class PortletRequestUtils {
public String[] validateRequiredStrings(String name, String[] values) throws PortletRequestBindingException {
validateRequiredParameter(name, values);
for (int i = 0; i < values.length; i++) {
validateRequiredParameter(name, values[i]);
for (String value : values) {
validateRequiredParameter(name, value);
}
return values;
}

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -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);
}
}