mikeh 01/06/26 08:32:02
Modified: proposals/eric/statement BaseSql.java
Log:
added select distinct, and set (list) methods
Revision Changes Path
1.4 +67 -43 jakarta-turbine/proposals/eric/statement/BaseSql.java
Index: BaseSql.java
===================================================================
RCS file: /home/cvs/jakarta-turbine/proposals/eric/statement/BaseSql.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- BaseSql.java 2001/06/24 14:38:23 1.3
+++ BaseSql.java 2001/06/26 15:32:00 1.4
@@ -77,7 +77,8 @@
* getUpdate --> update <em>left</em> <em>item1</em>,...,<em>itemN</em>
* getSet --> set <em>left</em>=<em>right</em>
* getDelete --> delete from <em>left</em>
- * getSelect --> select <em>item1</em>,<em>item2</em>,...,<em>itemN</em>
+ * getSelect --> select <em>item1</em>,...,<em>itemN</em>
+ * getSelectDistinct --> select distinct <em>item1</em>,...,<em>itemN</em>
* getFrom --> from <em>item1</em>,<em>item2</em>,...,<em>itemN</em>
* getWhere --> where <em>tree</em>
* getEqual --> (<em>left</em> = <em>right</em>)
@@ -95,8 +96,8 @@
* getNot --> (not <em>item</em>)
* getAscending --> <em>item</em> ASC
* getDescending --> <em>item</em> DESC
- * getOrderBy --> order by <em>item1</em>,<em>item2</em>,...,<em>itemN</em>
- * getGroupBy --> group by <em>item1</em>,<em>item2</em>,...,<em>itemN</em>
+ * getOrderBy --> order by <em>item1</em>...,<em>itemN</em>
+ * getGroupBy --> group by <em>item1</em>...,<em>itemN</em>
* getHaving --> having <em>tree</em>
* getCount --> count(<em>item</em>)
* getMin --> min(<em>item</em>)
@@ -115,46 +116,47 @@
* </p>
*/
public class BaseSql
- implements Sql
+ implements Sql
{
- public static String EMPTY = "";
- public static String SPACE = " ";
- public static String INSERT = "INSERT INTO ";
- public static String VALUES = " VALUES ";
- public static String UPDATE = "UPDATE ";
- public static String DELETE = "DELETE FROM ";
- public static String SELECT = "SELECT ";
- public static String SET = "SET ";
- public static String FROM = " FROM ";
- public static String WHERE = " WHERE ";
- public static String ORDER_BY = " ORDER BY ";
- public static String GROUP_BY = " GROUP BY ";
- public static String HAVING = " HAVING ";
- public static String ASC = " ASC";
- public static String DESC = " DESC";
- public static String OPEN_PAREN = "(";
- public static String CLOSE_PAREN = ")";
- public static String EQUALS = "=";
- public static String NOT_EQUALS = "!=";
- public static String GREATER_THAN = ">";
- public static String LESS_THAN = "<";
- public static String GREATER_EQUAL = ">=";
- public static String LESS_EQUAL = "<=";
- public static String IS_NULL = " IS NULL";
- public static String IS_NOT_NULL = " IS NOT NULL";
- public static String IN = " IN ";
- public static String NOT_IN = " NOT IN ";
- public static String LIKE = " LIKE ";
- public static String AND = " AND ";
- public static String OR = " OR ";
- public static String NOT = " NOT ";
- public static String COUNT = "COUNT";
- public static String MIN = "MIN";
- public static String MAX = "MAX";
- public static String AVG = "AVG";
- public static String SUM = "SUM";
- public static String UPPER = "UPPER";
- public static String COMMA = ", ";
+ public static String EMPTY = "";
+ public static String SPACE = " ";
+ public static String INSERT = "INSERT INTO ";
+ public static String VALUES = " VALUES ";
+ public static String UPDATE = "UPDATE ";
+ public static String DELETE = "DELETE FROM ";
+ public static String SELECT = "SELECT ";
+ public static String SELECT_DISTINCT = "SELECT DISTINCT ";
+ public static String SET = "SET ";
+ public static String FROM = " FROM ";
+ public static String WHERE = " WHERE ";
+ public static String ORDER_BY = " ORDER BY ";
+ public static String GROUP_BY = " GROUP BY ";
+ public static String HAVING = " HAVING ";
+ public static String ASC = " ASC";
+ public static String DESC = " DESC";
+ public static String OPEN_PAREN = "(";
+ public static String CLOSE_PAREN = ")";
+ public static String EQUALS = "=";
+ public static String NOT_EQUALS = "!=";
+ public static String GREATER_THAN = ">";
+ public static String LESS_THAN = "<";
+ public static String GREATER_EQUAL = ">=";
+ public static String LESS_EQUAL = "<=";
+ public static String IS_NULL = " IS NULL";
+ public static String IS_NOT_NULL = " IS NOT NULL";
+ public static String IN = " IN ";
+ public static String NOT_IN = " NOT IN ";
+ public static String LIKE = " LIKE ";
+ public static String AND = " AND ";
+ public static String OR = " OR ";
+ public static String NOT = " NOT ";
+ public static String COUNT = "COUNT";
+ public static String MIN = "MIN";
+ public static String MAX = "MAX";
+ public static String AVG = "AVG";
+ public static String SUM = "SUM";
+ public static String UPPER = "UPPER";
+ public static String COMMA = ", ";
private static final char SINGLE_QUOTE = '\'';
/**
@@ -507,7 +509,7 @@
*
* @param left String the table to insert values into
* @param list List the list of column names
- * @return INSERT INTO <em>left</em> (<em>item1</em>, <em>item2</em>, ...,
<em>itemN</em>)
+ * @return INSERT INTO <em>left</em> (<em>item1</em>, ..., <em>itemN</em>)
*/
public String getInsert(String left, List list)
{
@@ -572,6 +574,17 @@
}
/**
+ * Constructs a set statement.
+ *
+ * @param list List the list of items
+ * @return SET <em>item1</em>, ... <em>itemN</em>
+ */
+ public String getSet(List list)
+ {
+ return leftRightListConnector(SET, EMPTY, list, COMMA);
+ }
+
+ /**
* Constructs a delete fragment.
*
* @param left String the table from which rows will be deleted
@@ -591,6 +604,17 @@
public String getSelect(List list)
{
return leftRightListConnector(SELECT, EMPTY, list, COMMA);
+ }
+
+ /**
+ * Constructs a select distinct fragment.
+ *
+ * @param list List the list of items
+ * @return SELECT DISTINCT <em>item1</em>, ..., <em>itemN</em>
+ */
+ public String getSelectDistinct(List list)
+ {
+ return leftRightListConnector(SELECT_DISTINCT, EMPTY, list, COMMA);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]