Changeset 5948


Ignore:
Timestamp:
2003-11-24T14:28:37+13:00 (20 years ago)
Author:
cs025
Message:

Extended SQL Support

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  
    33public class GS3SQLSelect extends GS3SQLAction
    44{ GS3SQLWhere where;
     5  boolean     distinct;
    56
    67  public GS3SQLSelect(String table)
    78  { super(table);
    89    this.where  = null;
     10    this.distinct = false;
    911  }
    1012   
     
    1315  }
    1416
     17  public void setDistinct(boolean distinct)
     18  { this.distinct = distinct;
     19  }
     20
    1521  public String toString()
    1622  { StringBuffer reply = new StringBuffer();
    1723 
    1824    reply.append("SELECT ");
     25
     26    if (this.distinct)
     27    { reply.append("DISTINCT ");
     28    }
    1929 
    2030    for (int i = 0; i < this.values.size(); i ++)
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLUpdate.java

    r5798 r5948  
    2525        reply.append(value.field);
    2626    reply.append("=");
     27    if (value.getType() == null ||
     28        value.getType().equals(GS3SQLField.VARCHAR_TYPE))
     29    {
     30        reply.append("\"");
     31    }
    2732    reply.append(value.value);
     33    if (value.getType() == null ||
     34        value.getType().equals(GS3SQLField.VARCHAR_TYPE))
     35    {
     36        reply.append("\"");
     37    }
    2838      }
    2939      if (this.where != null)
  • trunk/gsdl3/src/java/org/greenstone/gsdl3/gs3build/database/GS3SQLWhere.java

    r5798 r5948  
    55
    66public class GS3SQLWhere implements GS3SQLWhereElement
    7   { String condition;
    8     List   elements;
     7{ String condition;
     8  List   elements;
    99
    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";
    1512
    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);
    4117  }
    4218
     19  public GS3SQLWhere()
     20  { this.condition = AND_CONDITION;
     21    this.elements  = new ArrayList();   
     22  }
    4323
     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.