001/* 002 * Copyright 2002-2017 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 * https://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 017package org.springframework.jdbc.core; 018 019/** 020 * Subclass of {@link SqlParameter} to represent an output parameter. 021 * No additional properties: instanceof will be used to check for such types. 022 * 023 * <p>Output parameters - like all stored procedure parameters - must have names. 024 * 025 * @author Rod Johnson 026 * @author Thomas Risberg 027 * @author Juergen Hoeller 028 * @see SqlReturnResultSet 029 * @see SqlInOutParameter 030 */ 031public class SqlOutParameter extends ResultSetSupportingSqlParameter { 032 033 private SqlReturnType sqlReturnType; 034 035 036 /** 037 * Create a new SqlOutParameter. 038 * @param name name of the parameter, as used in input and output maps 039 * @param sqlType SQL type of the parameter according to java.sql.Types 040 */ 041 public SqlOutParameter(String name, int sqlType) { 042 super(name, sqlType); 043 } 044 045 /** 046 * Create a new SqlOutParameter. 047 * @param name name of the parameter, as used in input and output maps 048 * @param sqlType SQL type of the parameter according to java.sql.Types 049 * @param scale the number of digits after the decimal point 050 * (for DECIMAL and NUMERIC types) 051 */ 052 public SqlOutParameter(String name, int sqlType, int scale) { 053 super(name, sqlType, scale); 054 } 055 056 /** 057 * Create a new SqlOutParameter. 058 * @param name name of the parameter, as used in input and output maps 059 * @param sqlType SQL type of the parameter according to java.sql.Types 060 * @param typeName the type name of the parameter (optional) 061 */ 062 public SqlOutParameter(String name, int sqlType, String typeName) { 063 super(name, sqlType, typeName); 064 } 065 066 /** 067 * Create a new SqlOutParameter. 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 typeName the type name of the parameter (optional) 071 * @param sqlReturnType custom value handler for complex type (optional) 072 */ 073 public SqlOutParameter(String name, int sqlType, String typeName, SqlReturnType sqlReturnType) { 074 super(name, sqlType, typeName); 075 this.sqlReturnType = sqlReturnType; 076 } 077 078 /** 079 * Create a new SqlOutParameter. 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 rse ResultSetExtractor to use for parsing the ResultSet 083 */ 084 public SqlOutParameter(String name, int sqlType, ResultSetExtractor<?> rse) { 085 super(name, sqlType, rse); 086 } 087 088 /** 089 * Create a new SqlOutParameter. 090 * @param name name of the parameter, as used in input and output maps 091 * @param sqlType SQL type of the parameter according to java.sql.Types 092 * @param rch RowCallbackHandler to use for parsing the ResultSet 093 */ 094 public SqlOutParameter(String name, int sqlType, RowCallbackHandler rch) { 095 super(name, sqlType, rch); 096 } 097 098 /** 099 * Create a new SqlOutParameter. 100 * @param name name of the parameter, as used in input and output maps 101 * @param sqlType SQL type of the parameter according to java.sql.Types 102 * @param rm RowMapper to use for parsing the ResultSet 103 */ 104 public SqlOutParameter(String name, int sqlType, RowMapper<?> rm) { 105 super(name, sqlType, rm); 106 } 107 108 109 /** 110 * Return the custom return type, if any. 111 */ 112 public SqlReturnType getSqlReturnType() { 113 return this.sqlReturnType; 114 } 115 116 /** 117 * Return whether this parameter holds a custom return type. 118 */ 119 public boolean isReturnTypeSupported() { 120 return (this.sqlReturnType != null); 121 } 122 123}