1 package org.apache.torque.engine.platform;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Hashtable;
23 import java.util.Iterator;
24 import java.util.Map;
25
26 import org.apache.torque.engine.database.model.Domain;
27 import org.apache.torque.engine.database.model.SchemaType;
28
29
30 /***
31 * Default implementation for the Platform interface.
32 *
33 * @author <a href="mailto:mpoeschl@marmot.at">Martin Poeschl</a>
34 * @version $Id: PlatformDefaultImpl.java 473814 2006-11-11 22:30:30Z tv $
35 */
36 public class PlatformDefaultImpl implements Platform
37 {
38 private Map schemaDomainMap;
39
40 /***
41 * Default constructor.
42 */
43 public PlatformDefaultImpl()
44 {
45 initialize();
46 }
47
48 private void initialize()
49 {
50 schemaDomainMap = new Hashtable(30);
51 Iterator iter = SchemaType.iterator();
52 while (iter.hasNext())
53 {
54 SchemaType type = (SchemaType) iter.next();
55 schemaDomainMap.put(type, new Domain(type));
56 }
57 schemaDomainMap.put(SchemaType.BOOLEANCHAR,
58 new Domain(SchemaType.BOOLEANCHAR, "CHAR"));
59 schemaDomainMap.put(SchemaType.BOOLEANINT,
60 new Domain(SchemaType.BOOLEANINT, "INTEGER"));
61 }
62
63 protected void setSchemaDomainMapping(Domain domain)
64 {
65 schemaDomainMap.put(domain.getType(), domain);
66 }
67
68 /***
69 * @see Platform#getMaxColumnNameLength()
70 */
71 public int getMaxColumnNameLength()
72 {
73 return 64;
74 }
75
76 /***
77 * @see Platform#getNativeIdMethod()
78 */
79 public String getNativeIdMethod()
80 {
81 return Platform.IDENTITY;
82 }
83
84 /***
85 * @see Platform#getDomainForSchemaType(SchemaType)
86 */
87 public Domain getDomainForSchemaType(SchemaType jdbcType)
88 {
89 return (Domain) schemaDomainMap.get(jdbcType);
90 }
91
92 /***
93 * @return Only produces a SQL fragment if null values are
94 * disallowed.
95 * @see Platform#getNullString(boolean)
96 */
97 public String getNullString(boolean notNull)
98 {
99
100
101 return (notNull ? "NOT NULL" : "");
102 }
103
104 /***
105 * @see Platform#getAutoIncrement()
106 */
107 public String getAutoIncrement()
108 {
109 return "IDENTITY";
110 }
111
112 /***
113 * @see Platform#hasScale(String)
114 * TODO collect info for all platforms
115 */
116 public boolean hasScale(String sqlType)
117 {
118 return true;
119 }
120
121 /***
122 * @see Platform#hasSize(String)
123 * TODO collect info for all platforms
124 */
125 public boolean hasSize(String sqlType)
126 {
127 return true;
128 }
129
130 /***
131 * @see Platform#createNotNullBeforeAutoincrement()
132 */
133 public boolean createNotNullBeforeAutoincrement()
134 {
135 return true;
136 }
137 }