KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > dbPort > ConvertMap


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.dbPort;
15
16 import java.util.*;
17
18 /**
19  * Database Syntax Conversion Map.
20  *
21  *
22  * @author Jorg Janke & Victor Perez
23  * @version $Id: ConvertMap.java,v 1.12 2002/08/12 01:55:15 danb Exp $
24  */

25 public class ConvertMap
26 {
27     /**
28      * Return Map for PostgreSQL
29      * @return TreeMap with pattern as key and the replavement as value
30      */

31     public static TreeMap getPostgetSQLMap()
32     {
33         return s_pg;
34     } // getPostgreSQLMap
35

36     /** Tree Map for PostgreSQL */
37     private static TreeMap s_pg = new TreeMap();
38
39     /**
40      * Static Initializer
41      */

42     static
43     {
44         // Oracle Pattern Replacement
45

46         // Column Names
47
s_pg.put("\\bROWID\\b", "OID");
48
49         // Data Types
50
s_pg.put("\\bNUMBER\\b", "NUMERIC");
51         s_pg.put("\\bDATE\\b", "TIMESTAMP");
52         s_pg.put("\\bVARCHAR2\\b", "VARCHAR");
53         s_pg.put("\\bNVARCHAR2\\b", "VARCHAR");
54         s_pg.put("\\bNCHAR\\b", "CHAR");
55         s_pg.put("\\bBLOB\\b", "OID"); // BLOB not directly supported
56
s_pg.put("\\bCLOB\\b", "TEXT"); // CLOB not directly supported
57

58         // Storage
59
s_pg.put("\\bCACHE\\b", "");
60         s_pg.put("\\bUSING INDEX\\b", "");
61         s_pg.put("\\bTABLESPACE\\s\\w+\\b", "");
62         s_pg.put("\\bSTORAGE\\([\\w\\s]+\\)", "");
63         //
64
s_pg.put("\\bBITMAP INDEX\\b", "INDEX");
65
66         // Functions
67
s_pg.put("\\bSYSDATE\\b", "CURRENT_TIMESTAMP"); // alternative: NOW()
68
s_pg.put("\\bNVL\\b", "COALESCE");
69         s_pg.put("\\bTO_DATE\\b", "TO_TIMESTAMP");
70         //
71
s_pg.put("\\bDBMS_OUTPUT.PUT_LINE\\b", "RAISE NOTICE");
72
73         // Temporary
74
s_pg.put("\\bGLOBAL TEMPORARY\\b", "TEMPORARY");
75         s_pg.put("\\bON COMMIT DELETE ROWS\\b", "");
76         s_pg.put("\\bON COMMIT PRESERVE ROWS\\b", "");
77
78
79         // DROP TABLE x CASCADE CONSTRAINTS
80
s_pg.put("\\bCASCADE CONSTRAINTS\\b", "");
81
82         // Select
83
s_pg.put("\\sFROM\\s+DUAL\\b", "");
84
85         // Statements
86
s_pg.put("\\bELSIF\\b", "ELSE IF");
87
88         // Sequences
89
s_pg.put("\\bSTART WITH\\b", "START");
90         s_pg.put("\\bINCREMENT BY\\b", "INCREMENT");
91
92     } // static initializer
93

94 } // ConvertMap
95
Popular Tags