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