Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
StatementParameter |
|
| 1.0;1 |
1 | package us.daveread.basicquery; | |
2 | ||
3 | /** | |
4 | * <p> | |
5 | * Title: Statement parameter | |
6 | * </p> | |
7 | * <p> | |
8 | * Description: An individual parameter for a parameterized SQL statement | |
9 | * </p> | |
10 | * <p> | |
11 | * Copyright: Copyright (c) 2004-2014, David Read | |
12 | * </p> | |
13 | * <p> | |
14 | * This program is free software; you can redistribute it and/or modify it under | |
15 | * the terms of the GNU General Public License as published by the Free Software | |
16 | * Foundation; either version 2 of the License, or (at your option) any later | |
17 | * version. | |
18 | * </p> | |
19 | * <p> | |
20 | * This program is distributed in the hope that it will be useful, but WITHOUT | |
21 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
22 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more | |
23 | * details. | |
24 | * </p> | |
25 | * <p> | |
26 | * You should have received a copy of the GNU General Public License along with | |
27 | * this program; if not, write to the Free Software Foundation, Inc., 59 Temple | |
28 | * Place, Suite 330, Boston, MA 02111-1307 USA | |
29 | * </p> | |
30 | * <p> | |
31 | * </p> | |
32 | * | |
33 | * @author David Read | |
34 | */ | |
35 | ||
36 | public class StatementParameter { | |
37 | /** | |
38 | * In parameter | |
39 | */ | |
40 | public static final int IN = 0; | |
41 | ||
42 | /** | |
43 | * Out parameter | |
44 | */ | |
45 | public static final int OUT = 1; | |
46 | ||
47 | /** | |
48 | * In-Out parameter | |
49 | */ | |
50 | public static final int IN_OUT = 2; | |
51 | ||
52 | /** | |
53 | * Parameter type (In, Out, In-Out) | |
54 | */ | |
55 | private int type; | |
56 | ||
57 | /** | |
58 | * Parameter data type | |
59 | */ | |
60 | private int dataType; | |
61 | ||
62 | /** | |
63 | * Data value associated with an In or In-Out parameter | |
64 | */ | |
65 | private String dataString; | |
66 | ||
67 | /** | |
68 | * Create a new StatementParameter instance. This constructor is | |
69 | * typically used for OUT parameters, which have no initial value. | |
70 | * | |
71 | * @param aType | |
72 | * The direction (In/Out) of the parameter | |
73 | * @param aDataType | |
74 | * The java.sql.Types value for the parameter | |
75 | */ | |
76 | 3 | public StatementParameter(int aType, int aDataType) { |
77 | 3 | type = aType; |
78 | 3 | dataType = aDataType; |
79 | 3 | } |
80 | ||
81 | /** | |
82 | * Create a new StatementParameter instance. This constructor is | |
83 | * typically used for IN or IN_OUT parameters, which have an initial value. | |
84 | * | |
85 | * @param aType | |
86 | * The direction (In/Out) of the parameter | |
87 | * @param aDataType | |
88 | * The java.sql.Types value for the parameter | |
89 | * @param aDataString | |
90 | * The data supplied for this parameter | |
91 | */ | |
92 | 3 | public StatementParameter(int aType, int aDataType, String aDataString) { |
93 | 3 | type = aType; |
94 | 3 | dataType = aDataType; |
95 | 3 | dataString = aDataString; |
96 | 3 | } |
97 | ||
98 | /** | |
99 | * Retrieve the direction (In/Out) of this parameter | |
100 | * | |
101 | * @return The direction of the parameter - constants in this class define the | |
102 | * meaning | |
103 | */ | |
104 | public int getType() { | |
105 | 2 | return type; |
106 | } | |
107 | ||
108 | /** | |
109 | * Retrieve the java.sql.Types value for this parameter | |
110 | * | |
111 | * @return The SQL data type | |
112 | */ | |
113 | public int getDataType() { | |
114 | 2 | return dataType; |
115 | } | |
116 | ||
117 | /** | |
118 | * Retrieve the value associated with this parameter. Only valid for | |
119 | * In or In-Out parameters. Note that all parameter values are | |
120 | * treated as strings. They are converted as necessary when the SQL is | |
121 | * executed. | |
122 | * | |
123 | * @return The value of the parameter | |
124 | */ | |
125 | public String getDataString() { | |
126 | 2 | return dataString; |
127 | } | |
128 | } |