Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SqlParameterValue |
|
| 1.0;1 |
1 | package liquibase.executor.jvm; | |
2 | ||
3 | /** | |
4 | * Object to represent a SQL parameter value, including parameter metadata such as the SQL type and the scale for | |
5 | * numeric values. | |
6 | * <p/> | |
7 | * <p> | |
8 | * Designed for use with {@link liquibase.executor.Executor}'s operations that take an array of argument values: Each | |
9 | * such argument value may be a <code>SqlParameterValue</code>, indicating the SQL type (and optionally the scale) | |
10 | * instead of letting the template guess a default type. Note that this only applies to the operations with a 'plain' | |
11 | * argument array, not to the overloaded variants with an explicit type array. | |
12 | * | |
13 | * @author Spring Framework | |
14 | * @see java.sql.Types | |
15 | */ | |
16 | class SqlParameterValue extends SqlParameter { | |
17 | ||
18 | private final Object value; | |
19 | ||
20 | /** | |
21 | * Create a new SqlParameterValue, supplying the SQL type. | |
22 | * | |
23 | * @param sqlType | |
24 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
25 | * @param value | |
26 | * the value object | |
27 | */ | |
28 | public SqlParameterValue(int sqlType, Object value) { | |
29 | 0 | super(sqlType); |
30 | 0 | this.value = value; |
31 | 0 | } |
32 | ||
33 | /** | |
34 | * Create a new SqlParameterValue, supplying the SQL type. | |
35 | * | |
36 | * @param sqlType | |
37 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
38 | * @param typeName | |
39 | * the type name of the parameter (optional) | |
40 | * @param value | |
41 | * the value object | |
42 | */ | |
43 | public SqlParameterValue(int sqlType, String typeName, Object value) { | |
44 | 0 | super(sqlType, typeName); |
45 | 0 | this.value = value; |
46 | 0 | } |
47 | ||
48 | /** | |
49 | * Create a new SqlParameterValue, supplying the SQL type. | |
50 | * | |
51 | * @param sqlType | |
52 | * SQL type of the parameter according to <code>java.sql.Types</code> | |
53 | * @param scale | |
54 | * the number of digits after the decimal point (for DECIMAL and NUMERIC types) | |
55 | * @param value | |
56 | * the value object | |
57 | */ | |
58 | public SqlParameterValue(int sqlType, int scale, Object value) { | |
59 | 0 | super(sqlType, scale); |
60 | 0 | this.value = value; |
61 | 0 | } |
62 | ||
63 | /** | |
64 | * Create a new SqlParameterValue based on the given SqlParameter declaration. | |
65 | * | |
66 | * @param declaredParam | |
67 | * the declared SqlParameter to define a value for | |
68 | * @param value | |
69 | * the value object | |
70 | */ | |
71 | public SqlParameterValue(SqlParameter declaredParam, Object value) { | |
72 | 0 | super(declaredParam); |
73 | 0 | this.value = value; |
74 | 0 | } |
75 | ||
76 | /** | |
77 | * Return the value object that this parameter value holds. | |
78 | */ | |
79 | public Object getValue() { | |
80 | 0 | return this.value; |
81 | } | |
82 | ||
83 | } |