diff options
author | James Moger <james.moger@gmail.com> | 2011-08-10 09:18:43 -0400 |
---|---|---|
committer | James Moger <james.moger@gmail.com> | 2011-08-10 09:18:43 -0400 |
commit | f3faeb5d1ea631b0074441f97080e1f2a9145f4b (patch) | |
tree | 94fffd66c04d2740778614b9cb00c608b759e148 /src/com | |
parent | 1d381026a5d256a59fe41da42c7f4e86bb60f02c (diff) | |
download | iciql-f3faeb5d1ea631b0074441f97080e1f2a9145f4b.tar.gz iciql-f3faeb5d1ea631b0074441f97080e1f2a9145f4b.zip |
Moved dialects back to main package. Registered MySQL dialect.
Diffstat (limited to 'src/com')
-rw-r--r-- | src/com/iciql/Db.java | 7 | ||||
-rw-r--r-- | src/com/iciql/SQLDialectDefault.java (renamed from src/com/iciql/dialect/DefaultSQLDialect.java) | 25 | ||||
-rw-r--r-- | src/com/iciql/SQLDialectH2.java (renamed from src/com/iciql/dialect/H2Dialect.java) | 22 | ||||
-rw-r--r-- | src/com/iciql/SQLDialectMySQL.java (renamed from src/com/iciql/dialect/MySQLDialect.java) | 24 | ||||
-rw-r--r-- | src/com/iciql/TableDefinition.java | 8 | ||||
-rw-r--r-- | src/com/iciql/dialect/package.html | 25 |
6 files changed, 63 insertions, 48 deletions
diff --git a/src/com/iciql/Db.java b/src/com/iciql/Db.java index d6f70d1..c7801c2 100644 --- a/src/com/iciql/Db.java +++ b/src/com/iciql/Db.java @@ -37,8 +37,6 @@ import javax.sql.DataSource; import com.iciql.DbUpgrader.DefaultDbUpgrader;
import com.iciql.Iciql.IQTable;
import com.iciql.Iciql.IQVersion;
-import com.iciql.dialect.DefaultSQLDialect;
-import com.iciql.dialect.H2Dialect;
import com.iciql.util.JdbcUtils;
import com.iciql.util.StringUtils;
import com.iciql.util.Utils;
@@ -73,7 +71,8 @@ public class Db { // can register by...
// 1. Connection class name
// 2. DatabaseMetaData.getDatabaseProductName()
- DIALECTS.put("h2", H2Dialect.class);
+ DIALECTS.put("H2", SQLDialectH2.class);
+ DIALECTS.put("MySQL", SQLDialectMySQL.class);
}
private Db(Connection conn) {
@@ -114,7 +113,7 @@ public class Db { dialectClass = DIALECTS.get(databaseName);
} else {
// did not find a match, use default
- dialectClass = DefaultSQLDialect.class;
+ dialectClass = SQLDialectDefault.class;
}
return instance(dialectClass);
}
diff --git a/src/com/iciql/dialect/DefaultSQLDialect.java b/src/com/iciql/SQLDialectDefault.java index f3f222e..760a1f4 100644 --- a/src/com/iciql/dialect/DefaultSQLDialect.java +++ b/src/com/iciql/SQLDialectDefault.java @@ -1,12 +1,25 @@ -package com.iciql.dialect;
+/*
+ * 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.
+ */
+
+package com.iciql;
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
-import com.iciql.IciqlException;
-import com.iciql.SQLDialect;
-import com.iciql.SQLStatement;
-import com.iciql.TableDefinition;
import com.iciql.TableDefinition.IndexDefinition;
import com.iciql.util.StringUtils;
@@ -14,7 +27,7 @@ import com.iciql.util.StringUtils; * Default implementation of an SQL dialect. Does not support merge nor index
* creation.
*/
-public class DefaultSQLDialect implements SQLDialect {
+public class SQLDialectDefault implements SQLDialect {
float databaseVersion;
String databaseName;
String productVersion;
diff --git a/src/com/iciql/dialect/H2Dialect.java b/src/com/iciql/SQLDialectH2.java index 61babd7..c65c277 100644 --- a/src/com/iciql/dialect/H2Dialect.java +++ b/src/com/iciql/SQLDialectH2.java @@ -1,7 +1,21 @@ -package com.iciql.dialect;
+/*
+ * 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.
+ */
+
+package com.iciql;
-import com.iciql.SQLStatement;
-import com.iciql.TableDefinition;
import com.iciql.TableDefinition.FieldDefinition;
import com.iciql.TableDefinition.IndexDefinition;
import com.iciql.util.StatementBuilder;
@@ -9,7 +23,7 @@ import com.iciql.util.StatementBuilder; /**
* H2 database dialect.
*/
-public class H2Dialect extends DefaultSQLDialect {
+public class SQLDialectH2 extends SQLDialectDefault {
@Override
public boolean supportsMemoryTables() {
diff --git a/src/com/iciql/dialect/MySQLDialect.java b/src/com/iciql/SQLDialectMySQL.java index e1ccaf3..837d77b 100644 --- a/src/com/iciql/dialect/MySQLDialect.java +++ b/src/com/iciql/SQLDialectMySQL.java @@ -1,15 +1,29 @@ -package com.iciql.dialect;
+/*
+ * 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.
+ */
+
+package com.iciql;
-import com.iciql.SQLStatement;
-import com.iciql.TableDefinition;
import com.iciql.TableDefinition.FieldDefinition;
import com.iciql.TableDefinition.IndexDefinition;
import com.iciql.util.StatementBuilder;
/**
- * H2 database dialect.
+ * MySQL database dialect.
*/
-public class MySQLDialect extends DefaultSQLDialect {
+public class SQLDialectMySQL extends SQLDialectDefault {
@Override
public boolean supportsMemoryTables() {
diff --git a/src/com/iciql/TableDefinition.java b/src/com/iciql/TableDefinition.java index 5d934a5..c08a032 100644 --- a/src/com/iciql/TableDefinition.java +++ b/src/com/iciql/TableDefinition.java @@ -67,12 +67,12 @@ public class TableDefinition<T> { * The meta data of a field.
*/
- public static class FieldDefinition {
- public String columnName;
+ static class FieldDefinition {
+ String columnName;
Field field;
String dataType;
int maxLength;
- public boolean isPrimaryKey;
+ boolean isPrimaryKey;
boolean isAutoIncrement;
boolean trimString;
boolean nullable;
@@ -362,7 +362,7 @@ public class TableDefinition<T> { * Optionally truncates strings to the maximum length and converts
* java.lang.Enum types to Strings or Integers.
*/
- public Object getValue(Object obj, FieldDefinition field) {
+ Object getValue(Object obj, FieldDefinition field) {
Object value = field.getValue(obj);
if (value == null) {
return value;
diff --git a/src/com/iciql/dialect/package.html b/src/com/iciql/dialect/package.html deleted file mode 100644 index ad91873..0000000 --- a/src/com/iciql/dialect/package.html +++ /dev/null @@ -1,25 +0,0 @@ -<!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 |