1 | package org.greenstone.gsdl3.gs3build.database;
|
---|
2 |
|
---|
3 | import java.util.List;
|
---|
4 | import java.util.ArrayList;
|
---|
5 |
|
---|
6 | public class GS3SQLWhere implements GS3SQLWhereElement
|
---|
7 | { String condition;
|
---|
8 | List elements;
|
---|
9 |
|
---|
10 | public static final String AND_CONDITION = "AND";
|
---|
11 | public static final String OR_CONDITION = "OR";
|
---|
12 |
|
---|
13 | public GS3SQLWhere(GS3SQLWhereElement element)
|
---|
14 | { this.condition = AND_CONDITION;
|
---|
15 | this.elements = new ArrayList();
|
---|
16 | this.elements.add(element);
|
---|
17 | }
|
---|
18 |
|
---|
19 | public GS3SQLWhere()
|
---|
20 | { this.condition = AND_CONDITION;
|
---|
21 | this.elements = new ArrayList();
|
---|
22 | }
|
---|
23 |
|
---|
24 | public GS3SQLWhere(GS3SQLWhereElement element, String condition, GS3SQLWhereElement other)
|
---|
25 | { this.elements = new ArrayList();
|
---|
26 | this.elements.add(element);
|
---|
27 | this.elements.add(other);
|
---|
28 | this.condition = condition;
|
---|
29 | }
|
---|
30 |
|
---|
31 | public void add(GS3SQLWhereElement element)
|
---|
32 | { this.elements.add(element);
|
---|
33 | }
|
---|
34 |
|
---|
35 | public String toString()
|
---|
36 | { StringBuffer reply = new StringBuffer();
|
---|
37 |
|
---|
38 | for (int i = 0; i < this.elements.size(); i ++)
|
---|
39 | {
|
---|
40 | if (i != 0) {
|
---|
41 | reply.append(" ");
|
---|
42 | reply.append(this.condition);
|
---|
43 | reply.append(" ");
|
---|
44 | }
|
---|
45 | reply.append(this.elements.get(i).toString());
|
---|
46 | }
|
---|
47 | return reply.toString();
|
---|
48 | }
|
---|
49 |
|
---|
50 | public void setCondition(String condition)
|
---|
51 | { this.condition = condition;
|
---|
52 | }
|
---|
53 | }
|
---|
54 |
|
---|
55 |
|
---|