]> source.dussan.org Git - iciql.git/commitdiff
Documentation. Moved dialects into separate package.
authorJames Moger <james.moger@gmail.com>
Mon, 8 Aug 2011 16:25:12 +0000 (12:25 -0400)
committerJames Moger <james.moger@gmail.com>
Mon, 8 Aug 2011 16:25:12 +0000 (12:25 -0400)
docs/05_releases.mkd
src/com/iciql/Db.java
src/com/iciql/QueryBetween.java
src/com/iciql/SQLDialect.java
src/com/iciql/TableDefinition.java
src/com/iciql/dialect/DefaultSQLDialect.java [new file with mode: 0644]
src/com/iciql/dialect/H2Dialect.java [new file with mode: 0644]
src/com/iciql/dialect/package.html [new file with mode: 0644]

index f2f14ccd8238937660934f5a838556a4b7384334..b060fd2e872f2ffceea576a3e8dffcd7c6bf3874 100644 (file)
@@ -9,6 +9,7 @@
 - added UUID type support (H2 databases only)\r
 - added partial primitives support *(primitives may not be used for compile-time condition clauses)*\r
 - added *between(A y).and(A z)* condition syntax\r
+- moved dialects into separate package\r
 \r
 ### Older Releases\r
 \r
index 787331322e504c3b03ddc107007cf727b75ed485..121e50c866f901ef70844cade4ba74d0768764e2 100644 (file)
@@ -34,10 +34,10 @@ import java.util.Set;
 import javax.sql.DataSource;\r
 \r
 import com.iciql.DbUpgrader.DefaultDbUpgrader;\r
-import com.iciql.Iciql.IQVersion;\r
 import com.iciql.Iciql.IQTable;\r
-import com.iciql.SQLDialect.DefaultSQLDialect;\r
-import com.iciql.SQLDialect.H2Dialect;\r
+import com.iciql.Iciql.IQVersion;\r
+import com.iciql.dialect.DefaultSQLDialect;\r
+import com.iciql.dialect.H2Dialect;\r
 import com.iciql.util.JdbcUtils;\r
 import com.iciql.util.StringUtils;\r
 import com.iciql.util.Utils;\r
index 26ac40eec65877638c7b872bd03cb9c1ecdcd62c..de0951550d97aa16932f413cc863a229127a31ce 100644 (file)
 \r
 package com.iciql;\r
 \r
