source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/database/GS3SQLWhere.java@ 12188

Last change on this file since 12188 was 12188, checked in by kjdon, 18 years ago

Initial revision

  • Property svn:keywords set to Author Date Id Revision
File size: 1.3 KB
Line 
1package org.greenstone.gsdl3.gs3build.database;
2
3import java.util.List;
4import java.util.ArrayList;
5
6public 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
Note: See TracBrowser for help on using the repository browser.