Source Code Cross Referenced for ArrayGeOxygene2Oracle.java in  » GIS » GeOxygene-1.3 » fr » ign » cogit » geoxygene » datatools » oracle » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » GIS » GeOxygene 1.3 » fr.ign.cogit.geoxygene.datatools.oracle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the GeOxygene project source files. 
003:         * 
004:         * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for 
005:         * the development and deployment of geographic (GIS) applications. It is a open source 
006:         * contribution of the COGIT laboratory at the Institut Géographique National (the French 
007:         * National Mapping Agency).
008:         * 
009:         * See: http://oxygene-project.sourceforge.net 
010:         *  
011:         * Copyright (C) 2005 Institut Géographique National
012:         *
013:         * This library is free software; you can redistribute it and/or modify it under the terms
014:         * of the GNU Lesser General Public License as published by the Free Software Foundation; 
015:         * either version 2.1 of the License, or any later version.
016:         *
017:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
018:         * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
019:         * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020:         *
021:         * You should have received a copy of the GNU Lesser General Public License along with 
022:         * this library (see file LICENSE if present); if not, write to the Free Software 
023:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:         *  
025:         */
026:
027:        package fr.ign.cogit.geoxygene.datatools.oracle;
028:
029:        import java.math.BigDecimal;
030:        import java.sql.Connection;
031:
032:        import oracle.jdbc.driver.OracleConnection;
033:        import oracle.sql.ARRAY;
034:        import oracle.sql.ArrayDescriptor;
035:
036:        import org.apache.ojb.broker.accesslayer.conversions.FieldConversion;
037:        import org.apache.ojb.broker.util.batch.BatchConnection;
038:
039:        /**
040:         * Routine de conversion des tableaux java en VARRAY Oracle.
041:         * On impose le nom du tableau dans Oracle.
042:         * double[] -> "VARRAY_OF_DOUBLE".
043:         * int[] -> "VARRAY_OF_INTEGER".
044:         * boolean[] -> "VARRAY_OF_BOOLEAN" (défini comme un varray de CHAR(1))
045:         * string[] -> "VARRAY_OF_STRING" 
046:         * 
047:         * @author Thierry Badard & Arnaud Braun
048:         * @version 1.1  
049:         * 
050:         */
051:
052:        /* Remarque : on pourrait coder comme GeomGeOxygene2Oracle avec la connection definie statique
053:         * et initialisee a la construction de GeodatabaseOjbOracle.
054:         */
055:
056:        public class ArrayGeOxygene2Oracle implements  FieldConversion {
057:
058:            // nom des types Oracle 
059:            public static String typeArrayDouble = "VARRAY_OF_DOUBLE";
060:            public static String typeArrayInt = "VARRAY_OF_INTEGER";
061:            public static String typeArrayBoolean = "VARRAY_OF_BOOLEAN";
062:            public static String typeArrayString = "VARRAY_OF_STRING";
063:
064:            public Object sqlToJava(Object object) {
065:                try {
066:                    Object array = ((ARRAY) object).getArray();
067:                    String type = ((ARRAY) object).getDescriptor().descType();
068:                    if (type.startsWith(typeArrayDouble)) {
069:                        BigDecimal[] bigdecimals = (BigDecimal[]) array;
070:                        int n = bigdecimals.length;
071:                        double[] doubles = new double[n];
072:                        for (int i = 0; i < n; i++)
073:                            doubles[i] = bigdecimals[i].doubleValue();
074:                        return doubles;
075:                    } else if (type.startsWith(typeArrayInt)) {
076:                        BigDecimal[] bigdecimals = (BigDecimal[]) array;
077:                        int n = bigdecimals.length;
078:                        int[] ints = new int[n];
079:                        for (int i = 0; i < n; i++)
080:                            ints[i] = bigdecimals[i].intValue();
081:                        return ints;
082:                    } else if (type.startsWith(typeArrayBoolean)) {
083:                        String[] strings = (String[]) array;
084:                        int n = strings.length;
085:                        boolean[] bools = new boolean[n];
086:                        for (int i = 0; i < n; i++) {
087:                            String value = strings[i];
088:                            boolean bool = false;
089:                            if (value.compareToIgnoreCase("0") == 0)
090:                                bool = false;
091:                            else if (value.compareToIgnoreCase("1") == 0)
092:                                bool = true;
093:                            else
094:                                System.out
095:                                        .println("## PROBLEME VARRAY_OF_BOOLEAN -> ARRAY ##");
096:                            bools[i] = bool;
097:                        }
098:                        return bools;
099:                    } else if (type.startsWith(typeArrayString)) {
100:                        String[] strings = (String[]) array;
101:                        return strings;
102:                    } else {
103:                        System.out.println("## PROBLEME VARRAY -> ARRAY ##");
104:                        return null;
105:                    }
106:                } catch (Exception e1) {
107:                    e1.printStackTrace();
108:                    return null;
109:                }
110:            }
111:
112:            public Object javaToSql(Object object, Connection conn) {
113:                String param = null;
114:                Object objectToConvert = null;
115:                ;
116:                if (object instanceof  double[]) {
117:                    param = typeArrayDouble;
118:                    objectToConvert = object;
119:                } else if (object instanceof  int[]) {
120:                    param = typeArrayInt;
121:                    objectToConvert = object;
122:                } else if (object instanceof  boolean[]) {
123:                    param = typeArrayBoolean;
124:                    boolean[] bools = (boolean[]) object;
125:                    String[] chars = new String[bools.length];
126:                    for (int i = 0; i < bools.length; i++)
127:                        if (bools[i] == true)
128:                            chars[i] = "1";
129:                        else
130:                            chars[i] = "0";
131:                    objectToConvert = chars;
132:                } else if (object instanceof  String[]) {
133:                    param = typeArrayString;
134:                    objectToConvert = object;
135:                } else
136:                    System.out
137:                            .println("## ARRAY EN VARRAY : CAS NON TRAITE ##");
138:                try {
139:                    ArrayDescriptor arraydesc;
140:                    ARRAY array;
141:                    if (conn instanceof  BatchConnection) {
142:                        OracleConnection oConn = (OracleConnection) ((BatchConnection) conn)
143:                                .getDelegate();
144:                        arraydesc = ArrayDescriptor.createDescriptor(param,
145:                                oConn);
146:                        array = new ARRAY(arraydesc, oConn, objectToConvert);
147:                    } else {
148:                        arraydesc = ArrayDescriptor.createDescriptor(param,
149:                                conn);
150:                        array = new ARRAY(arraydesc, conn, objectToConvert);
151:                    }
152:                    return array;
153:                } catch (Exception e) {
154:                    e.printStackTrace();
155:                    return null;
156:                }
157:            }
158:
159:            public Object javaToSql(Object arg0) {
160:                System.out
161:                        .println("[#### [ERREUR GeOxygene] L'IMPOSSIBLE EST ARRIVE !! ##### ");
162:                System.out
163:                        .println("Probleme de conversion GeOxygene -> Oracle");
164:                return null;
165:            }
166:
167:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.