提交 1ed9a110 authored 作者: Noel Grandin's avatar Noel Grandin

simplify the new Mode.ModeEnum stuff

上级 c99ad8ad
...@@ -163,7 +163,7 @@ public class Database implements DataHandler { ...@@ -163,7 +163,7 @@ public class Database implements DataHandler {
private boolean referentialIntegrity = true; private boolean referentialIntegrity = true;
private boolean multiVersion; private boolean multiVersion;
private DatabaseCloser closeOnExit; private DatabaseCloser closeOnExit;
private Mode mode = Mode.getInstance(Mode.REGULAR); private Mode mode = Mode.getRegular();
private boolean multiThreaded; private boolean multiThreaded;
private int maxOperationMemory = private int maxOperationMemory =
Constants.DEFAULT_MAX_OPERATION_MEMORY; Constants.DEFAULT_MAX_OPERATION_MEMORY;
......
...@@ -19,14 +19,9 @@ import org.h2.util.StringUtils; ...@@ -19,14 +19,9 @@ import org.h2.util.StringUtils;
public class Mode { public class Mode {
public enum ModeEnum { public enum ModeEnum {
REGULAR, DB2, Derby, MSSQLServer, HSQLDB, MySQL, Oracle, PostgreSQL, Ignite, REGULAR, DB2, Derby, MSSQLServer, HSQLDB, MySQL, Oracle, PostgreSQL, Ignite
} }
/**
* The name of the default mode.
*/
static final String REGULAR = ModeEnum.REGULAR.name();
private static final HashMap<String, Mode> MODES = New.hashMap(); private static final HashMap<String, Mode> MODES = New.hashMap();
// Modes are also documented in the features section // Modes are also documented in the features section
...@@ -182,16 +177,14 @@ public class Mode { ...@@ -182,16 +177,14 @@ public class Mode {
*/ */
public Set<String> disallowedTypes = Collections.emptySet(); public Set<String> disallowedTypes = Collections.emptySet();
private final String name;
private ModeEnum modeEnum; private ModeEnum modeEnum;
static { static {
Mode mode = new Mode(ModeEnum.REGULAR.name()); Mode mode = new Mode(ModeEnum.REGULAR);
mode.nullConcatIsNull = true; mode.nullConcatIsNull = true;
add(mode); add(mode);
mode = new Mode(ModeEnum.DB2.name()); mode = new Mode(ModeEnum.DB2);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.supportOffsetFetch = true; mode.supportOffsetFetch = true;
mode.sysDummy1 = true; mode.sysDummy1 = true;
...@@ -206,7 +199,7 @@ public class Mode { ...@@ -206,7 +199,7 @@ public class Mode {
mode.allowDB2TimestampFormat = true; mode.allowDB2TimestampFormat = true;
add(mode); add(mode);
mode = new Mode(ModeEnum.Derby.name()); mode = new Mode(ModeEnum.Derby);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.uniqueIndexSingleNull = true; mode.uniqueIndexSingleNull = true;
mode.supportOffsetFetch = true; mode.supportOffsetFetch = true;
...@@ -216,7 +209,7 @@ public class Mode { ...@@ -216,7 +209,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null; mode.supportedClientInfoPropertiesRegEx = null;
add(mode); add(mode);
mode = new Mode(ModeEnum.HSQLDB.name()); mode = new Mode(ModeEnum.HSQLDB);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.convertOnlyToSmallerScale = true; mode.convertOnlyToSmallerScale = true;
mode.nullConcatIsNull = true; mode.nullConcatIsNull = true;
...@@ -229,7 +222,7 @@ public class Mode { ...@@ -229,7 +222,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null; mode.supportedClientInfoPropertiesRegEx = null;
add(mode); add(mode);
mode = new Mode(ModeEnum.MSSQLServer.name()); mode = new Mode(ModeEnum.MSSQLServer);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.squareBracketQuotedNames = true; mode.squareBracketQuotedNames = true;
mode.uniqueIndexSingleNull = true; mode.uniqueIndexSingleNull = true;
...@@ -241,7 +234,7 @@ public class Mode { ...@@ -241,7 +234,7 @@ public class Mode {
mode.supportedClientInfoPropertiesRegEx = null; mode.supportedClientInfoPropertiesRegEx = null;
add(mode); add(mode);
mode = new Mode(ModeEnum.MySQL.name()); mode = new Mode(ModeEnum.MySQL);
mode.convertInsertNullToZero = true; mode.convertInsertNullToZero = true;
mode.indexDefinitionInCreateTable = true; mode.indexDefinitionInCreateTable = true;
mode.lowerCaseIdentifiers = true; mode.lowerCaseIdentifiers = true;
...@@ -255,7 +248,7 @@ public class Mode { ...@@ -255,7 +248,7 @@ public class Mode {
mode.prohibitEmptyInPredicate = true; mode.prohibitEmptyInPredicate = true;
add(mode); add(mode);
mode = new Mode(ModeEnum.Oracle.name()); mode = new Mode(ModeEnum.Oracle);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.convertOnlyToSmallerScale = true; mode.convertOnlyToSmallerScale = true;
mode.uniqueIndexSingleNullExceptAllColumnsAreNull = true; mode.uniqueIndexSingleNullExceptAllColumnsAreNull = true;
...@@ -268,7 +261,7 @@ public class Mode { ...@@ -268,7 +261,7 @@ public class Mode {
mode.prohibitEmptyInPredicate = true; mode.prohibitEmptyInPredicate = true;
add(mode); add(mode);
mode = new Mode(ModeEnum.PostgreSQL.name()); mode = new Mode(ModeEnum.PostgreSQL);
mode.aliasColumnName = true; mode.aliasColumnName = true;
mode.nullConcatIsNull = true; mode.nullConcatIsNull = true;
mode.supportOffsetFetch = true; mode.supportOffsetFetch = true;
...@@ -291,20 +284,19 @@ public class Mode { ...@@ -291,20 +284,19 @@ public class Mode {
mode.disallowedTypes = disallowedTypes; mode.disallowedTypes = disallowedTypes;
add(mode); add(mode);
mode = new Mode(ModeEnum.Ignite.name()); mode = new Mode(ModeEnum.Ignite);
mode.nullConcatIsNull = true; mode.nullConcatIsNull = true;
mode.allowAffinityKey = true; mode.allowAffinityKey = true;
mode.indexDefinitionInCreateTable = true; mode.indexDefinitionInCreateTable = true;
add(mode); add(mode);
} }
private Mode(String name) { private Mode(ModeEnum modeEnum) {
this.name = name; this.modeEnum = modeEnum;
this.modeEnum = ModeEnum.valueOf(name);
} }
private static void add(Mode mode) { private static void add(Mode mode) {
MODES.put(StringUtils.toUpperEnglish(mode.name), mode); MODES.put(StringUtils.toUpperEnglish(mode.modeEnum.name()), mode);
} }
/** /**
...@@ -317,6 +309,10 @@ public class Mode { ...@@ -317,6 +309,10 @@ public class Mode {
return MODES.get(StringUtils.toUpperEnglish(name)); return MODES.get(StringUtils.toUpperEnglish(name));
} }
public static Mode getRegular() {
return getInstance(ModeEnum.REGULAR.name());
}
public static Mode getMySQL() { public static Mode getMySQL() {
return getInstance(ModeEnum.MySQL.name()); return getInstance(ModeEnum.MySQL.name());
} }
...@@ -326,7 +322,7 @@ public class Mode { ...@@ -326,7 +322,7 @@ public class Mode {
} }
public String getName() { public String getName() {
return name; return modeEnum.name();
} }
public ModeEnum getEnum() { public ModeEnum getEnum() {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论