001/*
002 * Copyright 2002-2018 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.metadata;
018
019import java.sql.DatabaseMetaData;
020
021/**
022 * Holder of meta-data for a specific parameter that is used for call processing.
023 *
024 * @author Thomas Risberg
025 * @author Juergen Hoeller
026 * @since 2.5
027 * @see GenericCallMetaDataProvider
028 */
029public class CallParameterMetaData {
030
031        private String parameterName;
032
033        private int parameterType;
034
035        private int sqlType;
036
037        private String typeName;
038
039        private boolean nullable;
040
041
042        /**
043         * Constructor taking all the properties.
044         */
045        public CallParameterMetaData(
046                        String columnName, int columnType, int sqlType, String typeName, boolean nullable) {
047
048                this.parameterName = columnName;
049                this.parameterType = columnType;
050                this.sqlType = sqlType;
051                this.typeName = typeName;
052                this.nullable = nullable;
053        }
054
055
056        /**
057         * Get the parameter name.
058         */
059        public String getParameterName() {
060                return this.parameterName;
061        }
062
063        /**
064         * Get the parameter type.
065         */
066        public int getParameterType() {
067                return this.parameterType;
068        }
069
070        /**
071         * Determine whether the declared parameter qualifies as a 'return' parameter
072         * for our purposes: type {@link DatabaseMetaData#procedureColumnReturn} or
073         * {@link DatabaseMetaData#procedureColumnResult}.
074         * @since 4.3.15
075         */
076        public boolean isReturnParameter() {
077                return (this.parameterType == DatabaseMetaData.procedureColumnReturn ||
078                                this.parameterType == DatabaseMetaData.procedureColumnResult);
079        }
080
081        /**
082         * Get the parameter SQL type.
083         */
084        public int getSqlType() {
085                return this.sqlType;
086        }
087
088        /**
089         * Get the parameter type name.
090         */
091        public String getTypeName() {
092                return this.typeName;
093        }
094
095        /**
096         * Get whether the parameter is nullable.
097         */
098        public boolean isNullable() {
099                return this.nullable;
100        }
101
102}