KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > h2 > engine > Mode


1 /*
2  * Copyright 2004-2006 H2 Group. Licensed under the H2 License, Version 1.0 (http://h2database.com/html/license.html).
3  * Initial Developer: H2 Group
4  */

5 package org.h2.engine;
6
7 import java.util.HashMap JavaDoc;
8
9 import org.h2.util.StringUtils;
10
11 public class Mode {
12     
13     // TODO isolation: this setting should not be global
14
private static Mode currentMode;
15     public static final String JavaDoc REGULAR_NAME = "REGULAR";
16     
17     public boolean nullConcatIsNull;
18     public boolean convertInsertNullToZero;
19     public boolean convertOnlyToSmallerScale;
20     public boolean roundWhenConvertToLong ;
21     public boolean lowerCaseIdentifiers;
22     public boolean indexDefinitionInCreateTable;
23
24     private static final HashMap JavaDoc MODES = new HashMap JavaDoc();
25     
26     private String JavaDoc name;
27     
28     public static void setCurrentMode(Mode mode) {
29         currentMode = mode;
30     }
31     
32     public static Mode getCurrentMode() {
33         return currentMode;
34     }
35     
36     static {
37         Mode mode = new Mode(REGULAR_NAME);
38         setCurrentMode(mode);
39         add(mode);
40
41         mode = new Mode("PostgreSQL");
42         mode.nullConcatIsNull = true;
43         mode.roundWhenConvertToLong = true;
44         add(mode);
45         
46         mode = new Mode("MySQL");
47         mode.convertInsertNullToZero = true;
48         mode.roundWhenConvertToLong = true;
49         mode.lowerCaseIdentifiers = true;
50         mode.indexDefinitionInCreateTable = true;
51         add(mode);
52         
53         mode = new Mode("HSQLDB");
54         mode.nullConcatIsNull = true;
55         mode.convertOnlyToSmallerScale = true;
56         add(mode);
57     }
58     
59     private static void add(Mode mode) {
60         MODES.put(StringUtils.toUpperEnglish(mode.name), mode);
61     }
62     
63     private Mode(String JavaDoc name) {
64         this.name = name;
65     }
66     
67     public static Mode getMode(String JavaDoc name) {
68         return (Mode) MODES.get(StringUtils.toUpperEnglish(name));
69     }
70     
71     public String JavaDoc getName() {
72         return name;
73     }
74     
75 }
76
Popular Tags