%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.torque.engine.platform.PlatformDefaultImpl |
|
|
1 | package org.apache.torque.engine.platform; |
|
2 | ||
3 | /* |
|
4 | * Licensed to the Apache Software Foundation (ASF) under one |
|
5 | * or more contributor license agreements. See the NOTICE file |
|
6 | * distributed with this work for additional information |
|
7 | * regarding copyright ownership. The ASF licenses this file |
|
8 | * to you under the Apache License, Version 2.0 (the |
|
9 | * "License"); you may not use this file except in compliance |
|
10 | * with the License. You may obtain a copy of the License at |
|
11 | * |
|
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
13 | * |
|
14 | * Unless required by applicable law or agreed to in writing, |
|
15 | * software distributed under the License is distributed on an |
|
16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
17 | * KIND, either express or implied. See the License for the |
|
18 | * specific language governing permissions and limitations |
|
19 | * under the License. |
|
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 | 255 | { |
45 | 255 | initialize(); |
46 | 255 | } |
47 | ||
48 | private void initialize() |
|
49 | { |
|
50 | 255 | schemaDomainMap = new Hashtable(30); |
51 | 255 | Iterator iter = SchemaType.iterator(); |
52 | 7905 | while (iter.hasNext()) |
53 | { |
|
54 | 7650 | SchemaType type = (SchemaType) iter.next(); |
55 | 7650 | schemaDomainMap.put(type, new Domain(type)); |
56 | 7650 | } |
57 | 255 | schemaDomainMap.put(SchemaType.BOOLEANCHAR, |
58 | new Domain(SchemaType.BOOLEANCHAR, "CHAR")); |
|
59 | 255 | schemaDomainMap.put(SchemaType.BOOLEANINT, |
60 | new Domain(SchemaType.BOOLEANINT, "INTEGER")); |
|
61 | 255 | } |
62 | ||
63 | protected void setSchemaDomainMapping(Domain domain) |
|
64 | { |
|
65 | 1632 | schemaDomainMap.put(domain.getType(), domain); |
66 | 1632 | } |
67 | ||
68 | /** |
|
69 | * @see Platform#getMaxColumnNameLength() |
|
70 | */ |
|
71 | public int getMaxColumnNameLength() |
|
72 | { |
|
73 | 561 | return 64; |
74 | } |
|
75 | ||
76 | /** |
|
77 | * @see Platform#getNativeIdMethod() |
|
78 | */ |
|
79 | public String getNativeIdMethod() |
|
80 | { |
|
81 | 170 | return Platform.IDENTITY; |
82 | } |
|
83 | ||
84 | /** |
|
85 | * @see Platform#getDomainForSchemaType(SchemaType) |
|
86 | */ |
|
87 | public Domain getDomainForSchemaType(SchemaType jdbcType) |
|
88 | { |
|
89 | 58616 | 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 | // TODO: Check whether this is true for all DBs. Also verify |
|
100 | // the old Sybase templates. |
|
101 | 714 | return (notNull ? "NOT NULL" : ""); |
102 | } |
|
103 | ||
104 | /** |
|
105 | * @see Platform#getAutoIncrement() |
|
106 | */ |
|
107 | public String getAutoIncrement() |
|
108 | { |
|
109 | 51 | 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 | 0 | 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 | 425 | return true; |
128 | } |
|
129 | ||
130 | /** |
|
131 | * @see Platform#createNotNullBeforeAutoincrement() |
|
132 | */ |
|
133 | public boolean createNotNullBeforeAutoincrement() |
|
134 | { |
|
135 | 1122 | return true; |
136 | } |
|
137 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |