Skip to content

Commit 65b755a

Browse files
authored
Index checker annotations for ResultSetMetaData.java
1 parent 9411c75 commit 65b755a

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

src/java.sql/share/classes/java/sql/ResultSetMetaData.java

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
package java.sql;
2727

28+
import org.checkerframework.common.value.qual.IntVal;
29+
import org.checkerframework.checker.index.qual.NonNegative;
30+
import org.checkerframework.checker.index.qual.Positive;
31+
2832
/**
2933
* An object that can be used to get information about the types
3034
* and properties of the columns in a <code>ResultSet</code> object.
@@ -52,7 +56,7 @@ public interface ResultSetMetaData extends Wrapper {
5256
* @return the number of columns
5357
* @exception SQLException if a database access error occurs
5458
*/
55-
int getColumnCount() throws SQLException;
59+
@NonNegative int getColumnCount() throws SQLException;
5660

5761
/**
5862
* Indicates whether the designated column is automatically numbered.
@@ -61,7 +65,7 @@ public interface ResultSetMetaData extends Wrapper {
6165
* @return <code>true</code> if so; <code>false</code> otherwise
6266
* @exception SQLException if a database access error occurs
6367
*/
64-
boolean isAutoIncrement(int column) throws SQLException;
68+
boolean isAutoIncrement(@Positive int column) throws SQLException;
6569

6670
/**
6771
* Indicates whether a column's case matters.
@@ -70,7 +74,7 @@ public interface ResultSetMetaData extends Wrapper {
7074
* @return <code>true</code> if so; <code>false</code> otherwise
7175
* @exception SQLException if a database access error occurs
7276
*/
73-
boolean isCaseSensitive(int column) throws SQLException;
77+
boolean isCaseSensitive(@Positive int column) throws SQLException;
7478

7579
/**
7680
* Indicates whether the designated column can be used in a where clause.
@@ -79,7 +83,7 @@ public interface ResultSetMetaData extends Wrapper {
7983
* @return <code>true</code> if so; <code>false</code> otherwise
8084
* @exception SQLException if a database access error occurs
8185
*/
82-
boolean isSearchable(int column) throws SQLException;
86+
boolean isSearchable(@Positive int column) throws SQLException;
8387

8488
/**
8589
* Indicates whether the designated column is a cash value.
@@ -88,7 +92,7 @@ public interface ResultSetMetaData extends Wrapper {
8892
* @return <code>true</code> if so; <code>false</code> otherwise
8993
* @exception SQLException if a database access error occurs
9094
*/
91-
boolean isCurrency(int column) throws SQLException;
95+
boolean isCurrency(@Positive int column) throws SQLException;
9296

9397
/**
9498
* Indicates the nullability of values in the designated column.
@@ -98,25 +102,25 @@ public interface ResultSetMetaData extends Wrapper {
98102
* <code>columnNullable</code> or <code>columnNullableUnknown</code>
99103
* @exception SQLException if a database access error occurs
100104
*/
101-
int isNullable(int column) throws SQLException;
105+
@IntVal({0,1,2}) int isNullable(@Positive int column) throws SQLException;
102106

103107
/**
104108
* The constant indicating that a
105109
* column does not allow <code>NULL</code> values.
106110
*/
107-
int columnNoNulls = 0;
111+
@IntVal(0) int columnNoNulls = 0;
108112

109113
/**
110114
* The constant indicating that a
111115
* column allows <code>NULL</code> values.
112116
*/
113-
int columnNullable = 1;
117+
@IntVal(1) int columnNullable = 1;
114118

115119
/**
116120
* The constant indicating that the
117121
* nullability of a column's values is unknown.
118122
*/
119-
int columnNullableUnknown = 2;
123+
@IntVal(2) int columnNullableUnknown = 2;
120124

121125
/**
122126
* Indicates whether values in the designated column are signed numbers.
@@ -125,7 +129,7 @@ public interface ResultSetMetaData extends Wrapper {
125129
* @return <code>true</code> if so; <code>false</code> otherwise
126130
* @exception SQLException if a database access error occurs
127131
*/
128-
boolean isSigned(int column) throws SQLException;
132+
boolean isSigned(@Positive int column) throws SQLException;
129133

130134
/**
131135
* Indicates the designated column's normal maximum width in characters.
@@ -135,7 +139,7 @@ public interface ResultSetMetaData extends Wrapper {
135139
* of the designated column
136140
* @exception SQLException if a database access error occurs
137141
*/
138-
int getColumnDisplaySize(int column) throws SQLException;
142+
@NonNegative int getColumnDisplaySize(@Positive int column) throws SQLException;
139143

140144
/**
141145
* Gets the designated column's suggested title for use in printouts and
@@ -148,7 +152,7 @@ public interface ResultSetMetaData extends Wrapper {
148152
* @return the suggested column title
149153
* @exception SQLException if a database access error occurs
150154
*/
151-
String getColumnLabel(int column) throws SQLException;
155+
String getColumnLabel(@Positive int column) throws SQLException;
152156

