View Javadoc
1   /*
2    * Copyright 2002-2007 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   * Subclass of SqlParameter to represent an output parameter.
21   * No additional properties: instanceof will be used to check
22   * for such types.
23   *
24   * <p>Output parameters - like all stored procedure parameters -
25   * must have names.
26   *
27   * @author Rod Johnson
28   * @author Thomas Risberg
29   * @author Juergen Hoeller
30   * @see SqlReturnResultSet
31   * @see SqlInOutParameter
32   */
33  public class SqlOutParameter extends ResultSetSupportingSqlParameter {
34  
35  	private SqlReturnType sqlReturnType;
36  
37  
38  	/**
39  	 * Create a new SqlOutParameter.
40  	 * @param name name of the parameter, as used in input and output maps
41  	 * @param sqlType SQL type of the parameter according to java.sql.Types
42  	 */
43  	public SqlOutParameter(String name, int sqlType) {
44  		super(name, sqlType);
45  	}
46  
47  	/**
48  	 * Create a new SqlOutParameter.
49  	 * @param name name of the parameter, as used in input and output maps
50  	 * @param sqlType SQL type of the parameter according to java.sql.Types
51  	 * @param scale the number of digits after the decimal point
52  	 * (for DECIMAL and NUMERIC types)
53  	 */
54  	public SqlOutParameter(String name, int sqlType, int scale) {
55  		super(name, sqlType, scale);
56  	}
57  
58  	/**
59  	 * Create a new SqlOutParameter.
60  	 * @param name name of the parameter, as used in input and output maps
61  	 * @param sqlType SQL type of the parameter according to java.sql.Types
62  	 * @param typeName the type name of the parameter (optional)
63  	 */
64  	public SqlOutParameter(String name, int sqlType, String typeName) {
65  		super(name, sqlType, typeName);
66  	}
67  
68  	/**
69  	 * Create a new SqlOutParameter.
70  	 * @param name name of the parameter, as used in input and output maps
71  	 * @param sqlType SQL type of the parameter according to java.sql.Types
72  	 * @param typeName the type name of the parameter (optional)
73  	 * @param sqlReturnType custom value handler for complex type (optional)
74  	 */
75  	public SqlOutParameter(String name, int sqlType, String typeName, SqlReturnType sqlReturnType) {
76  		super(name, sqlType, typeName);
77  		this.sqlReturnType = sqlReturnType;
78  	}
79  
80  	/**
81  	 * Create a new SqlOutParameter.
82  	 * @param name name of the parameter, as used in input and output maps
83  	 * @param sqlType SQL type of the parameter according to java.sql.Types
84  	 * @param rse ResultSetExtractor to use for parsing the ResultSet
85  	 */
86  	public SqlOutParameter(String name, int sqlType, ResultSetExtractor<?> rse) {
87  		super(name, sqlType, rse);
88  	}
89  
90  	/**
91  	 * Create a new SqlOutParameter.
92  	 * @param name name of the parameter, as used in input and output maps
93  	 * @param sqlType SQL type of the parameter according to java.sql.Types
94  	 * @param rch RowCallbackHandler to use for parsing the ResultSet
95  	 */
96  	public SqlOutParameter(String name, int sqlType, RowCallbackHandler rch) {
97  		super(name, sqlType, rch);
98  	}
99  
100 	/**
101 	 * Create a new SqlOutParameter.
102 	 * @param name name of the parameter, as used in input and output maps
103 	 * @param sqlType SQL type of the parameter according to java.sql.Types
104 	 * @param rm RowMapper to use for parsing the ResultSet
105 	 */
106 	public SqlOutParameter(String name, int sqlType, RowMapper<?> rm) {
107 		super(name, sqlType, rm);
108 	}
109 
110 
111 	/**
112 	 * Return the custom return type, if any.
113 	 */
114 	public SqlReturnType getSqlReturnType() {
115 		return this.sqlReturnType;
116 	}
117 
118 	/**
119 	 * Return whether this parameter holds a custom return type.
120 	 */
121 	public boolean isReturnTypeSupported() {
122 		return (this.sqlReturnType != null);
123 	}
124 
125 }