source: trunk/greenstone3-extensions/gs3build/src/org/greenstone/gsdl3/gs3build/database/GS3SQLSelect.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: 962 bytes
Line 
1package org.greenstone.gsdl3.gs3build.database;
2
3public class GS3SQLSelect extends GS3SQLAction
4{ GS3SQLWhere where;
5 boolean distinct;
6
7 public GS3SQLSelect(String table)
8 { super(table);
9 this.where = null;
10 this.distinct = false;
11 }
12
13 public void setWhere(GS3SQLWhere where)
14 { this.where = where;
15 }
16
17 public void setDistinct(boolean distinct)
18 { this.distinct = distinct;
19 }
20
21 public String toString()
22 { StringBuffer reply = new StringBuffer();
23
24 reply.append("SELECT ");
25
26 if (this.distinct)
27 { reply.append("DISTINCT ");
28 }
29
30 for (int i = 0; i < this.values.size(); i ++)
31 { GS3SQLValue value = (GS3SQLValue) this.values.get(i);
32 if (i > 0)
33 reply.append(", ");
34 reply.append(value.field);
35 }
36
37 reply.append(" FROM ");
38 reply.append(this.table);
39
40 if (this.where != null)
41 { reply.append(" WHERE ");
42 reply.append(where.toString());
43 }
44 return reply.toString();
45 }
46}
47
48
Note: See TracBrowser for help on using the repository browser.