Skip to content

Commit 70b9dd6

Browse files
committed
closed Java 5 code style gaps
1 parent 62a7457 commit 70b9dd6

File tree

8 files changed

+34
-37
lines changed

8 files changed

+34
-37
lines changed

org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcOperations.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T> require
613613
* @see #queryForMap(String)
614614
* @see ColumnMapRowMapper
615615
*/
616-
Map<String, Object> queryForMap(String sql, Object[] args) throws DataAccessException;
616+
Map<String, Object> queryForMap(String sql, Object... args) throws DataAccessException;
617617

618618
/**
619619
* Query given SQL to create a prepared statement from SQL and a
@@ -649,7 +649,7 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T> require
649649
* @throws DataAccessException if the query fails
650650
* @see #queryForLong(String)
651651
*/
652-
long queryForLong(String sql, Object[] args) throws DataAccessException;
652+
long queryForLong(String sql, Object... args) throws DataAccessException;
653653

654654
/**
655655
* Query given SQL to create a prepared statement from SQL and a
@@ -685,7 +685,7 @@ <T> T queryForObject(String sql, Object[] args, int[] argTypes, Class<T> require
685685
* @throws DataAccessException if the query fails
686686
* @see #queryForInt(String)
687687
*/
688-
int queryForInt(String sql, Object[] args) throws DataAccessException;
688+
int queryForInt(String sql, Object... args) throws DataAccessException;
689689

690690
/**
691691
* Query given SQL to create a prepared statement from SQL and a
@@ -759,7 +759,7 @@ <T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elem
759759
* @throws DataAccessException if the query fails
760760
* @see #queryForList(String)
761761
*/
762-
List<Map<String, Object>> queryForList(String sql, Object[] args) throws DataAccessException;
762+
List<Map<String, Object>> queryForList(String sql, Object... args) throws DataAccessException;
763763

764764
/**
765765
* Query given SQL to create a prepared statement from SQL and a
@@ -805,7 +805,7 @@ <T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elem
805805
* @see SqlRowSetResultSetExtractor
806806
* @see javax.sql.rowset.CachedRowSet
807807
*/
808-
SqlRowSet queryForRowSet(String sql, Object[] args) throws DataAccessException;
808+
SqlRowSet queryForRowSet(String sql, Object... args) throws DataAccessException;
809809

810810
/**
811811
* Issue a single SQL update operation (such as an insert, update or delete statement)
@@ -871,7 +871,7 @@ <T>List<T> queryForList(String sql, Object[] args, int[] argTypes, Class<T> elem
871871
* @return the number of rows affected
872872
* @throws DataAccessException if there is any problem issuing the update
873873
*/
874-
int update(String sql, Object[] args) throws DataAccessException;
874+
int update(String sql, Object... args) throws DataAccessException;
875875

