1 5 package org.h2.engine; 6 7 import java.util.HashMap ; 8 9 import org.h2.util.StringUtils; 10 11 public class Mode { 12 13 private static Mode currentMode; 15 public static final String 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 MODES = new HashMap (); 25 26 private String 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 name) { 64 this.name = name; 65 } 66 67 public static Mode getMode(String name) { 68 return (Mode) MODES.get(StringUtils.toUpperEnglish(name)); 69 } 70 71 public String getName() { 72 return name; 73 } 74 75 } 76 | Popular Tags |