1 /*
2 QueryJ
3
4 Copyright (C) 2002 Jose San Leandro Armend?riz
5 jsanleandro@yahoo.es
6 chousz@yahoo.com
7
8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public
10 License as published by the Free Software Foundation; either
11 version 2.1 of the License, or (at your option) any later version.
12
13 This library is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 You should have received a copy of the GNU General Public
19 License along with this library; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 Thanks to ACM S.L. for distributing this library under the GPL license.
23 Contact info: jsanleandro@yahoo.es
24 Postal Address: c/Playa de Lagoa, 1
25 Urb. Valdecaba?as
26 Boadilla del monte
27 28660 Madrid
28 Spain
29
30 ******************************************************************************
31 *
32 * Filename: $RCSfile: Field.java,v $
33 *
34 * Author: Jose San Leandro Armend?riz
35 *
36 * Description: Represents SQL fields.
37 *
38 * Last modified by: $Author: chous $ at $Date: 2003/08/29 08:14:59 $
39 *
40 * File version: $Revision: 1.1 $
41 *
42 * Project version: $Name: $
43 *
44 * $Id: Field.java,v 1.1 2003/08/29 08:14:59 chous Exp $
45 *
46 */
47 package org.acmsl.queryj;
48
49 /*
50 * Importing some ACM-SL classes.
51 */
52 import org.acmsl.queryj.Table;
53
54 /***
55 * Represents SQL fields.
56 * @author <a href="mailto:jsanleandro@yahoo.es"
57 >Jose San Leandro</a>
58 * @version $Revision: 1.1 $
59 */
60 public abstract class Field
61 {
62 /***
63 * The field name.
64 */
65 private String m__strName;
66
67 /***
68 * The table this field belongs to.
69 */
70 private Table m__Table;
71
72 /***
73 * Creates a field using given information.
74 * @param name the field name.
75 * @param table the table.
76 */
77 public Field(String name, Table table)
78 {
79 unmodifiableSetName(name);
80 unmodifiableSetTable(table);
81 }
82
83 /***
84 * Specifies the field name.
85 * @param name the name.
86 */
87 private void unmodifiableSetName(String name)
88 {
89 m__strName = name;
90 }
91
92 /***
93 * Specifies the field name.
94 * @param name the name.
95 */
96 protected void setName(String name)
97 {
98 unmodifiableSetName(name);
99 }
100
101 /***
102 * Retrieves the field name.
103 * @return such reference.
104 */
105 public String getName()
106 {
107 return m__strName;
108 }
109
110 /***
111 * Specifies the field table.
112 * @param table the table.
113 */
114 private void unmodifiableSetTable(Table table)
115 {
116 m__Table = table;
117 }
118
119 /***
120 * Specifies the field table.
121 * @param table the table.
122 */
123 protected void setTable(Table table)
124 {
125 unmodifiableSetTable(table);
126 }
127
128 /***
129 * Retrieves the field table.
130 * @return such reference.
131 */
132 public Table getTable()
133 {
134 return m__Table;
135 }
136
137 /***
138 * Retrieves the variable condition to be able to filter for equality.
139 * @return such kind of condition.
140 */
141 public VariableCondition equals()
142 {
143 VariableCondition result = null;
144
145 ConditionFactory t_ConditionFactory =
146 ConditionFactory.getInstance();
147
148 ConditionOperatorRepository t_ConditionOperatorRepository =
149 ConditionOperatorRepository.getInstance();
150
151 if ( (t_ConditionFactory != null)
152 && (t_ConditionOperatorRepository != null))
153 {
154 result =
155 t_ConditionFactory.createVariableCondition(
156 this, t_ConditionOperatorRepository.getEquals());
157 }
158
159 return result;
160 }
161
162 /***
163 * Retrieves the variable condition to be able to filter for non-equality.
164 * @return such kind of condition.
165 */
166 public VariableCondition notEquals()
167 {
168 VariableCondition result = null;
169
170 ConditionFactory t_ConditionFactory =
171 ConditionFactory.getInstance();
172
173 ConditionOperatorRepository t_ConditionOperatorRepository =
174 ConditionOperatorRepository.getInstance();
175
176 if ( (t_ConditionFactory != null)
177 && (t_ConditionOperatorRepository != null))
178 {
179 result =
180 t_ConditionFactory.createVariableCondition(
181 this, t_ConditionOperatorRepository.getNotEquals());
182 }
183
184 return result;
185 }
186
187 /***
188 * Retrieves the variable condition to be able to filter for lower values.
189 * @return such kind of condition.
190 */
191 public VariableCondition greaterThan()
192 {
193 VariableCondition result = null;
194
195 ConditionFactory t_ConditionFactory =
196 ConditionFactory.getInstance();
197
198 ConditionOperatorRepository t_ConditionOperatorRepository =
199 ConditionOperatorRepository.getInstance();
200
201 if ( (t_ConditionFactory != null)
202 && (t_ConditionOperatorRepository != null))
203 {
204 result =
205 t_ConditionFactory.createVariableCondition(
206 this, t_ConditionOperatorRepository.getGreaterThan());
207 }
208
209 return result;
210 }
211
212 /***
213 * Retrieves the variable condition to be able to filter for greater
214 * values.
215 * @return such kind of condition.
216 */
217 public VariableCondition lessThan()
218 {
219 VariableCondition result = null;
220
221 ConditionFactory t_ConditionFactory =
222 ConditionFactory.getInstance();
223
224 ConditionOperatorRepository t_ConditionOperatorRepository =
225 ConditionOperatorRepository.getInstance();
226
227 if ( (t_ConditionFactory != null)
228 && (t_ConditionOperatorRepository != null))
229 {
230 result =
231 t_ConditionFactory.createVariableCondition(
232 this, t_ConditionOperatorRepository.getLessThan());
233 }
234
235 return result;
236 }
237
238 /***
239 * Retrieves the variable condition to be able to filter for values using
240 * belongs-to relationships.
241 * @return such kind of condition.
242 */
243 public VariableCondition in(SelectQuery query)
244 {
245 VariableCondition result = null;
246
247 ConditionFactory t_ConditionFactory =
248 ConditionFactory.getInstance();
249
250 ConditionOperatorRepository t_ConditionOperatorRepository =
251 ConditionOperatorRepository.getInstance();
252
253 if ( (query != null)
254 && (t_ConditionFactory != null)
255 && (t_ConditionOperatorRepository != null))
256 {
257 result =
258 t_ConditionFactory.createVariableCondition(
259 this, t_ConditionOperatorRepository.getBelongsTo(query));
260 }
261
262 return result;
263 }
264
265 /***
266 * Retrieves the variable condition to be able to filter for values using
267 * not-belongs-to relationships.
268 * @return such kind of condition.
269 */
270 public VariableCondition notIn(SelectQuery query)
271 {
272 VariableCondition result = null;
273
274 ConditionFactory t_ConditionFactory =
275 ConditionFactory.getInstance();
276
277 ConditionOperatorRepository t_ConditionOperatorRepository =
278 ConditionOperatorRepository.getInstance();
279
280 if ( (query != null)
281 && (t_ConditionFactory != null)
282 && (t_ConditionOperatorRepository != null))
283 {
284 result =
285 t_ConditionFactory.createVariableCondition(
286 this,
287 t_ConditionOperatorRepository.getNotBelongsTo(query));
288 }
289
290 return result;
291 }
292
293 /***
294 * Retrieves the variable condition to be able to filter for null values.
295 * @param value the value.
296 * @return such kind of condition.
297 */
298 public Condition isNull()
299 {
300 Condition result = null;
301
302 ConditionFactory t_ConditionFactory =
303 ConditionFactory.getInstance();
304
305 ConditionOperatorRepository t_ConditionOperatorRepository =
306 ConditionOperatorRepository.getInstance();
307
308 if ( (t_ConditionFactory != null)
309 && (t_ConditionOperatorRepository != null))
310 {
311 result =
312 t_ConditionFactory.createCondition(
313 this,
314 t_ConditionOperatorRepository.getIsNull(),
315 null);
316 }
317
318 return result;
319 }
320
321 // Serialization methods //
322
323 /***
324 * Outputs a text version of the field.
325 * @return the field.
326 */
327 public String toString()
328 {
329 return getName();
330 }
331 }
This page was automatically generated by Maven