153157
/**
154158
* Get the designated column's name.
@@ -157,7 +161,7 @@ public interface ResultSetMetaData extends Wrapper {
157161
* @return column name
158162
* @exception SQLException if a database access error occurs
159163
*/
160-
String getColumnName(int column) throws SQLException;
164+
String getColumnName(@Positive int column) throws SQLException;
161165

162166
/**
163167
* Get the designated column's table's schema.
@@ -166,7 +170,7 @@ public interface ResultSetMetaData extends Wrapper {
166170
* @return schema name or "" if not applicable
167171
* @exception SQLException if a database access error occurs
168172
*/
169-
String getSchemaName(int column) throws SQLException;
173+
String getSchemaName(@Positive int column) throws SQLException;
170174

171175
/**
172176
* Get the designated column's specified column size.
@@ -180,7 +184,7 @@ public interface ResultSetMetaData extends Wrapper {
180184
* @return precision
181185
* @exception SQLException if a database access error occurs
182186
*/
183-
int getPrecision(int column) throws SQLException;
187+
@NonNegative int getPrecision(@Positive int column) throws SQLException;
184188

185189
/**
186190
* Gets the designated column's number of digits to right of the decimal point.
@@ -190,7 +194,7 @@ public interface ResultSetMetaData extends Wrapper {
190194
* @return scale
191195
* @exception SQLException if a database access error occurs
192196
*/
193-
int getScale(int column) throws SQLException;
197+
@NonNegative int getScale(@Positive int column) throws SQLException;
194198

195199
/**
196200
* Gets the designated column's table name.
@@ -199,7 +203,7 @@ public interface ResultSetMetaData extends Wrapper {
199203
* @return table name or "" if not applicable
200204
* @exception SQLException if a database access error occurs
201205
*/
202-
String getTableName(int column) throws SQLException;
206+
String getTableName(@Positive int column) throws SQLException;
203207

204208
/**
205209
* Gets the designated column's table's catalog name.
@@ -209,7 +213,7 @@ public interface ResultSetMetaData extends Wrapper {
209213
* appears or "" if not applicable
210214
* @exception SQLException if a database access error occurs
211215
*/
212-
String getCatalogName(int column) throws SQLException;
216+
String getCatalogName(@Positive int column) throws SQLException;
213217

214218
/**
215219
* Retrieves the designated column's SQL type.
@@ -219,7 +223,7 @@ public interface ResultSetMetaData extends Wrapper {
219223
* @exception SQLException if a database access error occurs
220224
* @see Types
221225
*/
222-
int getColumnType(int column) throws SQLException;
226+
int getColumnType(@Positive int column) throws SQLException;
223227

224228
/**
225229
* Retrieves the designated column's database-specific type name.
@@ -229,7 +233,7 @@ public interface ResultSetMetaData extends Wrapper {
229233
* a user-defined type, then a fully-qualified type name is returned.
230234
* @exception SQLException if a database access error occurs
231235
*/
232-
String getColumnTypeName(int column) throws SQLException;
236+
String getColumnTypeName(@Positive int column) throws SQLException;
233237

234238
/**
235239
* Indicates whether the designated column is definitely not writable.
@@ -238,7 +242,7 @@ public interface ResultSetMetaData extends Wrapper {
238242
* @return <code>true</code> if so; <code>false</code> otherwise
239243
* @exception SQLException if a database access error occurs
240244
*/
241-
boolean isReadOnly(int column) throws SQLException;
245+
boolean isReadOnly(@Positive int column) throws SQLException;
242246

243247
/**
244248
* Indicates whether it is possible for a write on the designated column to succeed.
@@ -247,7 +251,7 @@ public interface ResultSetMetaData extends Wrapper {
247251
* @return <code>true</code> if so; <code>false</code> otherwise
248252
* @exception SQLException if a database access error occurs
249253
*/
250-
boolean isWritable(int column) throws SQLException;
254+
boolean isWritable(@Positive int column) throws SQLException;
251255

252256
/**
253257
* Indicates whether a write on the designated column will definitely succeed.
@@ -256,7 +260,7 @@ public interface ResultSetMetaData extends Wrapper {
256260
* @return <code>true</code> if so; <code>false</code> otherwise
257261
* @exception SQLException if a database access error occurs
258262
*/
259-
boolean isDefinitelyWritable(int column) throws SQLException;
263+
boolean isDefinitelyWritable(@Positive int column) throws SQLException;
260264

261265
//--------------------------JDBC 2.0-----------------------------------
262266

@@ -275,5 +279,5 @@ public interface ResultSetMetaData extends Wrapper {
275279
* @exception SQLException if a database access error occurs
276280
* @since 1.2
277281
*/
278-
String getColumnClassName(int column) throws SQLException;
282+
String getColumnClassName(@Positive int column) throws SQLException;
279283
}

0 commit comments

Comments
 (0)