KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > expressionbuilders > ResourceIteratorExpressionBuilderDODS


1 /* ResourceIteratorExpressionBuilderDODS.java */
2
3 package org.enhydra.shark.expressionbuilders;
4
5 import java.util.Properties JavaDoc;
6
7 import org.enhydra.shark.api.common.ResourceIteratorExpressionBuilder;
8 import org.enhydra.shark.api.common.SharkConstants;
9
10 /**
11  * ResourceIteratorExpressionBuilderDODS
12  *
13  * @author V.Puskas
14  * @version 0.21
15  */

16 public class ResourceIteratorExpressionBuilderDODS extends
17                                                  BasicExpressionBuilder implements
18                                                                        ResourceIteratorExpressionBuilder {
19
20    protected static final String JavaDoc sqlUsername = " Username ";
21
22    public ResourceIteratorExpressionBuilderDODS(Properties JavaDoc p) {
23       super(p);
24    }
25
26    public ResourceIteratorExpressionBuilder and() {
27       this.operator = AND_OPERATOR;
28       return this;
29    }
30
31    public ResourceIteratorExpressionBuilder or() {
32       this.operator = OR_OPERATOR;
33       return this;
34    }
35
36    public ResourceIteratorExpressionBuilder not() {
37       this.operator |= NOT_OPERATOR;
38       return this;
39    }
40
41    public ResourceIteratorExpressionBuilder addUsernameEquals(String JavaDoc un) {
42       addEquals(SharkConstants.RES_USERNAME, sqlUsername, un);
43       return this;
44    }
45
46    public ResourceIteratorExpressionBuilder addAssignemtCountEquals(long cnt) {
47       char _notPrecedes = appendOperator(true);
48       this.bshExpression.add(SharkConstants.RES_NO_OF_ASSIGNMENTS
49                              + _notPrecedes + "= " + cnt);
50       // FIXME: missing SQL expression this.sqlExpression.add("1");
51
sqlComplete = false;
52       this.propertiesUsed.add(SharkConstants.RES_NO_OF_ASSIGNMENTS);
53       return this;
54    }
55
56    public ResourceIteratorExpressionBuilder addAssignemtCountLessThan(long cnt) {
57       char _notPrecedes = appendOperator(true);
58       String JavaDoc operator = ' ' == _notPrecedes ? " < " : " >= ";
59       this.bshExpression.add(SharkConstants.RES_NO_OF_ASSIGNMENTS
60                              + operator + cnt);
61       // FIXME: missing SQL expression
62
this.sqlExpression.add("1 = 1");
63       sqlComplete = false;
64       this.propertiesUsed.add(SharkConstants.RES_NO_OF_ASSIGNMENTS);
65       return this;
66    }
67
68    public ResourceIteratorExpressionBuilder addAssignemtCountGreaterThan(long cnt) {
69       char _notPrecedes = appendOperator(true);
70       String JavaDoc operator = ' ' == _notPrecedes ? " > " : " <= ";
71       this.bshExpression.add(SharkConstants.RES_NO_OF_ASSIGNMENTS
72                              + operator + cnt);
73       // FIXME: missing SQL expression this.sqlExpression.add("1");
74
this.sqlExpression.add("1 = 1");
75       sqlComplete = false;
76       this.propertiesUsed.add(SharkConstants.RES_NO_OF_ASSIGNMENTS);
77       return this;
78    }
79
80    public ResourceIteratorExpressionBuilder addExpression(String JavaDoc exp) {
81       sqlComplete = false;
82       appendOperator(false);
83       this.bshExpression.add(exp);
84       return this;
85    }
86
87    public ResourceIteratorExpressionBuilder addExpression(ResourceIteratorExpressionBuilder eb) {
88       appendOperator(eb.isComplete());
89       this.bshExpression.add(eb);
90       this.sqlExpression.add(eb);
91       sqlComplete |= eb.isComplete();
92       return this;
93    }
94
95    public ResourceIteratorExpressionBuilder setOrderByUsername(boolean ascending) {
96       super.setOrderBy(sqlUsername, ascending);
97       return this;
98    }
99 }
100
Popular Tags