876876
/**
877877
* Issue multiple update statements on a single PreparedStatement,

org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/JdbcTemplate.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,7 @@ public Map<String, Object> queryForMap(String sql, Object[] args, int[] argTypes
731731
return queryForObject(sql, args, argTypes, getColumnMapRowMapper());
732732
}
733733

734-
public Map<String, Object> queryForMap(String sql, Object[] args) throws DataAccessException {
734+
public Map<String, Object> queryForMap(String sql, Object... args) throws DataAccessException {
735735
return queryForObject(sql, args, getColumnMapRowMapper());
736736
}
737737

@@ -740,7 +740,7 @@ public long queryForLong(String sql, Object[] args, int[] argTypes) throws DataA
740740
return (number != null ? number.longValue() : 0);
741741
}
742742

743-
public long queryForLong(String sql, Object[] args) throws DataAccessException {
743+
public long queryForLong(String sql, Object... args) throws DataAccessException {
744744
Number number = queryForObject(sql, args, Long.class);
745745
return (number != null ? number.longValue() : 0);
746746
}
@@ -750,7 +750,7 @@ public int queryForInt(String sql, Object[] args, int[] argTypes) throws DataAcc
750750
return (number != null ? number.intValue() : 0);
751751
}
752752

753-
public int queryForInt(String sql, Object[] args) throws DataAccessException {
753+
public int queryForInt(String sql, Object... args) throws DataAccessException {
754754
Number number = queryForObject(sql, args, Integer.class);
755755
return (number != null ? number.intValue() : 0);
756756
}
@@ -767,15 +767,15 @@ public List<Map<String, Object>> queryForList(String sql, Object[] args, int[] a
767767
return query(sql, args, argTypes, getColumnMapRowMapper());
768768
}
769769

770-
public List<Map<String, Object>> queryForList(String sql, Object[] args) throws DataAccessException {
770+
public List<Map<String, Object>> queryForList(String sql, Object... args) throws DataAccessException {
771771
return query(sql, args, getColumnMapRowMapper());
772772
}
773773

774774
public SqlRowSet queryForRowSet(String sql, Object[] args, int[] argTypes) throws DataAccessException {
775775
return query(sql, args, argTypes, new SqlRowSetResultSetExtractor());
776776
}
777777

778-
public SqlRowSet queryForRowSet(String sql, Object[] args) throws DataAccessException {
778+
public SqlRowSet queryForRowSet(String sql, Object... args) throws DataAccessException {
779779
return query(sql, args, new SqlRowSetResultSetExtractor());
780780
}
781781

@@ -846,7 +846,7 @@ public int update(String sql, Object[] args, int[] argTypes) throws DataAccessEx
846846
return update(sql, new ArgTypePreparedStatementSetter(args, argTypes));
847847
}
848848

849-
public int update(String sql, Object[] args) throws DataAccessException {
849+
public int update(String sql, Object... args) throws DataAccessException {
850850
return update(sql, new ArgPreparedStatementSetter(args));
851851
}
852852

org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/metadata/CallMetaDataContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ public Map<String, Object> matchInParameterValuesWithCallParameters(SqlParameter
484484
* @param inParameters the input values
485485
* @return a Map containing the matched parameter names with the value taken from the input
486486
*/
487-
public Map<String, Object> matchInParameterValuesWithCallParameters(Map<String, Object> inParameters) {
487+
public Map<String, ?> matchInParameterValuesWithCallParameters(Map<String, ?> inParameters) {
488488
if (!this.metaDataProvider.isProcedureColumnMetaDataUsed()) {
489489
return inParameters;
490490
}

org.springframework.jdbc/src/main/java/org/springframework/jdbc/core/simple/AbstractJdbcCall.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import java.util.List;
2222
import java.util.Map;
2323
import java.util.Set;
24-
2524
import javax.sql.DataSource;
2625

2726
import org.apache.commons.logging.Log;
@@ -50,7 +49,7 @@ public abstract class AbstractJdbcCall {
5049
protected final Log logger = LogFactory.getLog(getClass());
5150

5251
/** Lower-level class used to execute SQL */
53-
private JdbcTemplate jdbcTemplate = new JdbcTemplate();
52+
private final JdbcTemplate jdbcTemplate;
5453

5554
/** List of SqlParameter objects */
5655
private final List<SqlParameter> declaredParameters = new ArrayList<SqlParameter>();
@@ -338,7 +337,7 @@ protected void checkCompiled() {
338337
*/
339338
protected Map<String, Object> doExecute(SqlParameterSource parameterSource) {
340339
checkCompiled();
341-
Map params = matchInParameterValuesWithCallParameters(parameterSource);
340+
Map<String, Object> params = matchInParameterValuesWithCallParameters(parameterSource);
342341
return executeCallInternal(params);
343342
}
344343

@@ -347,16 +346,16 @@ protected Map<String, Object> doExecute(SqlParameterSource parameterSource) {
347346
* @param args Map of parameter name and values
348347
* @return Map of out parameters
349348
*/
350-
protected Map<String, Object> doExecute(Map<String, Object> args) {
349+
protected Map<String, Object> doExecute(Map<String, ?> args) {
351350
checkCompiled();
352-
Map params = matchInParameterValuesWithCallParameters(args);
351+
Map<String, ?> params = matchInParameterValuesWithCallParameters(args);
353352
return executeCallInternal(params);
354353
}
355354

356355
/**
357356
* Method to perform the actual call processing
358357
*/
359-
private Map<String, Object> executeCallInternal(Map params) {
358+
private Map<String, Object> executeCallInternal(Map<String, ?> params) {
360359
CallableStatementCreator csc = getCallableStatementFactory().newCallableStatementCreator(params);
361360
if (logger.isDebugEnabled()) {
362361
logger.debug("The following parameters are used for call " + getCallString() + " with: " + params);
@@ -392,7 +391,7 @@ protected Map<String, Object> matchInParameterValuesWithCallParameters(SqlParame
392391
* @param args the parameter values provided in a Map
393392
* @return Map with parameter names and values
394393
*/
395-
protected Map<String, Object> matchInParameterValuesWithCallParameters(Map<String, Object> args) {
394+
protected Map<String, ?> matchInParameterValuesWithCallParameters(Map<String, ?> args) {
396395
return this.callMetaDataContext.matchInParameterValuesWithCallParameters(args);
397396
}
398397

org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/AbstractDataSource.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
1818

1919
import java.io.PrintWriter;
2020
import java.sql.SQLException;
21-
2221
import javax.sql.DataSource;
2322

2423
import org.apache.commons.logging.Log;
@@ -77,16 +76,17 @@ public void setLogWriter(PrintWriter pw) throws SQLException {
7776
// Implementation of JDBC 4.0's Wrapper interface
7877
//---------------------------------------------------------------------
7978

80-
public Object unwrap(Class iface) throws SQLException {
79+
@SuppressWarnings("unchecked")
80+
public <T> T unwrap(Class<T> iface) throws SQLException {
8181
Assert.notNull(iface, "Interface argument must not be null");
8282
if (!DataSource.class.equals(iface)) {
8383
throw new SQLException("DataSource of type [" + getClass().getName() +
8484
"] can only be unwrapped as [javax.sql.DataSource], not as [" + iface.getName());
8585
}
86-
return this;
86+
return (T) this;
8787
}
8888

89-
public boolean isWrapperFor(Class iface) throws SQLException {
89+
public boolean isWrapperFor(Class<?> iface) throws SQLException {
9090
return DataSource.class.equals(iface);
9191
}
9292

org.springframework.jdbc/src/main/java/org/springframework/jdbc/datasource/DelegatingDataSource.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@
1919
import java.io.PrintWriter;
2020
import java.sql.Connection;
2121
import java.sql.SQLException;
22-
2322
import javax.sql.DataSource;
2423

2524
import org.springframework.beans.factory.InitializingBean;
@@ -109,11 +108,12 @@ public void setLoginTimeout(int seconds) throws SQLException {
109108
// Implementation of JDBC 4.0's Wrapper interface
110109
//---------------------------------------------------------------------
111110

112-
public Object unwrap(Class iface) throws SQLException {
111+
@SuppressWarnings("unchecked")
112+
public <T> T unwrap(Class<T> iface) throws SQLException {
113113
return getTargetDataSource().unwrap(iface);
114114
}
115115

116-
public boolean isWrapperFor(Class iface) throws SQLException {
116+
public boolean isWrapperFor(Class<?> iface) throws SQLException {
117117
return getTargetDataSource().isWrapperFor(iface);
118118
}
119119

org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/SqlUpdate.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
package org.springframework.jdbc.object;
1818

1919
import java.util.Map;
20-
2120
import javax.sql.DataSource;
2221

2322
import org.springframework.dao.DataAccessException;
@@ -240,7 +239,7 @@ public int update(String p1, String p2) throws DataAccessException {
240239
* matching named parameters specified in the SQL statement
241240
* @return the number of rows affected by the update
242241
*/
243-
public int updateByNamedParam(Map paramMap) throws DataAccessException {
242+
public int updateByNamedParam(Map<String, ?> paramMap) throws DataAccessException {
244243
validateNamedParameters(paramMap);
245244
ParsedSql parsedSql = getParsedSql();
246245
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);
@@ -259,7 +258,7 @@ public int updateByNamedParam(Map paramMap) throws DataAccessException {
259258
* @param generatedKeyHolder KeyHolder that will hold the generated keys
260259
* @return the number of rows affected by the update
261260
*/
262-
public int updateByNamedParam(Map paramMap, KeyHolder generatedKeyHolder) throws DataAccessException {
261+
public int updateByNamedParam(Map<String, ?> paramMap, KeyHolder generatedKeyHolder) throws DataAccessException {
263262
validateNamedParameters(paramMap);
264263
ParsedSql parsedSql = getParsedSql();
265264
MapSqlParameterSource paramSource = new MapSqlParameterSource(paramMap);

org.springframework.jdbc/src/main/java/org/springframework/jdbc/object/StoredProcedure.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2006 the original author or authors.
2+
* Copyright 2002-2008 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,7 +17,6 @@
1717
package org.springframework.jdbc.object;
1818

1919
import java.util.Map;
20-
2120
import javax.sql.DataSource;
2221

2322
import org.springframework.dao.DataAccessException;
@@ -114,7 +113,7 @@ public void declareParameter(SqlParameter param) throws InvalidDataAccessApiUsag
114113
* Output parameters will appear here, with their values after the
115114
* stored procedure has been called.
116115
*/
117-
public Map execute(Map inParams) throws DataAccessException {
116+
public Map<String, Object> execute(Map<String, ?> inParams) throws DataAccessException {
118117
validateParameters(inParams.values().toArray());
119118
return getJdbcTemplate().call(newCallableStatementCreator(inParams), getDeclaredParameters());
120119
}
@@ -135,7 +134,7 @@ public Map execute(Map inParams) throws DataAccessException {
135134
* Output parameters will appear here, with their values after the
136135
* stored procedure has been called.
137136
*/
138-
public Map execute(ParameterMapper inParamMapper) throws DataAccessException {
137+
public Map<String, Object> execute(ParameterMapper inParamMapper) throws DataAccessException {
139138
checkCompiled();
140139
return getJdbcTemplate().call(newCallableStatementCreator(inParamMapper), getDeclaredParameters());
141140
}

0 commit comments

Comments
 (0)