KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > oracle > toplink > essentials > platform > database > PointBasePlatform


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the "License"). You may not use this file except
5  * in compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * glassfish/bootstrap/legal/CDDLv1.0.txt or
9  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * HEADER in each file and include the License file at
15  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
16  * add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your
18  * own identifying information: Portions Copyright [yyyy]
19  * [name of copyright owner]
20  */

21 // Copyright (c) 1998, 2006, Oracle. All rights reserved.
22
package oracle.toplink.essentials.platform.database;
23
24 import java.io.*;
25 import java.util.*;
26 import oracle.toplink.essentials.expressions.ExpressionOperator;
27 import oracle.toplink.essentials.internal.databaseaccess.*;
28
29 /**
30  * Support the Pointbase database.
31  */

32 public class PointBasePlatform extends oracle.toplink.essentials.platform.database.DatabasePlatform {
33
34     /**
35      * INTERNAL:
36      * Appends a Boolean value as true/false instead of 0/1
37      */

38     protected void appendBoolean(Boolean JavaDoc bool, Writer writer) throws IOException {
39         writer.write(bool.toString());
40     }
41
42     /**
43      * INTERNAL:
44      * Write a Time in PointBase specific format.
45      */

46     protected void appendTime(java.sql.Time JavaDoc time, Writer writer) throws IOException {
47         writer.write("TIME '" + time + "'");
48     }
49
50     /**
51      * INTERNAL:
52      * Write a Date in PointBase specific format.
53      */

54     protected void appendDate(java.sql.Date JavaDoc date, Writer writer) throws IOException {
55         writer.write("DATE '" + date + "'");
56     }
57
58     /**
59      * INTERNAL:
60      * Write a TimeStamp in PointBase specific format.
61      */

62     protected void appendTimestamp(java.sql.Timestamp JavaDoc timestamp, Writer writer) throws IOException {
63         writer.write("TIMESTAMP '" + timestamp + "'");
64     }
65
66     protected Hashtable buildClassTypes() {
67         Hashtable classTypeMapping = super.buildClassTypes();
68
69         classTypeMapping.put("FLOAT", Double JavaDoc.class);
70         classTypeMapping.put("DOUBLE PRECISION", Double JavaDoc.class);
71         classTypeMapping.put("CHARACTER", String JavaDoc.class);
72         classTypeMapping.put("CLOB", Character JavaDoc[].class);
73         classTypeMapping.put("BLOB", Byte JavaDoc[].class);
74         classTypeMapping.put("BOOLEAN", Boolean JavaDoc.class);
75
76         return classTypeMapping;
77     }
78
79     protected Hashtable buildFieldTypes() {
80         Hashtable fieldTypeMapping;
81
82         fieldTypeMapping = super.buildFieldTypes();
83         fieldTypeMapping.put(Boolean JavaDoc.class, new FieldTypeDefinition("BOOLEAN"));
84
85         fieldTypeMapping.put(Long JavaDoc.class, new FieldTypeDefinition("NUMERIC", 19));
86         fieldTypeMapping.put(Short JavaDoc.class, new FieldTypeDefinition("NUMERIC", 5));
87         fieldTypeMapping.put(Byte JavaDoc.class, new FieldTypeDefinition("NUMERIC", 3));
88         fieldTypeMapping.put(java.math.BigInteger JavaDoc.class, new FieldTypeDefinition("NUMERIC", 19));
89
90         fieldTypeMapping.put(Integer JavaDoc.class, new FieldTypeDefinition("INTEGER", false));
91         fieldTypeMapping.put(Float JavaDoc.class, new FieldTypeDefinition("REAL", false));
92         fieldTypeMapping.put(Double JavaDoc.class, new FieldTypeDefinition("DOUBLE", false));
93         fieldTypeMapping.put(Short JavaDoc.class, new FieldTypeDefinition("SMALLINT", false));
94         fieldTypeMapping.put(java.math.BigDecimal JavaDoc.class, new FieldTypeDefinition("DECIMAL"));
95         fieldTypeMapping.put(Number JavaDoc.class, new FieldTypeDefinition("DECIMAL"));
96
97         fieldTypeMapping.put(Character JavaDoc.class, new FieldTypeDefinition("CHARACTER"));
98
99         return fieldTypeMapping;
100     }
101
102     protected void initializePlatformOperators() {
103         super.initializePlatformOperators();
104         addOperator(ExpressionOperator.simpleMath(ExpressionOperator.Concat, "||"));
105     }
106
107     public boolean isPointBase() {
108         return true;
109     }
110 }
111
Popular Tags