Changeset 5948
- Timestamp:
- 2003-11-24T14:28:37+13:00 (20 years ago)
- Location:
- trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLSelect.java
r5798 r5948 3 3 public class GS3SQLSelect extends GS3SQLAction 4 4 { GS3SQLWhere where; 5 boolean distinct; 5 6 6 7 public GS3SQLSelect(String table) 7 8 { super(table); 8 9 this.where = null; 10 this.distinct = false; 9 11 } 10 12 … … 13 15 } 14 16 17 public void setDistinct(boolean distinct) 18 { this.distinct = distinct; 19 } 20 15 21 public String toString() 16 22 { StringBuffer reply = new StringBuffer(); 17 23 18 24 reply.append("SELECT "); 25 26 if (this.distinct) 27 { reply.append("DISTINCT "); 28 } 19 29 20 30 for (int i = 0; i < this.values.size(); i ++) -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLUpdate.java
r5798 r5948 25 25 reply.append(value.field); 26 26 reply.append("="); 27 if (value.getType() == null || 28 value.getType().equals(GS3SQLField.VARCHAR_TYPE)) 29 { 30 reply.append("\""); 31 } 27 32 reply.append(value.value); 33 if (value.getType() == null || 34 value.getType().equals(GS3SQLField.VARCHAR_TYPE)) 35 { 36 reply.append("\""); 37 } 28 38 } 29 39 if (this.where != null) -
trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLWhere.java
r5798 r5948 5 5 6 6 public class GS3SQLWhere implements GS3SQLWhereElement 7 8 7 { String condition; 8 List elements; 9 9 10 public GS3SQLWhere(GS3SQLWhereElement element) 11 { this.condition = "AND"; 12 this.elements = new ArrayList(); 13 this.elements.add(element); 14 } 10 public static final String AND_CONDITION = "AND"; 11 public static final String OR_CONDITION = "OR"; 15 12 16 public GS3SQLWhere(GS3SQLWhereElement element, String condition, GS3SQLWhereElement other) 17 { this.elements = new ArrayList(); 18 this.elements.add(element); 19 this.elements.add(other); 20 this.condition = condition; 21 } 22 23 public void add(GS3SQLWhereElement element) 24 { this.elements.add(element); 25 } 26 27 public String toString() 28 { StringBuffer reply = new StringBuffer(); 29 30 for (int i = 0; i < this.elements.size(); i ++) 31 { 32 if (i != 0) { 33 reply.append(" "); 34 reply.append(this.condition); 35 reply.append(" "); 36 } 37 reply.append(this.elements.get(i).toString()); 38 } 39 return reply.toString(); 40 } 13 public GS3SQLWhere(GS3SQLWhereElement element) 14 { this.condition = AND_CONDITION; 15 this.elements = new ArrayList(); 16 this.elements.add(element); 41 17 } 42 18 19 public GS3SQLWhere() 20 { this.condition = AND_CONDITION; 21 this.elements = new ArrayList(); 22 } 43 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 TracChangeset
for help on using the changeset viewer.