| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| SqlParameter |
|
| 1.0;1 |
| 1 | package liquibase.executor.jvm; | |
| 2 | ||
| 3 | /** | |
| 4 | * Object to represent a SQL parameter definition. | |
| 5 | * <p/> | |
| 6 | * <p> | |
| 7 | * Parameters may be anonymous, in which case "name" is <code>null</code>. However, all parameters must define a SQL | |
| 8 | * type according to {@link java.sql.Types}. | |
| 9 | * | |
| 10 | * @author Spring Framework | |
| 11 | * @see java.sql.Types | |
| 12 | */ | |
| 13 | class SqlParameter { | |
| 14 | ||
| 15 | /** | |
| 16 | * The name of the parameter, if any | |
| 17 | */ | |
| 18 | private String name; | |
| 19 | ||
| 20 | /** | |
| 21 | * SQL type constant from <code>java.sql.Types</code> | |
| 22 | */ | |
| 23 | private final int sqlType; | |
| 24 | ||
| 25 | /** | |
| 26 | * Used for types that are user-named like: STRUCT, DISTINCT, JAVA_OBJECT, named array types | |
| 27 | */ | |
| 28 | private String typeName; | |
| 29 | ||
| 30 | /** | |
| 31 | * The scale to apply in case of a NUMERIC or DECIMAL type, if any | |
| 32 | */ | |
| 33 | private Integer scale; | |
| 34 | ||
| 35 | /** | |
| 36 | * Create a new anonymous SqlParameter, supplying the SQL type. | |
| 37 | * | |
| 38 | * @param sqlType | |
| 39 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
| 40 | */ | |
| 41 | 0 | public SqlParameter(int sqlType) { |
| 42 | 0 | this.sqlType = sqlType; |
| 43 | 0 | } |
| 44 | ||
| 45 | /** | |
| 46 | * Create a new anonymous SqlParameter, supplying the SQL type. | |
| 47 | * | |
| 48 | * @param sqlType | |
| 49 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
| 50 | * @param typeName | |
| 51 | * the type name of the parameter (optional) | |
| 52 | */ | |
| 53 | 0 | public SqlParameter(int sqlType, String typeName) { |
| 54 | 0 | this.sqlType = sqlType; |
| 55 | 0 | this.typeName = typeName; |
| 56 | 0 | } |
| 57 | ||
| 58 | /** | |
| 59 | * Create a new anonymous SqlParameter, supplying the SQL type. | |
| 60 | * | |
| 61 | * @param sqlType | |
| 62 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
| 63 | * @param scale | |
| 64 | * the number of digits after the decimal point (for DECIMAL and NUMERIC types) | |
| 65 | */ | |
| 66 | 0 | public SqlParameter(int sqlType, int scale) { |
| 67 | 0 | this.sqlType = sqlType; |
| 68 | 0 | this.scale = scale; |
| 69 | 0 | } |
| 70 | ||
| 71 | /** | |
| 72 | * Create a new SqlParameter, supplying name and SQL type. | |
| 73 | * | |
| 74 | * @param name | |
| 75 | * name of the parameter, as used in input and output maps | |
| 76 | * @param sqlType | |
| 77 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
| 78 | */ | |
| 79 | 0 | public SqlParameter(String name, int sqlType) { |
| 80 | 0 | this.name = name; |
| 81 | 0 | this.sqlType = sqlType; |
| 82 | 0 | } |
| 83 | ||
| 84 | /** | |
| 85 | * Create a new SqlParameter, supplying name and SQL type. | |
| 86 | * | |
| 87 | * @param name | |
| 88 | * name of the parameter, as used in input and output maps | |
| 89 | * @param sqlType | |
| 90 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
| 91 | * @param typeName | |
| 92 | * the type name of the parameter (optional) | |
| 93 | */ | |
| 94 | 0 | public SqlParameter(String name, int sqlType, String typeName) { |
| 95 | 0 | this.name = name; |
| 96 | 0 | this.sqlType = sqlType; |
| 97 | 0 | this.typeName = typeName; |
| 98 | 0 | } |
| 99 | ||
| 100 | /** | |
| 101 | * Create a new SqlParameter, supplying name and SQL type. | |
| 102 | * | |
| 103 | * @param name | |
| 104 | * name of the parameter, as used in input and output maps | |
| 105 | * @param sqlType | |
| 106 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
| 107 | * @param scale | |
| 108 | * the number of digits after the decimal point (for DECIMAL and NUMERIC types) | |
| 109 | */ | |
| 110 | 0 | public SqlParameter(String name, int sqlType, int scale) { |
| 111 | 0 | this.name = name; |
| 112 | 0 | this.sqlType = sqlType; |
| 113 | 0 | this.scale = scale; |
| 114 | 0 | } |
| 115 | ||
| 116 | /** | |
| 117 | * Copy constructor. | |
| 118 | * | |
| 119 | * @param otherParam | |
| 120 | * the SqlParameter object to copy from | |
| 121 | */ | |
| 122 | 0 | public SqlParameter(SqlParameter otherParam) { |
| 123 | 0 | this.name = otherParam.name; |
| 124 | 0 | this.sqlType = otherParam.sqlType; |
| 125 | 0 | this.typeName = otherParam.typeName; |
| 126 | 0 | this.scale = otherParam.scale; |
| 127 | 0 | } |
| 128 | ||
| 129 | /** | |
| 130 | * Return the name of the parameter. | |
| 131 | */ | |
| 132 | public String getName() { | |
| 133 | 0 | return this.name; |
| 134 | } | |
| 135 | ||
| 136 | /** | |
| 137 | * Return the SQL type of the parameter. | |
| 138 | */ | |
| 139 | public int getSqlType() { | |
| 140 | 0 | return this.sqlType; |
| 141 | } | |
| 142 | ||
| 143 | /** | |
| 144 | * Return the type name of the parameter, if any. | |
| 145 | */ | |
| 146 | public String getTypeName() { | |
| 147 | 0 | return this.typeName; |
| 148 | } | |
| 149 | ||
| 150 | /** | |
| 151 | * Return the scale of the parameter, if any. | |
| 152 | */ | |
| 153 | public Integer getScale() { | |
| 154 | 0 | return this.scale; |
| 155 | } | |
| 156 | ||
| 157 | /** | |
| 158 | * Return whether this parameter holds input values that should be set before execution even if they are | |
| 159 | * <code>null</code>. | |
| 160 | * <p> | |
| 161 | * This implementation always returns <code>true</code>. | |
| 162 | */ | |
| 163 | public boolean isInputValueProvided() { | |
| 164 | 0 | return true; |
| 165 | } | |
| 166 | ||
| 167 | /** | |
| 168 | * Return whether this parameter is an implicit return parameter used during the reults preocessing of the | |
| 169 | * CallableStatement.getMoreResults/getUpdateCount. | |
| 170 | * <p> | |
| 171 | * This implementation always returns <code>false</code>. | |
| 172 | */ | |
| 173 | public boolean isResultsParameter() { | |
| 174 | 0 | return false; |
| 175 | } | |
| 176 | } |