1
|
|
|
2
|
|
|
3
|
|
|
4
|
|
|
5
|
|
|
6
|
|
|
7
|
|
|
8
|
|
package org.asyrinx.brownie.core.sql2;
|
9
|
|
|
10
|
|
import java.util.Date;
|
11
|
|
|
12
|
|
import org.asyrinx.brownie.core.sql.Operator;
|
13
|
|
|
14
|
|
|
15
|
|
|
16
|
|
|
17
|
|
public class Conditions extends Elements {
|
18
|
|
|
19
|
20
|
public void accept(Visitor visitor) {
|
20
|
20
|
visitor.visit(this);
|
21
|
|
}
|
22
|
|
|
23
|
|
private Operator connection = Operator.AND;
|
24
|
|
|
25
|
|
|
26
|
|
|
27
|
|
|
28
|
19
|
public Operator getConnection() {
|
29
|
19
|
return connection;
|
30
|
|
}
|
31
|
|
|
32
|
|
|
33
|
|
|
34
|
|
|
35
|
8
|
public void setConnection(Operator operator) {
|
36
|
8
|
connection = operator;
|
37
|
|
}
|
38
|
|
|
39
|
|
|
40
|
|
|
41
|
|
|
42
|
0
|
public Conditions addNewCondition() {
|
43
|
0
|
return addNewConditions(this.getConnection());
|
44
|
|
}
|
45
|
|
|
46
|
|
|
47
|
|
|
48
|
|
|
49
|
8
|
public Conditions addNewConditions(Operator conn) {
|
50
|
8
|
final Conditions result = new Conditions();
|
51
|
8
|
result.setConnection(conn);
|
52
|
8
|
super.addImpl(result);
|
53
|
8
|
return result;
|
54
|
|
}
|
55
|
|
|
56
|
|
|
57
|
|
|
58
|
|
|
59
|
|
|
60
|
|
|
61
|
0
|
public Conditions addPlainCondition(String condition) {
|
62
|
0
|
return add(null, condition, Operator.NONE);
|
63
|
|
}
|
64
|
|
|
65
|
26
|
public Conditions add(String field, Object value, Operator operator) {
|
66
|
26
|
final Condition result = new Condition();
|
67
|
26
|
result.setFieldName(field);
|
68
|
26
|
result.setOperator(operator);
|
69
|
26
|
result.setValue(value);
|
70
|
26
|
result.setConditions(this);
|
71
|
26
|
super.addImpl(result);
|
72
|
26
|
return this;
|
73
|
|
}
|
74
|
|
|
75
|
0
|
public Conditions addRange(String field, Object min, Object max) {
|
76
|
0
|
return addRange(field, min, max, true, true);
|
77
|
|
}
|
78
|
|
|
79
|
0
|
public Conditions addRange(String field, Object min, Object max,
|
80
|
|
boolean includeMin, boolean includeMax) {
|
81
|
0
|
final Conditions conditions = addNewConditions(Operator.AND);
|
82
|
0
|
if (includeMin)
|
83
|
0
|
conditions.add(field, min, Operator.GREATER_EQUAL);
|
84
|
|
else
|
85
|
0
|
conditions.add(field, min, Operator.GREATER_THAN);
|
86
|
0
|
if (includeMax)
|
87
|
0
|
conditions.add(field, max, Operator.LESS_EQUAL);
|
88
|
|
else
|
89
|
0
|
conditions.add(field, max, Operator.LESS_THAN);
|
90
|
0
|
return this;
|
91
|
|
}
|
92
|
|
|
93
|
|
|
94
|
|
|
95
|
|
|
96
|
|
|
97
|
|
|
98
|
|
|
99
|
|
|
100
|
|
|
101
|
|
|
102
|
|
|
103
|
|
|
104
|
7
|
public Conditions add(String field, String value) {
|
105
|
7
|
return add(field, value, Operator.EQUAL);
|
106
|
|
}
|
107
|
|
|
108
|
|
|
109
|
|
|
110
|
|
|
111
|
|
|
112
|
|
|
113
|
|
|
114
|
|
|
115
|
|
|
116
|
|
|
117
|
|
|
118
|
|
|
119
|
7
|
public Conditions add(String field, String value, Operator operater) {
|
120
|
7
|
return add(field, (Object) value, operater);
|
121
|
|
}
|
122
|
|
|
123
|
|
|
124
|
|
|
125
|
|
|
126
|
|
|
127
|
|
|
128
|
|
|
129
|
|
|
130
|
|
|
131
|
13
|
public Conditions add(String field, int value) {
|
132
|
13
|
return add(field, value, Operator.EQUAL);
|
133
|
|
}
|
134
|
|
|
135
|
|
|
136
|
|
|
137
|
|
|
138
|
|
|
139
|
|
|
140
|
|
|
141
|
|
|
142
|
|
|
143
|
|
|
144
|
|
|
145
|
13
|
public Conditions add(String field, int value, Operator operater) {
|
146
|
13
|
return add(field, new Integer(value), operater);
|
147
|
|
}
|
148
|
|
|
149
|
0
|
public Conditions addRange(String field, int min, int max,
|
150
|
|
boolean includeMin, boolean includeMax) {
|
151
|
0
|
return addRange(field, new Integer(min), new Integer(max), includeMin,
|
152
|
|
includeMax);
|
153
|
|
}
|
154
|
|
|
155
|
|
|
156
|
|
|
157
|
|
|
158
|
|
|
159
|
|
|
160
|
|
|
161
|
|
|
162
|
|
|
163
|
0
|
public Conditions add(String field, long value) {
|
164
|
0
|
return add(field, value, Operator.EQUAL);
|
165
|
|
}
|
166
|
|
|
167
|
|
|
168
|
|
|
169
|
|
|
170
|
|
|
171
|
|
|
172
|
|
|
173
|
|
|
174
|
|
|
175
|
|
|
176
|
|
|
177
|
0
|
public Conditions add(String field, long value, Operator operater) {
|
178
|
0
|
return add(field, new Long(value), operater);
|
179
|
|
}
|
180
|
|
|
181
|
0
|
public Conditions addRange(String field, long min, long max,
|
182
|
|
boolean includeMin, boolean includeMax) {
|
183
|
0
|
return addRange(field, new Long(min), new Long(max), includeMin,
|
184
|
|
includeMax);
|
185
|
|
}
|
186
|
|
|
187
|
0
|
public Conditions add(String field, Date value) {
|
188
|
0
|
return add(field, value, Operator.EQUAL);
|
189
|
|
}
|
190
|
|
|
191
|
0
|
public Conditions add(String field, Date value, Operator operater) {
|
192
|
0
|
return add(field, (Object) value, operater);
|
193
|
|
}
|
194
|
|
|
195
|
0
|
public Conditions addRange(String field, Date beginDate, Date endDate) {
|
196
|
0
|
return addRange(field, beginDate, endDate, true, true);
|
197
|
|
}
|
198
|
|
|
199
|
0
|
public Conditions addRange(String field, Date beginDate, Date endDate,
|
200
|
|
boolean includeMin, boolean includeMax) {
|
201
|
0
|
return addRange(field, (Object) beginDate, (Object) endDate,
|
202
|
|
includeMin, includeMax);
|
203
|
|
}
|
204
|
|
|
205
|
|
}
|