001: /*
002: * Copyright 2002-2007 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.jdbc.core;
018:
019: /**
020: * Common base class for ResultSet-supporting SqlParameters like
021: * {@link SqlOutParameter} and {@link SqlReturnResultSet}.
022: *
023: * @author Juergen Hoeller
024: * @since 1.0.2
025: */
026: public class ResultSetSupportingSqlParameter extends SqlParameter {
027:
028: private ResultSetExtractor resultSetExtractor;
029:
030: private RowCallbackHandler rowCallbackHandler;
031:
032: private RowMapper rowMapper;
033:
034: /**
035: * Create a new ResultSetSupportingSqlParameter.
036: * @param name name of the parameter, as used in input and output maps
037: * @param sqlType SQL type of the parameter according to java.sql.Types
038: */
039: public ResultSetSupportingSqlParameter(String name, int sqlType) {
040: super (name, sqlType);
041: }
042:
043: /**
044: * Create a new ResultSetSupportingSqlParameter.
045: * @param name name of the parameter, as used in input and output maps
046: * @param sqlType SQL type of the parameter according to java.sql.Types
047: * @param scale the number of digits after the decimal point
048: * (for DECIMAL and NUMERIC types)
049: */
050: public ResultSetSupportingSqlParameter(String name, int sqlType,
051: int scale) {
052: super (name, sqlType, scale);
053: }
054:
055: /**
056: * Create a new ResultSetSupportingSqlParameter.
057: * @param name name of the parameter, as used in input and output maps
058: * @param sqlType SQL type of the parameter according to java.sql.Types
059: * @param typeName the type name of the parameter (optional)
060: */
061: public ResultSetSupportingSqlParameter(String name, int sqlType,
062: String typeName) {
063: super (name, sqlType, typeName);
064: }
065:
066: /**
067: * Create a new ResultSetSupportingSqlParameter.
068: * @param name name of the parameter, as used in input and output maps
069: * @param sqlType SQL type of the parameter according to java.sql.Types
070: * @param rse ResultSetExtractor to use for parsing the ResultSet
071: */
072: public ResultSetSupportingSqlParameter(String name, int sqlType,
073: ResultSetExtractor rse) {
074: super (name, sqlType);
075: this .resultSetExtractor = rse;
076: }
077:
078: /**
079: * Create a new ResultSetSupportingSqlParameter.
080: * @param name name of the parameter, as used in input and output maps
081: * @param sqlType SQL type of the parameter according to java.sql.Types
082: * @param rch RowCallbackHandler to use for parsing the ResultSet
083: */
084: public ResultSetSupportingSqlParameter(String name, int sqlType,
085: RowCallbackHandler rch) {
086: super (name, sqlType);
087: this .rowCallbackHandler = rch;
088: }
089:
090: /**
091: * Create a new ResultSetSupportingSqlParameter.
092: * @param name name of the parameter, as used in input and output maps
093: * @param sqlType SQL type of the parameter according to java.sql.Types
094: * @param rm RowMapper to use for parsing the ResultSet
095: */
096: public ResultSetSupportingSqlParameter(String name, int sqlType,
097: RowMapper rm) {
098: super (name, sqlType);
099: this .rowMapper = rm;
100: }
101:
102: /**
103: * Does this parameter support a ResultSet, i.e. does it hold a
104: * ResultSetExtractor, RowCallbackHandler or RowMapper?
105: */
106: public boolean isResultSetSupported() {
107: return (this .resultSetExtractor != null
108: || this .rowCallbackHandler != null || this .rowMapper != null);
109: }
110:
111: /**
112: * Return the ResultSetExtractor held by this parameter, if any.
113: */
114: public ResultSetExtractor getResultSetExtractor() {
115: return resultSetExtractor;
116: }
117:
118: /**
119: * Return the RowCallbackHandler held by this parameter, if any.
120: */
121: public RowCallbackHandler getRowCallbackHandler() {
122: return this .rowCallbackHandler;
123: }
124:
125: /**
126: * Return the RowMapper held by this parameter, if any.
127: */
128: public RowMapper getRowMapper() {
129: return this .rowMapper;
130: }
131:
132: /**
133: * <p>This implementation always returns <code>false</code>.
134: */
135: public boolean isInputValueProvided() {
136: return false;
137: }
138:
139: }
|