01: /*
02: * Copyright 2004-2008 H2 Group. Licensed under the H2 License, Version 1.0
03: * (http://h2database.com/html/license.html).
04: * Initial Developer: H2 Group
05: */
06: package org.h2.engine;
07:
08: import java.util.HashMap;
09:
10: import org.h2.util.StringUtils;
11:
12: /**
13: * The compatibility modes. There is a fixed set of modes (for example
14: * PostgreSQL, MySQL). Each mode has different settings.
15: */
16: public class Mode {
17:
18: public static final String REGULAR = "REGULAR";
19:
20: public boolean nullConcatIsNull;
21: public boolean convertInsertNullToZero;
22: public boolean convertOnlyToSmallerScale;
23: public boolean roundWhenConvertToLong;
24: public boolean lowerCaseIdentifiers;
25: public boolean indexDefinitionInCreateTable;
26: public boolean systemColumns;
27: public boolean squareBracketQuotedNames;
28:
29: private static final HashMap MODES = new HashMap();
30:
31: private String name;
32:
33: static {
34: Mode mode = new Mode(REGULAR);
35: add(mode);
36:
37: mode = new Mode("PostgreSQL");
38: mode.nullConcatIsNull = true;
39: mode.roundWhenConvertToLong = true;
40: mode.systemColumns = true;
41: add(mode);
42:
43: mode = new Mode("MySQL");
44: mode.convertInsertNullToZero = true;
45: mode.roundWhenConvertToLong = true;
46: mode.lowerCaseIdentifiers = true;
47: mode.indexDefinitionInCreateTable = true;
48: add(mode);
49:
50: mode = new Mode("HSQLDB");
51: mode.nullConcatIsNull = true;
52: mode.convertOnlyToSmallerScale = true;
53: add(mode);
54:
55: mode = new Mode("MSSQLServer");
56: mode.squareBracketQuotedNames = true;
57: add(mode);
58:
59: }
60:
61: private static void add(Mode mode) {
62: MODES.put(StringUtils.toUpperEnglish(mode.name), mode);
63: }
64:
65: private Mode(String name) {
66: this .name = name;
67: }
68:
69: public static Mode getInstance(String name) {
70: return (Mode) MODES.get(StringUtils.toUpperEnglish(name));
71: }
72:
73: public String getName() {
74: return name;
75: }
76:
77: }
|