Mark SqlRowSet accessor methods as nullable (for alignment with JDBC)

Closes gh-24042
This commit is contained in:
Juergen Hoeller
2019-11-20 17:37:40 +01:00
parent 83f03976ea
commit aee33d8b4b
2 changed files with 54 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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.
@@ -29,6 +29,7 @@ import java.util.HashMap;
import java.util.Map;
import org.springframework.jdbc.InvalidResultSetAccessException;
import org.springframework.lang.Nullable;
/**
* The default implementation of Spring's {@link SqlRowSet} interface, wrapping a
@@ -160,6 +161,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getBigDecimal(int)
*/
@Override
@Nullable
public BigDecimal getBigDecimal(int columnIndex) throws InvalidResultSetAccessException {
try {
return this.resultSet.getBigDecimal(columnIndex);
@@ -173,6 +175,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getBigDecimal(String)
*/
@Override
@Nullable
public BigDecimal getBigDecimal(String columnLabel) throws InvalidResultSetAccessException {
return getBigDecimal(findColumn(columnLabel));
}
@@ -223,6 +226,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getDate(int)
*/
@Override
@Nullable
public Date getDate(int columnIndex) throws InvalidResultSetAccessException {
try {
return this.resultSet.getDate(columnIndex);
@@ -236,6 +240,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getDate(String)
*/
@Override
@Nullable
public Date getDate(String columnLabel) throws InvalidResultSetAccessException {
return getDate(findColumn(columnLabel));
}
@@ -244,6 +249,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getDate(int, Calendar)
*/
@Override
@Nullable
public Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
try {
return this.resultSet.getDate(columnIndex, cal);
@@ -257,6 +263,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getDate(String, Calendar)
*/
@Override
@Nullable
public Date getDate(String columnLabel, Calendar cal) throws InvalidResultSetAccessException {
return getDate(findColumn(columnLabel), cal);
}
@@ -349,6 +356,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getNString(int)
*/
@Override
@Nullable
public String getNString(int columnIndex) throws InvalidResultSetAccessException {
try {
return this.resultSet.getNString(columnIndex);
@@ -362,6 +370,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getNString(String)
*/
@Override
@Nullable
public String getNString(String columnLabel) throws InvalidResultSetAccessException {
return getNString(findColumn(columnLabel));
}
@@ -370,6 +379,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getObject(int)
*/
@Override
@Nullable
public Object getObject(int columnIndex) throws InvalidResultSetAccessException {
try {
return this.resultSet.getObject(columnIndex);
@@ -383,6 +393,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getObject(String)
*/
@Override
@Nullable
public Object getObject(String columnLabel) throws InvalidResultSetAccessException {
return getObject(findColumn(columnLabel));
}
@@ -391,6 +402,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getObject(int, Map)
*/
@Override
@Nullable
public Object getObject(int columnIndex, Map<String, Class<?>> map) throws InvalidResultSetAccessException {
try {
return this.resultSet.getObject(columnIndex, map);
@@ -404,6 +416,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getObject(String, Map)
*/
@Override
@Nullable
public Object getObject(String columnLabel, Map<String, Class<?>> map) throws InvalidResultSetAccessException {
return getObject(findColumn(columnLabel), map);
}
@@ -412,6 +425,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getObject(int, Class)
*/
@Override
@Nullable
public <T> T getObject(int columnIndex, Class<T> type) throws InvalidResultSetAccessException {
try {
return this.resultSet.getObject(columnIndex, type);
@@ -425,6 +439,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getObject(String, Class)
*/
@Override
@Nullable
public <T> T getObject(String columnLabel, Class<T> type) throws InvalidResultSetAccessException {
return getObject(findColumn(columnLabel), type);
}
@@ -454,6 +469,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getString(int)
*/
@Override
@Nullable
public String getString(int columnIndex) throws InvalidResultSetAccessException {
try {
return this.resultSet.getString(columnIndex);
@@ -467,6 +483,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getString(String)
*/
@Override
@Nullable
public String getString(String columnLabel) throws InvalidResultSetAccessException {
return getString(findColumn(columnLabel));
}
@@ -475,6 +492,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getTime(int)
*/
@Override
@Nullable
public Time getTime(int columnIndex) throws InvalidResultSetAccessException {
try {
return this.resultSet.getTime(columnIndex);
@@ -488,6 +506,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getTime(String)
*/
@Override
@Nullable
public Time getTime(String columnLabel) throws InvalidResultSetAccessException {
return getTime(findColumn(columnLabel));
}
@@ -496,6 +515,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getTime(int, Calendar)
*/
@Override
@Nullable
public Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
try {
return this.resultSet.getTime(columnIndex, cal);
@@ -509,6 +529,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getTime(String, Calendar)
*/
@Override
@Nullable
public Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException {
return getTime(findColumn(columnLabel), cal);
}
@@ -517,6 +538,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getTimestamp(int)
*/
@Override
@Nullable
public Timestamp getTimestamp(int columnIndex) throws InvalidResultSetAccessException {
try {
return this.resultSet.getTimestamp(columnIndex);
@@ -530,6 +552,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getTimestamp(String)
*/
@Override
@Nullable
public Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessException {
return getTimestamp(findColumn(columnLabel));
}
@@ -538,6 +561,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getTimestamp(int, Calendar)
*/
@Override
@Nullable
public Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException {
try {
return this.resultSet.getTimestamp(columnIndex, cal);
@@ -551,6 +575,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
* @see java.sql.ResultSet#getTimestamp(String, Calendar)
*/
@Override
@Nullable
public Timestamp getTimestamp(String columnLabel, Calendar cal) throws InvalidResultSetAccessException {
return getTimestamp(findColumn(columnLabel), cal);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2019 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,6 +25,7 @@ import java.util.Calendar;
import java.util.Map;
import org.springframework.jdbc.InvalidResultSetAccessException;
import org.springframework.lang.Nullable;
/**
* Mirror interface for {@link javax.sql.RowSet}, representing a disconnected variant of
@@ -74,6 +75,7 @@ public interface SqlRowSet extends Serializable {
* @return an BigDecimal object representing the column value
* @see java.sql.ResultSet#getBigDecimal(int)
*/
@Nullable
BigDecimal getBigDecimal(int columnIndex) throws InvalidResultSetAccessException;
/**
@@ -82,6 +84,7 @@ public interface SqlRowSet extends Serializable {
* @return an BigDecimal object representing the column value
* @see java.sql.ResultSet#getBigDecimal(String)
*/
@Nullable
BigDecimal getBigDecimal(String columnLabel) throws InvalidResultSetAccessException;
/**
@@ -122,6 +125,7 @@ public interface SqlRowSet extends Serializable {
* @return a Date object representing the column value
* @see java.sql.ResultSet#getDate(int)
*/
@Nullable
Date getDate(int columnIndex) throws InvalidResultSetAccessException;
/**
@@ -130,6 +134,7 @@ public interface SqlRowSet extends Serializable {
* @return a Date object representing the column value
* @see java.sql.ResultSet#getDate(String)
*/
@Nullable
Date getDate(String columnLabel) throws InvalidResultSetAccessException;
/**
@@ -139,6 +144,7 @@ public interface SqlRowSet extends Serializable {
* @return a Date object representing the column value
* @see java.sql.ResultSet#getDate(int, Calendar)
*/
@Nullable
Date getDate(int columnIndex, Calendar cal) throws InvalidResultSetAccessException;
/**
@@ -148,6 +154,7 @@ public interface SqlRowSet extends Serializable {
* @return a Date object representing the column value
* @see java.sql.ResultSet#getDate(String, Calendar)
*/
@Nullable
Date getDate(String columnLabel, Calendar cal) throws InvalidResultSetAccessException;
/**
@@ -222,6 +229,7 @@ public interface SqlRowSet extends Serializable {
* @since 4.1.3
* @see java.sql.ResultSet#getNString(int)
*/
@Nullable
String getNString(int columnIndex) throws InvalidResultSetAccessException;
/**
@@ -232,6 +240,7 @@ public interface SqlRowSet extends Serializable {
* @since 4.1.3
* @see java.sql.ResultSet#getNString(String)
*/
@Nullable
String getNString(String columnLabel) throws InvalidResultSetAccessException;
/**
@@ -240,6 +249,7 @@ public interface SqlRowSet extends Serializable {
* @return a Object representing the column value
* @see java.sql.ResultSet#getObject(int)
*/
@Nullable
Object getObject(int columnIndex) throws InvalidResultSetAccessException;
/**
@@ -248,6 +258,7 @@ public interface SqlRowSet extends Serializable {
* @return a Object representing the column value
* @see java.sql.ResultSet#getObject(String)
*/
@Nullable
Object getObject(String columnLabel) throws InvalidResultSetAccessException;
/**
@@ -257,6 +268,7 @@ public interface SqlRowSet extends Serializable {
* @return a Object representing the column value
* @see java.sql.ResultSet#getObject(int, Map)
*/
@Nullable
Object getObject(int columnIndex, Map<String, Class<?>> map) throws InvalidResultSetAccessException;
/**
@@ -266,6 +278,7 @@ public interface SqlRowSet extends Serializable {
* @return a Object representing the column value
* @see java.sql.ResultSet#getObject(String, Map)
*/
@Nullable
Object getObject(String columnLabel, Map<String, Class<?>> map) throws InvalidResultSetAccessException;
/**
@@ -273,9 +286,10 @@ public interface SqlRowSet extends Serializable {
* @param columnIndex the column index
* @param type the Java type to convert the designated column to
* @return a Object representing the column value
* @see java.sql.ResultSet#getObject(int)
* @since 4.1.3
* @see java.sql.ResultSet#getObject(int, Class)
*/
@Nullable
<T> T getObject(int columnIndex, Class<T> type) throws InvalidResultSetAccessException;
/**
@@ -283,9 +297,10 @@ public interface SqlRowSet extends Serializable {
* @param columnLabel the column label
* @param type the Java type to convert the designated column to
* @return a Object representing the column value
* @see java.sql.ResultSet#getObject(int)
* @since 4.1.3
* @see java.sql.ResultSet#getObject(String, Class)
*/
@Nullable
<T> T getObject(String columnLabel, Class<T> type) throws InvalidResultSetAccessException;
/**
@@ -310,6 +325,7 @@ public interface SqlRowSet extends Serializable {
* @return a String representing the column value
* @see java.sql.ResultSet#getString(int)
*/
@Nullable
String getString(int columnIndex) throws InvalidResultSetAccessException;
/**
@@ -318,6 +334,7 @@ public interface SqlRowSet extends Serializable {
* @return a String representing the column value
* @see java.sql.ResultSet#getString(String)
*/
@Nullable
String getString(String columnLabel) throws InvalidResultSetAccessException;
/**
@@ -326,6 +343,7 @@ public interface SqlRowSet extends Serializable {
* @return a Time object representing the column value
* @see java.sql.ResultSet#getTime(int)
*/
@Nullable
Time getTime(int columnIndex) throws InvalidResultSetAccessException;
/**
@@ -334,6 +352,7 @@ public interface SqlRowSet extends Serializable {
* @return a Time object representing the column value
* @see java.sql.ResultSet#getTime(String)
*/
@Nullable
Time getTime(String columnLabel) throws InvalidResultSetAccessException;
/**
@@ -343,6 +362,7 @@ public interface SqlRowSet extends Serializable {
* @return a Time object representing the column value
* @see java.sql.ResultSet#getTime(int, Calendar)
*/
@Nullable
Time getTime(int columnIndex, Calendar cal) throws InvalidResultSetAccessException;
/**
@@ -352,6 +372,7 @@ public interface SqlRowSet extends Serializable {
* @return a Time object representing the column value
* @see java.sql.ResultSet#getTime(String, Calendar)
*/
@Nullable
Time getTime(String columnLabel, Calendar cal) throws InvalidResultSetAccessException;
/**
@@ -360,6 +381,7 @@ public interface SqlRowSet extends Serializable {
* @return a Timestamp object representing the column value
* @see java.sql.ResultSet#getTimestamp(int)
*/
@Nullable
Timestamp getTimestamp(int columnIndex) throws InvalidResultSetAccessException;
/**
@@ -368,6 +390,7 @@ public interface SqlRowSet extends Serializable {
* @return a Timestamp object representing the column value
* @see java.sql.ResultSet#getTimestamp(String)
*/
@Nullable
Timestamp getTimestamp(String columnLabel) throws InvalidResultSetAccessException;
/**
@@ -377,6 +400,7 @@ public interface SqlRowSet extends Serializable {
* @return a Timestamp object representing the column value
* @see java.sql.ResultSet#getTimestamp(int, Calendar)
*/
@Nullable
Timestamp getTimestamp(int columnIndex, Calendar cal) throws InvalidResultSetAccessException;
/**
@@ -386,6 +410,7 @@ public interface SqlRowSet extends Serializable {
* @return a Timestamp object representing the column value
* @see java.sql.ResultSet#getTimestamp(String, Calendar)
*/
@Nullable
Timestamp getTimestamp(String columnLabel, Calendar cal) throws InvalidResultSetAccessException;