1 /* 2 * Copyright 2002-2012 the original author or authors. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package org.springframework.jdbc.core; 18 19 /** 20 * Common base class for ResultSet-supporting SqlParameters like 21 * {@link SqlOutParameter} and {@link SqlReturnResultSet}. 22 * 23 * @author Juergen Hoeller 24 * @since 1.0.2 25 */ 26 public class ResultSetSupportingSqlParameter extends SqlParameter { 27 28 private ResultSetExtractor<?> resultSetExtractor; 29 30 private RowCallbackHandler rowCallbackHandler; 31 32 private RowMapper<?> rowMapper; 33 34 35 /** 36 * Create a new ResultSetSupportingSqlParameter. 37 * @param name name of the parameter, as used in input and output maps 38 * @param sqlType SQL type of the parameter according to java.sql.Types 39 */ 40 public ResultSetSupportingSqlParameter(String name, int sqlType) { 41 super(name, sqlType); 42 } 43 44 /** 45 * Create a new ResultSetSupportingSqlParameter. 46 * @param name name of the parameter, as used in input and output maps 47 * @param sqlType SQL type of the parameter according to java.sql.Types 48 * @param scale the number of digits after the decimal point 49 * (for DECIMAL and NUMERIC types) 50 */ 51 public ResultSetSupportingSqlParameter(String name, int sqlType, int scale) { 52 super(name, sqlType, scale); 53 } 54 55 /** 56 * Create a new ResultSetSupportingSqlParameter. 57 * @param name name of the parameter, as used in input and output maps 58 * @param sqlType SQL type of the parameter according to java.sql.Types 59 * @param typeName the type name of the parameter (optional) 60 */ 61 public ResultSetSupportingSqlParameter(String name, int sqlType, String typeName) { 62 super(name, sqlType, typeName); 63 } 64 65 /** 66 * Create a new ResultSetSupportingSqlParameter. 67 * @param name name of the parameter, as used in input and output maps 68 * @param sqlType SQL type of the parameter according to java.sql.Types 69 * @param rse ResultSetExtractor to use for parsing the ResultSet 70 */ 71 public ResultSetSupportingSqlParameter(String name, int sqlType, ResultSetExtractor<?> rse) { 72 super(name, sqlType); 73 this.resultSetExtractor = rse; 74 } 75 76 /** 77 * Create a new ResultSetSupportingSqlParameter. 78 * @param name name of the parameter, as used in input and output maps 79 * @param sqlType SQL type of the parameter according to java.sql.Types 80 * @param rch RowCallbackHandler to use for parsing the ResultSet 81 */ 82 public ResultSetSupportingSqlParameter(String name, int sqlType, RowCallbackHandler rch) { 83 super(name, sqlType); 84 this.rowCallbackHandler = rch; 85 } 86 87 /** 88 * Create a new ResultSetSupportingSqlParameter. 89 * @param name name of the parameter, as used in input and output maps 90 * @param sqlType SQL type of the parameter according to java.sql.Types 91 * @param rm RowMapper to use for parsing the ResultSet 92 */ 93 public ResultSetSupportingSqlParameter(String name, int sqlType, RowMapper<?> rm) { 94 super(name, sqlType); 95 this.rowMapper = rm; 96 } 97 98 99 /** 100 * Does this parameter support a ResultSet, i.e. does it hold a 101 * ResultSetExtractor, RowCallbackHandler or RowMapper? 102 */ 103 public boolean isResultSetSupported() { 104 return (this.resultSetExtractor != null || this.rowCallbackHandler != null || this.rowMapper != null); 105 } 106 107 /** 108 * Return the ResultSetExtractor held by this parameter, if any. 109 */ 110 public ResultSetExtractor<?> getResultSetExtractor() { 111 return this.resultSetExtractor; 112 } 113 114 /** 115 * Return the RowCallbackHandler held by this parameter, if any. 116 */ 117 public RowCallbackHandler getRowCallbackHandler() { 118 return this.rowCallbackHandler; 119 } 120 121 /** 122 * Return the RowMapper held by this parameter, if any. 123 */ 124 public RowMapper<?> getRowMapper() { 125 return this.rowMapper; 126 } 127 128 129 /** 130 * <p>This implementation always returns {@code false}. 131 */ 132 @Override 133 public boolean isInputValueProvided() { 134 return false; 135 } 136 137 }