Consistent vararg declarations for String array setters

This commit is contained in:
Juergen Hoeller
2014-08-08 17:17:09 +02:00
parent 47006eeff1
commit ad475ffadf
40 changed files with 265 additions and 311 deletions

View File

@@ -291,7 +291,7 @@ public interface JdbcOperations {
* @return an array of the number of rows affected by each statement
* @throws DataAccessException if there is any problem executing the batch
*/
int[] batchUpdate(String[] sql) throws DataAccessException;
int[] batchUpdate(String... sql) throws DataAccessException;
//-------------------------------------------------------------------------

View File

@@ -547,10 +547,8 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
}
@Override
public int[] batchUpdate(final String[] sql) throws DataAccessException {
public int[] batchUpdate(final String... sql) throws DataAccessException {
Assert.notEmpty(sql, "SQL array must not be empty");
if (logger.isDebugEnabled()) {
logger.debug("Executing SQL batch update of " + sql.length + " statements");
}
@@ -561,9 +559,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
@Override
public int[] doInStatement(Statement stmt) throws SQLException, DataAccessException {
int[] rowsAffected = new int[sql.length];
if (JdbcUtils.supportsBatchUpdates(stmt.getConnection())) {
for (String sqlStmt : sql) {
this.currSql = appendSql(this.currSql, sqlStmt);
@@ -608,6 +604,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
return this.currSql;
}
}
return execute(new BatchUpdateStatementCallback());
}

View File

@@ -129,7 +129,7 @@ public class PreparedStatementCreatorFactory {
/**
* Set the column names of the auto-generated keys.
*/
public void setGeneratedKeysColumnNames(String[] names) {
public void setGeneratedKeysColumnNames(String... names) {
this.generatedKeysColumnNames = names;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2014 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.
@@ -22,7 +22,6 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
@@ -292,7 +291,7 @@ public class TableMetaDataContext {
* Build the insert string based on configuration and metadata information
* @return the insert string to be used
*/
public String createInsertString(String[] generatedKeyNames) {
public String createInsertString(String... generatedKeyNames) {
HashSet<String> keys = new HashSet<String>(generatedKeyNames.length);
for (String key : generatedKeyNames) {
keys.add(key.toUpperCase());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2013 the original author or authors.
* Copyright 2002-2014 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.
@@ -179,21 +179,6 @@ public abstract class AbstractJdbcInsert {
return Collections.unmodifiableList(this.declaredColumns);
}
/**
* Get the names of any generated keys
*/
public String[] getGeneratedKeyNames() {
return this.generatedKeyNames;
}
/**
* Set the names of any generated keys
*/
public void setGeneratedKeyNames(String[] generatedKeyNames) {
checkIfConfigurationModificationIsAllowed();
this.generatedKeyNames = generatedKeyNames;
}
/**
* Specify the name of a single generated key column
*/
@@ -202,6 +187,21 @@ public abstract class AbstractJdbcInsert {
this.generatedKeyNames = new String[] {generatedKeyName};
}
/**
* Set the names of any generated keys
*/
public void setGeneratedKeyNames(String... generatedKeyNames) {
checkIfConfigurationModificationIsAllowed();
this.generatedKeyNames = generatedKeyNames;
}
/**
* Get the names of any generated keys
*/
public String[] getGeneratedKeyNames() {
return this.generatedKeyNames;
}
/**
* Specify whether the parameter metadata for the call should be used. The default is true.
*/

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -210,7 +210,7 @@ public abstract class RdbmsOperation implements InitializingBean {
* Set the column names of the auto-generated keys.
* @see java.sql.Connection#prepareStatement(String, String[])
*/
public void setGeneratedKeysColumnNames(String[] names) {
public void setGeneratedKeysColumnNames(String... names) {
if (isCompiled()) {
throw new InvalidDataAccessApiUsageException(
"The column names for the generated keys must be set before the operation is compiled");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2008 the original author or authors.
* Copyright 2002-2014 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.
@@ -38,7 +38,7 @@ public class CustomSQLErrorCodesTranslation {
/**
* Set the SQL error codes to match.
*/
public void setErrorCodes(String[] errorCodes) {
public void setErrorCodes(String... errorCodes) {
this.errorCodes = StringUtils.sortStringArray(errorCodes);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 the original author or authors.
* Copyright 2002-2014 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.
@@ -79,7 +79,7 @@ public class SQLErrorCodes {
* Set this property to specify multiple database names that contains spaces,
* in which case we can not use bean names for lookup.
*/
public void setDatabaseProductNames(String[] databaseProductNames) {
public void setDatabaseProductNames(String... databaseProductNames) {
this.databaseProductNames = databaseProductNames;
}
@@ -99,7 +99,7 @@ public class SQLErrorCodes {
return this.useSqlStateForTranslation;
}
public void setBadSqlGrammarCodes(String[] badSqlGrammarCodes) {
public void setBadSqlGrammarCodes(String... badSqlGrammarCodes) {
this.badSqlGrammarCodes = StringUtils.sortStringArray(badSqlGrammarCodes);
}
@@ -107,7 +107,7 @@ public class SQLErrorCodes {
return this.badSqlGrammarCodes;
}
public void setInvalidResultSetAccessCodes(String[] invalidResultSetAccessCodes) {
public void setInvalidResultSetAccessCodes(String... invalidResultSetAccessCodes) {
this.invalidResultSetAccessCodes = StringUtils.sortStringArray(invalidResultSetAccessCodes);
}
@@ -119,11 +119,11 @@ public class SQLErrorCodes {
return duplicateKeyCodes;
}
public void setDuplicateKeyCodes(String[] duplicateKeyCodes) {
public void setDuplicateKeyCodes(String... duplicateKeyCodes) {
this.duplicateKeyCodes = duplicateKeyCodes;
}
public void setDataIntegrityViolationCodes(String[] dataIntegrityViolationCodes) {
public void setDataIntegrityViolationCodes(String... dataIntegrityViolationCodes) {
this.dataIntegrityViolationCodes = StringUtils.sortStringArray(dataIntegrityViolationCodes);
}
@@ -131,7 +131,7 @@ public class SQLErrorCodes {
return this.dataIntegrityViolationCodes;
}
public void setPermissionDeniedCodes(String[] permissionDeniedCodes) {
public void setPermissionDeniedCodes(String... permissionDeniedCodes) {
this.permissionDeniedCodes = StringUtils.sortStringArray(permissionDeniedCodes);
}
@@ -139,7 +139,7 @@ public class SQLErrorCodes {
return this.permissionDeniedCodes;
}
public void setDataAccessResourceFailureCodes(String[] dataAccessResourceFailureCodes) {
public void setDataAccessResourceFailureCodes(String... dataAccessResourceFailureCodes) {
this.dataAccessResourceFailureCodes = StringUtils.sortStringArray(dataAccessResourceFailureCodes);
}
@@ -147,7 +147,7 @@ public class SQLErrorCodes {
return this.dataAccessResourceFailureCodes;
}
public void setTransientDataAccessResourceCodes(String[] transientDataAccessResourceCodes) {
public void setTransientDataAccessResourceCodes(String... transientDataAccessResourceCodes) {
this.transientDataAccessResourceCodes = StringUtils.sortStringArray(transientDataAccessResourceCodes);
}
@@ -155,7 +155,7 @@ public class SQLErrorCodes {
return this.transientDataAccessResourceCodes;
}
public void setCannotAcquireLockCodes(String[] cannotAcquireLockCodes) {
public void setCannotAcquireLockCodes(String... cannotAcquireLockCodes) {
this.cannotAcquireLockCodes = StringUtils.sortStringArray(cannotAcquireLockCodes);
}
@@ -163,7 +163,7 @@ public class SQLErrorCodes {
return this.cannotAcquireLockCodes;
}
public void setDeadlockLoserCodes(String[] deadlockLoserCodes) {
public void setDeadlockLoserCodes(String... deadlockLoserCodes) {
this.deadlockLoserCodes = StringUtils.sortStringArray(deadlockLoserCodes);
}
@@ -171,7 +171,7 @@ public class SQLErrorCodes {
return this.deadlockLoserCodes;
}
public void setCannotSerializeTransactionCodes(String[] cannotSerializeTransactionCodes) {
public void setCannotSerializeTransactionCodes(String... cannotSerializeTransactionCodes) {
this.cannotSerializeTransactionCodes = StringUtils.sortStringArray(cannotSerializeTransactionCodes);
}
@@ -179,7 +179,7 @@ public class SQLErrorCodes {
return this.cannotSerializeTransactionCodes;
}
public void setCustomTranslations(CustomSQLErrorCodesTranslation[] customTranslations) {
public void setCustomTranslations(CustomSQLErrorCodesTranslation... customTranslations) {
this.customTranslations = customTranslations;
}