From 70b9dd61085b96e292d8bf59d626130c1ae8ab6c Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Fri, 5 Dec 2008 07:04:19 +0000 Subject: [PATCH] closed Java 5 code style gaps --- .../springframework/jdbc/core/JdbcOperations.java | 12 ++++++------ .../org/springframework/jdbc/core/JdbcTemplate.java | 12 ++++++------ .../jdbc/core/metadata/CallMetaDataContext.java | 2 +- .../jdbc/core/simple/AbstractJdbcCall.java | 13 ++++++------- .../jdbc/datasource/AbstractDataSource.java | 10 +++++----- .../jdbc/datasource/DelegatingDataSource.java | 8 ++++---- .../org/springframework/jdbc/object/SqlUpdate.java | 7 +++---- .../jdbc/object/StoredProcedure.java | 7 +++---- 8 files changed, 34 insertions(+), 37 deletions(-) diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java index 29a518657fe..27642b4e200 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java @@ -613,7 +613,7 @@ public interface JdbcOperations { * @see #queryForMap(String) * @see ColumnMapRowMapper */ - Map queryForMap(String sql, Object[] args) throws DataAccessException; + Map queryForMap(String sql, Object... args) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a @@ -649,7 +649,7 @@ public interface JdbcOperations { * @throws DataAccessException if the query fails * @see #queryForLong(String) */ - long queryForLong(String sql, Object[] args) throws DataAccessException; + long queryForLong(String sql, Object... args) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a @@ -685,7 +685,7 @@ public interface JdbcOperations { * @throws DataAccessException if the query fails * @see #queryForInt(String) */ - int queryForInt(String sql, Object[] args) throws DataAccessException; + int queryForInt(String sql, Object... args) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a @@ -759,7 +759,7 @@ public interface JdbcOperations { * @throws DataAccessException if the query fails * @see #queryForList(String) */ - List> queryForList(String sql, Object[] args) throws DataAccessException; + List> queryForList(String sql, Object... args) throws DataAccessException; /** * Query given SQL to create a prepared statement from SQL and a @@ -805,7 +805,7 @@ public interface JdbcOperations { * @see SqlRowSetResultSetExtractor * @see javax.sql.rowset.CachedRowSet */ - SqlRowSet queryForRowSet(String sql, Object[] args) throws DataAccessException; + SqlRowSet queryForRowSet(String sql, Object... args) throws DataAccessException; /** * Issue a single SQL update operation (such as an insert, update or delete statement) @@ -871,7 +871,7 @@ public interface JdbcOperations { * @return the number of rows affected * @throws DataAccessException if there is any problem issuing the update */ - int update(String sql, Object[] args) throws DataAccessException; + int update(String sql, Object... args) throws DataAccessException; /** * Issue multiple update statements on a single PreparedStatement, diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java index ae312e35d0b..e85d907a7f5 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java @@ -731,7 +731,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { return queryForObject(sql, args, argTypes, getColumnMapRowMapper()); } - public Map queryForMap(String sql, Object[] args) throws DataAccessException { + public Map queryForMap(String sql, Object... args) throws DataAccessException { return queryForObject(sql, args, getColumnMapRowMapper()); } @@ -740,7 +740,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { return (number != null ? number.longValue() : 0); } - public long queryForLong(String sql, Object[] args) throws DataAccessException { + public long queryForLong(String sql, Object... args) throws DataAccessException { Number number = queryForObject(sql, args, Long.class); return (number != null ? number.longValue() : 0); } @@ -750,7 +750,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { return (number != null ? number.intValue() : 0); } - public int queryForInt(String sql, Object[] args) throws DataAccessException { + public int queryForInt(String sql, Object... args) throws DataAccessException { Number number = queryForObject(sql, args, Integer.class); return (number != null ? number.intValue() : 0); } @@ -767,7 +767,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { return query(sql, args, argTypes, getColumnMapRowMapper()); } - public List> queryForList(String sql, Object[] args) throws DataAccessException { + public List> queryForList(String sql, Object... args) throws DataAccessException { return query(sql, args, getColumnMapRowMapper()); } @@ -775,7 +775,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { return query(sql, args, argTypes, new SqlRowSetResultSetExtractor()); } - public SqlRowSet queryForRowSet(String sql, Object[] args) throws DataAccessException { + public SqlRowSet queryForRowSet(String sql, Object... args) throws DataAccessException { return query(sql, args, new SqlRowSetResultSetExtractor()); } @@ -846,7 +846,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations { return update(sql, new ArgTypePreparedStatementSetter(args, argTypes)); } - public int update(String sql, Object[] args) throws DataAccessException { + public int update(String sql, Object... args) throws DataAccessException { return update(sql, new ArgPreparedStatementSetter(args)); } diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java index f0ac6d9eb6b..e111c48adf9 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java @@ -484,7 +484,7 @@ public class CallMetaDataContext { * @param inParameters the input values * @return a Map containing the matched parameter names with the value taken from the input */ - public Map matchInParameterValuesWithCallParameters(Map inParameters) { + public Map matchInParameterValuesWithCallParameters(Map inParameters) { if (!this.metaDataProvider.isProcedureColumnMetaDataUsed()) { return inParameters; } diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java index 0a1c4c129f5..16584753f76 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java @@ -21,7 +21,6 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; - import javax.sql.DataSource; import org.apache.commons.logging.Log; @@ -50,7 +49,7 @@ public abstract class AbstractJdbcCall { protected final Log logger = LogFactory.getLog(getClass()); /** Lower-level class used to execute SQL */ - private JdbcTemplate jdbcTemplate = new JdbcTemplate(); + private final JdbcTemplate jdbcTemplate; /** List of SqlParameter objects */ private final List declaredParameters = new ArrayList(); @@ -338,7 +337,7 @@ public abstract class AbstractJdbcCall { */ protected Map doExecute(SqlParameterSource parameterSource) { checkCompiled(); - Map params = matchInParameterValuesWithCallParameters(parameterSource); + Map params = matchInParameterValuesWithCallParameters(parameterSource); return executeCallInternal(params); } @@ -347,16 +346,16 @@ public abstract class AbstractJdbcCall { * @param args Map of parameter name and values * @return Map of out parameters */ - protected Map doExecute(Map args) { + protected Map doExecute(Map args) { checkCompiled(); - Map params = matchInParameterValuesWithCallParameters(args); + Map params = matchInParameterValuesWithCallParameters(args); return executeCallInternal(params); } /** * Method to perform the actual call processing */ - private Map executeCallInternal(Map params) { + private Map executeCallInternal(Map params) { CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(params); if (logger.isDebugEnabled()) { logger.debug("The following parameters are used for call " + getCallString() + " with: " + params); @@ -392,7 +391,7 @@ public abstract class AbstractJdbcCall { * @param args the parameter values provided in a Map * @return Map with parameter names and values */ - protected Map matchInParameterValuesWithCallParameters(Map args) { + protected Map matchInParameterValuesWithCallParameters(Map args) { return this.callMetaDataContext.matchInParameterValuesWithCallParameters(args); } diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java index 813b6ea0c67..10e1b9a7f7d 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java @@ -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. @@ -18,7 +18,6 @@ package org.springframework.jdbc.datasource; import java.io.PrintWriter; import java.sql.SQLException; - import javax.sql.DataSource; import org.apache.commons.logging.Log; @@ -77,16 +76,17 @@ public abstract class AbstractDataSource implements DataSource { // Implementation of JDBC 4.0's Wrapper interface //--------------------------------------------------------------------- - public Object unwrap(Class iface) throws SQLException { + @SuppressWarnings("unchecked") + public T unwrap(Class iface) throws SQLException { Assert.notNull(iface, "Interface argument must not be null"); if (!DataSource.class.equals(iface)) { throw new SQLException("DataSource of type [" + getClass().getName() + "] can only be unwrapped as [javax.sql.DataSource], not as [" + iface.getName()); } - return this; + return (T) this; } - public boolean isWrapperFor(Class iface) throws SQLException { + public boolean isWrapperFor(Class iface) throws SQLException { return DataSource.class.equals(iface); } diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java index 5f2b77210ad..c51590daf48 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java @@ -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. @@ -19,7 +19,6 @@ package org.springframework.jdbc.datasource; import java.io.PrintWriter; import java.sql.Connection; import java.sql.SQLException; - import javax.sql.DataSource; import org.springframework.beans.factory.InitializingBean; @@ -109,11 +108,12 @@ public class DelegatingDataSource implements DataSource, InitializingBean { // Implementation of JDBC 4.0's Wrapper interface //--------------------------------------------------------------------- - public Object unwrap(Class iface) throws SQLException { + @SuppressWarnings("unchecked") + public T unwrap(Class iface) throws SQLException { return getTargetDataSource().unwrap(iface); } - public boolean isWrapperFor(Class iface) throws SQLException { + public boolean isWrapperFor(Class iface) throws SQLException { return getTargetDataSource().isWrapperFor(iface); } diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/SqlUpdate.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/SqlUpdate.java index de00dea47ba..d077fa63b08 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/SqlUpdate.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/SqlUpdate.java @@ -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. @@ -17,7 +17,6 @@ package org.springframework.jdbc.object; import java.util.Map; - import javax.sql.DataSource; import org.springframework.dao.DataAccessException; @@ -240,7 +239,7 @@ public class SqlUpdate extends SqlOperation { * matching named parameters specified in the SQL statement * @return the number of rows affected by the update */ - public int updateByNamedParam(Map paramMap) throws DataAccessException { + public int updateByNamedParam(Map paramMap) throws DataAccessException { validateNamedParameters(paramMap); ParsedSql parsedSql = getParsedSql(); MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap); @@ -259,7 +258,7 @@ public class SqlUpdate extends SqlOperation { * @param generatedKeyHolder KeyHolder that will hold the generated keys * @return the number of rows affected by the update */ - public int updateByNamedParam(Map paramMap, KeyHolder generatedKeyHolder) throws DataAccessException { + public int updateByNamedParam(Map paramMap, KeyHolder generatedKeyHolder) throws DataAccessException { validateNamedParameters(paramMap); ParsedSql parsedSql = getParsedSql(); MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap); diff --git a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java index ed69657c173..b070e4baa7e 100644 --- a/org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java +++ b/org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java @@ -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. @@ -17,7 +17,6 @@ package org.springframework.jdbc.object; import java.util.Map; - import javax.sql.DataSource; import org.springframework.dao.DataAccessException; @@ -114,7 +113,7 @@ public abstract class StoredProcedure extends SqlCall { * Output parameters will appear here, with their values after the * stored procedure has been called. */ - public Map execute(Map inParams) throws DataAccessException { + public Map execute(Map inParams) throws DataAccessException { validateParameters(inParams.values().toArray()); return getJdbcTemplate().call(newCallableStatementCreator(inParams), getDeclaredParameters()); } @@ -135,7 +134,7 @@ public abstract class StoredProcedure extends SqlCall { * Output parameters will appear here, with their values after the * stored procedure has been called. */ - public Map execute(ParameterMapper inParamMapper) throws DataAccessException { + public Map execute(ParameterMapper inParamMapper) throws DataAccessException { checkCompiled(); return getJdbcTemplate().call(newCallableStatementCreator(inParamMapper), getDeclaredParameters()); }