001: /*
002: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com> and
003: * JR Boyens <gnu-jrb[remove] at gmx dot net>
004: * Distributed under the terms of either:
005: * - the common development and distribution license (CDDL), v1.0; or
006: * - the GNU Lesser General Public License, v2.1 or later
007: * $Id: AbstractWhereDelegateQuery.java 3634 2007-01-08 21:42:24Z gbevin $
008: */
009: package com.uwyn.rife.database.queries;
010:
011: import com.uwyn.rife.database.Datasource;
012: import com.uwyn.rife.database.exceptions.DbQueryException;
013: import com.uwyn.rife.database.queries.AbstractWhereQuery;
014: import com.uwyn.rife.database.queries.Select;
015: import com.uwyn.rife.database.queries.WhereGroupAnd;
016: import com.uwyn.rife.database.queries.WhereGroupOr;
017: import com.uwyn.rife.database.queries.WhereQuery;
018: import java.util.List;
019:
020: public abstract class AbstractWhereDelegateQuery<QueryType extends AbstractWhereDelegateQuery, DelegateType extends AbstractWhereQuery>
021: implements WhereQuery<QueryType> {
022: protected DelegateType mDelegate = null;
023:
024: protected AbstractWhereDelegateQuery(DelegateType delegate) {
025: mDelegate = delegate;
026: }
027:
028: public DelegateType getDelegate() {
029: return mDelegate;
030: }
031:
032: public Datasource getDatasource() {
033: return mDelegate.getDatasource();
034: }
035:
036: public WhereGroup<QueryType> startWhere() {
037: return new WhereGroup<QueryType>(getDatasource(), this );
038: }
039:
040: public WhereGroupAnd<QueryType> startWhereAnd() {
041: return new WhereGroupAnd<QueryType>(getDatasource(), this );
042: }
043:
044: public WhereGroupOr<QueryType> startWhereOr() {
045: return new WhereGroupOr<QueryType>(getDatasource(), this );
046: }
047:
048: public QueryType where(String where) {
049: if (mDelegate.getWhere().length() > 0) {
050: mDelegate.whereAnd(where);
051: } else {
052: mDelegate.where(where);
053: }
054:
055: return (QueryType) this ;
056: }
057:
058: public QueryType where(String field, String operator, boolean value) {
059: if (mDelegate.getWhere().length() > 0) {
060: mDelegate.whereAnd(field, operator, value);
061: } else {
062: mDelegate.where(field, operator, value);
063: }
064:
065: return (QueryType) this ;
066: }
067:
068: public QueryType where(String field, String operator, byte value) {
069: if (mDelegate.getWhere().length() > 0) {
070: mDelegate.whereAnd(field, operator, value);
071: } else {
072: mDelegate.where(field, operator, value);
073: }
074:
075: return (QueryType) this ;
076: }
077:
078: public QueryType where(String field, String operator, char value) {
079: if (mDelegate.getWhere().length() > 0) {
080: mDelegate.whereAnd(field, operator, value);
081: } else {
082: mDelegate.where(field, operator, value);
083: }
084:
085: return (QueryType) this ;
086: }
087:
088: public QueryType where(String field, String operator, double value) {
089: if (mDelegate.getWhere().length() > 0) {
090: mDelegate.whereAnd(field, operator, value);
091: } else {
092: mDelegate.where(field, operator, value);
093: }
094:
095: return (QueryType) this ;
096: }
097:
098: public QueryType where(String field, String operator, float value) {
099: if (mDelegate.getWhere().length() > 0) {
100: mDelegate.whereAnd(field, operator, value);
101: } else {
102: mDelegate.where(field, operator, value);
103: }
104:
105: return (QueryType) this ;
106: }
107:
108: public QueryType where(String field, String operator, int value) {
109: if (mDelegate.getWhere().length() > 0) {
110: mDelegate.whereAnd(field, operator, value);
111: } else {
112: mDelegate.where(field, operator, value);
113: }
114:
115: return (QueryType) this ;
116: }
117:
118: public QueryType where(String field, String operator, long value) {
119: if (mDelegate.getWhere().length() > 0) {
120: mDelegate.whereAnd(field, operator, value);
121: } else {
122: mDelegate.where(field, operator, value);
123: }
124:
125: return (QueryType) this ;
126: }
127:
128: public QueryType where(String field, String operator, Select query) {
129: if (mDelegate.getWhere().length() > 0) {
130: mDelegate.whereAnd(field, operator, query);
131: } else {
132: mDelegate.where(field, operator, query);
133: }
134:
135: return (QueryType) this ;
136: }
137:
138: public QueryType where(String field, String operator, Object value) {
139: if (mDelegate.getWhere().length() > 0) {
140: mDelegate.whereAnd(field, operator, value);
141: } else {
142: mDelegate.where(field, operator, value);
143: }
144:
145: return (QueryType) this ;
146: }
147:
148: public QueryType where(String field, String operator, short value) {
149: if (mDelegate.getWhere().length() > 0) {
150: mDelegate.whereAnd(field, operator, value);
151: } else {
152: mDelegate.where(field, operator, value);
153: }
154:
155: return (QueryType) this ;
156: }
157:
158: public QueryType whereAnd(String where) {
159: mDelegate.whereAnd(where);
160:
161: return (QueryType) this ;
162: }
163:
164: public QueryType whereAnd(String field, String operator,
165: boolean value) {
166: mDelegate.whereAnd(field, operator, value);
167:
168: return (QueryType) this ;
169: }
170:
171: public QueryType whereAnd(String field, String operator, byte value) {
172: mDelegate.whereAnd(field, operator, value);
173:
174: return (QueryType) this ;
175: }
176:
177: public QueryType whereAnd(String field, String operator, char value) {
178: mDelegate.whereAnd(field, operator, value);
179:
180: return (QueryType) this ;
181: }
182:
183: public QueryType whereAnd(String field, String operator,
184: double value) {
185: mDelegate.whereAnd(field, operator, value);
186:
187: return (QueryType) this ;
188: }
189:
190: public QueryType whereAnd(String field, String operator, float value) {
191: mDelegate.whereAnd(field, operator, value);
192:
193: return (QueryType) this ;
194: }
195:
196: public QueryType whereAnd(String field, String operator, int value) {
197: mDelegate.whereAnd(field, operator, value);
198:
199: return (QueryType) this ;
200: }
201:
202: public QueryType whereAnd(String field, String operator, long value) {
203: mDelegate.whereAnd(field, operator, value);
204:
205: return (QueryType) this ;
206: }
207:
208: public QueryType whereAnd(String field, String operator,
209: Select query) {
210: mDelegate.whereAnd(field, operator, query);
211:
212: return (QueryType) this ;
213: }
214:
215: public QueryType whereAnd(String field, String operator,
216: Object value) {
217: mDelegate.whereAnd(field, operator, value);
218:
219: return (QueryType) this ;
220: }
221:
222: public QueryType whereAnd(String field, String operator, short value) {
223: mDelegate.whereAnd(field, operator, value);
224:
225: return (QueryType) this ;
226: }
227:
228: public QueryType whereOr(String where) {
229: mDelegate.whereOr(where);
230:
231: return (QueryType) this ;
232: }
233:
234: public QueryType whereOr(String field, String operator,
235: boolean value) {
236: mDelegate.whereOr(field, operator, value);
237:
238: return (QueryType) this ;
239: }
240:
241: public QueryType whereOr(String field, String operator, byte value) {
242: mDelegate.whereOr(field, operator, value);
243:
244: return (QueryType) this ;
245: }
246:
247: public QueryType whereOr(String field, String operator, char value) {
248: mDelegate.whereOr(field, operator, value);
249:
250: return (QueryType) this ;
251: }
252:
253: public QueryType whereOr(String field, String operator, double value) {
254: mDelegate.whereOr(field, operator, value);
255:
256: return (QueryType) this ;
257: }
258:
259: public QueryType whereOr(String field, String operator, float value) {
260: mDelegate.whereOr(field, operator, value);
261:
262: return (QueryType) this ;
263: }
264:
265: public QueryType whereOr(String field, String operator, int value) {
266: mDelegate.whereOr(field, operator, value);
267:
268: return (QueryType) this ;
269: }
270:
271: public QueryType whereOr(String field, String operator, long value) {
272: mDelegate.whereOr(field, operator, value);
273:
274: return (QueryType) this ;
275: }
276:
277: public QueryType whereOr(String field, String operator, Select query) {
278: mDelegate.whereOr(field, operator, query);
279:
280: return (QueryType) this ;
281: }
282:
283: public QueryType whereOr(String field, String operator, Object value) {
284: mDelegate.whereOr(field, operator, value);
285:
286: return (QueryType) this ;
287: }
288:
289: public QueryType whereOr(String field, String operator, short value) {
290: mDelegate.whereOr(field, operator, value);
291:
292: return (QueryType) this ;
293: }
294:
295: public QueryType whereSubselect(Select query) {
296: mDelegate.whereSubselect(query);
297:
298: return (QueryType) this ;
299: }
300:
301: public QueryType where(Object bean) throws DbQueryException {
302: mDelegate.where(bean);
303:
304: return (QueryType) this ;
305: }
306:
307: public QueryType whereIncluded(Object bean, String[] includedFields)
308: throws DbQueryException {
309: mDelegate.whereIncluded(bean, includedFields);
310:
311: return (QueryType) this ;
312: }
313:
314: public QueryType whereExcluded(Object bean, String[] excludedFields)
315: throws DbQueryException {
316: mDelegate.whereExcluded(bean, excludedFields);
317:
318: return (QueryType) this ;
319: }
320:
321: public QueryType whereFiltered(Object bean,
322: String[] includedFields, String[] excludedFields)
323: throws DbQueryException {
324: mDelegate.whereFiltered(bean, includedFields, excludedFields);
325:
326: return (QueryType) this ;
327: }
328:
329: public void addWhereParameters(List<String> parameters) {
330: mDelegate.addWhereParameters(parameters);
331: }
332: }
|