+/**\r
+ * This class represents a "between y and z" condition.\r
+ */\r
 public class QueryBetween<T, A> {\r
-       \r
+\r
        private Query<T> query;\r
        private A x;\r
        private A y;\r
 \r
+       /**\r
+        * Construct a between condition.\r
+        * \r
+        * @param query\r
+        *            the query\r
+        * @param x\r
+        *            the alias\r
+        * @param y\r
+        *            the lower bound of the between condition\r
+        */\r
        public QueryBetween(Query<T> query, A x, A y) {\r
                this.query = query;\r
                this.x = x;\r
                this.y = y;\r
        }\r
-       \r
+\r
+       /**\r
+        * Set the upper bound of the between condition.\r
+        * \r
+        * @param z\r
+        *            the upper bound of the between condition\r
+        * @return the query\r
+        */\r
        public QueryWhere<T> and(A z) {\r
                query.addConditionToken(new Condition<A>(x, y, z, CompareType.BETWEEN));\r
                return new QueryWhere<T>(query);\r
index 3cb933954396abcc4e4a6a8ed74db2f0bc94350c..8291e538d510b2d7dfd7eeafc1f9e52fe1a666ca 100644 (file)
 package com.iciql;
 
 import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.SQLException;
 
 import com.iciql.TableDefinition.IndexDefinition;
-import com.iciql.util.StatementBuilder;
-import com.iciql.util.StringUtils;
 
 /**
  * This interface defines points where iciql can build different statements
@@ -111,126 +107,4 @@ public interface SQLDialect {
         * @return true if they are
         */
        boolean supportsLimitOffset();
-
-       /**
-        * Default implementation of an SQL dialect.
-        * Does not support merge nor index creation.
-        */
-       public static class DefaultSQLDialect implements SQLDialect {
-               float databaseVersion;
-               String productName;
-               String productVersion;
-
-               @Override
-               public String toString() {
-                       return getClass().getName() + ": " + productName + " " + productVersion;
-               }
-               
-               @Override
-               public void configureDialect(Connection conn) {
-                       loadIdentity(conn);
-               }
-               
-               protected void loadIdentity(Connection conn) {
-                       try {
-                               DatabaseMetaData data = conn.getMetaData();
-                               databaseVersion = Float.parseFloat(data.getDatabaseMajorVersion() + "."
-                                               + data.getDatabaseMinorVersion());
-                               productName = data.getDatabaseProductName();
-                               productVersion = data.getDatabaseProductVersion();
-                       } catch (SQLException e) {
-                               throw new IciqlException(e);
-                       }
-               }               
-
-               @Override
-               public boolean supportsMemoryTables() {
-                       return false;
-               }
-
-               @Override
-               public boolean supportsMerge() {
-                       return false;
-               }
-               
-               @Override
-               public boolean supportsLimitOffset() {
-                       return true;
-               }
-
-               @Override
-               public String prepareTableName(String schema, String table) {
-                       if (StringUtils.isNullOrEmpty(schema)) {
-                               return table;
-                       }
-                       return schema + "." + table;
-               }
-
-               @Override
-               public String prepareColumnName(String name) {
-                       return name;
-               }
-
-               @Override
-               public String prepareCreateIndex(String schema, String table, IndexDefinition index) {
-                       throw new IciqlException("Dialect does not support index creation!");
-               }
-
-               @Override
-               public void appendLimit(SQLStatement stat, long limit) {
-                       stat.appendSQL(" LIMIT " + limit);
-               }
-
-               @Override
-               public void appendOffset(SQLStatement stat, long offset) {
-                       stat.appendSQL(" OFFSET " + offset);
-               }
-       }
-       
-
-       /**
-        * H2 database dialect.
-        */
-       public static class H2Dialect extends DefaultSQLDialect {
-
-               @Override
-               public boolean supportsMemoryTables() {
-                       return true;
-               }
-
-               @Override
-               public boolean supportsMerge() {
-                       return true;
-               }
-               
-               @Override
-               public String prepareCreateIndex(String schema, String table, IndexDefinition index) {
-                       StatementBuilder buff = new StatementBuilder();
-                       buff.append("CREATE ");
-                       switch (index.type) {
-                       case STANDARD:
-                               break;
-                       case UNIQUE:
-                               buff.append("UNIQUE ");
-                               break;
-                       case HASH:
-                               buff.append("HASH ");
-                               break;
-                       case UNIQUE_HASH:
-                               buff.append("UNIQUE HASH ");
-                               break;
-                       }
-                       buff.append("INDEX IF NOT EXISTS ");
-                       buff.append(index.indexName);
-                       buff.append(" ON ");
-                       buff.append(table);
-                       buff.append("(");
-                       for (String col : index.columnNames) {
-                               buff.appendExceptFirst(", ");
-                               buff.append(col);
-                       }
-                       buff.append(")");
-                       return buff.toString();
-               }
-       }
 }
index f5064844e0cecf4413e93aa7e534c6dca4160f61..7b3e1e436ad67e01310460a2cba79cd2ee5aff0e 100644 (file)
@@ -50,17 +50,17 @@ import com.iciql.util.Utils;
  *            the table type\r
  */\r
 \r
-class TableDefinition<T> {\r
+public class TableDefinition<T> {\r
 \r
        /**\r
         * The meta data of an index.\r
         */\r
 \r
-       static class IndexDefinition {\r
-               IndexType type;\r
-               String indexName;\r
+       public static class IndexDefinition {\r
+               public IndexType type;\r
+               public String indexName;\r
 \r
-               List<String> columnNames;\r
+               public List<String> columnNames;\r
        }\r
 \r
        /**\r
diff --git a/src/com/iciql/dialect/DefaultSQLDialect.java b/src/com/iciql/dialect/DefaultSQLDialect.java
new file mode 100644 (file)
index 0000000..517ae10
--- /dev/null
@@ -0,0 +1,86 @@
+package com.iciql.dialect;\r
+\r
+import java.sql.Connection;\r
+import java.sql.DatabaseMetaData;\r
+import java.sql.SQLException;\r
+\r
+import com.iciql.IciqlException;\r
+import com.iciql.SQLDialect;\r
+import com.iciql.SQLStatement;\r
+import com.iciql.TableDefinition.IndexDefinition;\r
+import com.iciql.util.StringUtils;\r
+\r
+/**\r
+ * Default implementation of an SQL dialect. Does not support merge nor index\r
+ * creation.\r
+ */\r
+public class DefaultSQLDialect implements SQLDialect {\r
+       float databaseVersion;\r
+       String productName;\r
+       String productVersion;\r
+\r
+       @Override\r
+       public String toString() {\r
+               return getClass().getName() + ": " + productName + " " + productVersion;\r
+       }\r
+\r
+       @Override\r
+       public void configureDialect(Connection conn) {\r
+               loadIdentity(conn);\r
+       }\r
+\r
+       protected void loadIdentity(Connection conn) {\r
+               try {\r
+                       DatabaseMetaData data = conn.getMetaData();\r
+                       databaseVersion = Float.parseFloat(data.getDatabaseMajorVersion() + "."\r
+                                       + data.getDatabaseMinorVersion());\r
+                       productName = data.getDatabaseProductName();\r
+                       productVersion = data.getDatabaseProductVersion();\r
+               } catch (SQLException e) {\r
+                       throw new IciqlException(e);\r
+               }\r
+       }\r
+\r
+       @Override\r
+       public boolean supportsMemoryTables() {\r
+               return false;\r
+       }\r
+\r
+       @Override\r
+       public boolean supportsMerge() {\r
+               return false;\r
+       }\r
+\r
+       @Override\r
+       public boolean supportsLimitOffset() {\r
+               return true;\r
+       }\r
+\r
+       @Override\r
+       public String prepareTableName(String schema, String table) {\r
+               if (StringUtils.isNullOrEmpty(schema)) {\r
+                       return table;\r
+               }\r
+               return schema + "." + table;\r
+       }\r
+\r
+       @Override\r
+       public String prepareColumnName(String name) {\r
+               return name;\r
+       }\r
+\r
+       @Override\r
+       public String prepareCreateIndex(String schema, String table, IndexDefinition index) {\r
+               throw new IciqlException("Dialect does not support index creation!");\r
+       }\r
+\r
+       @Override\r
+       public void appendLimit(SQLStatement stat, long limit) {\r
+               stat.appendSQL(" LIMIT " + limit);\r
+       }\r
+\r
+       @Override\r
+       public void appendOffset(SQLStatement stat, long offset) {\r
+               stat.appendSQL(" OFFSET " + offset);\r
+       }\r
+}
\ No newline at end of file
diff --git a/src/com/iciql/dialect/H2Dialect.java b/src/com/iciql/dialect/H2Dialect.java
new file mode 100644 (file)
index 0000000..e0a5035
--- /dev/null
@@ -0,0 +1,50 @@
+package com.iciql.dialect;\r
+\r
+import com.iciql.TableDefinition.IndexDefinition;\r
+import com.iciql.util.StatementBuilder;\r
+\r
+/**\r
+ * H2 database dialect.\r
+ */\r
+public class H2Dialect extends DefaultSQLDialect {\r
+\r
+       @Override\r
+       public boolean supportsMemoryTables() {\r
+               return true;\r
+       }\r
+\r
+       @Override\r
+       public boolean supportsMerge() {\r
+               return true;\r
+       }\r
+\r
+       @Override\r
+       public String prepareCreateIndex(String schema, String table, IndexDefinition index) {\r
+               StatementBuilder buff = new StatementBuilder();\r
+               buff.append("CREATE ");\r
+               switch (index.type) {\r
+               case STANDARD:\r
+                       break;\r
+               case UNIQUE:\r
+                       buff.append("UNIQUE ");\r
+                       break;\r
+               case HASH:\r
+                       buff.append("HASH ");\r
+                       break;\r
+               case UNIQUE_HASH:\r
+                       buff.append("UNIQUE HASH ");\r
+                       break;\r
+               }\r
+               buff.append("INDEX IF NOT EXISTS ");\r
+               buff.append(index.indexName);\r
+               buff.append(" ON ");\r
+               buff.append(table);\r
+               buff.append("(");\r
+               for (String col : index.columnNames) {\r
+                       buff.appendExceptFirst(", ");\r
+                       buff.append(col);\r
+               }\r
+               buff.append(")");\r
+               return buff.toString();\r
+       }\r
+}
\ No newline at end of file
diff --git a/src/com/iciql/dialect/package.html b/src/com/iciql/dialect/package.html
new file mode 100644 (file)
index 0000000..ad91873
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<!--
+ Copyright 2004-2011 H2 Group.
+ Copyright 2011 James Moger.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
+<head><meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
+<title>Javadoc package documentation</title>
+</head>
+<body>
+The dialect classes for iciql.
+</body>
+</html>
\ No newline at end of file