Source Code Cross Referenced for I18nDriver.java in  » Database-JDBC-Connection-Pool » octopus » org » webdocwf » util » i18njdbc » 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 » Database JDBC Connection Pool » octopus » org.webdocwf.util.i18njdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:            Copyright (C) 2002-2003  Together
003:
004:            This library is free software; you can redistribute it and/or
005:            modify it under the terms of the GNU Lesser General Public
006:            License as published by the Free Software Foundation; either
007:            version 2.1 of the License, or (at your option) any later version.
008:
009:            This library is distributed in the hope that it will be useful,
010:            but WITHOUT ANY WARRANTY; without even the implied warranty of
011:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:            Lesser General Public License for more details.
013:
014:            You should have received a copy of the GNU Lesser General Public
015:            License along with this library; if not, write to the Free Software
016:            Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:
018:         */package org.webdocwf.util.i18njdbc;
019:
020:        import java.sql.*;
021:        import java.util.Properties;
022:        import java.util.StringTokenizer;
023:        import java.io.File;
024:
025:        /**
026:         * This class implements the Driver interface for the I18nJdbc driver.
027:         *
028:         * @author     Zoran Milakovic
029:         * @author		 Zeljko Kovacevic
030:         */
031:
032:        public class I18nDriver implements  Driver {
033:
034:            //PARAMETER NAMES
035:
036:            //ZK added properties for i18nJdbc driver
037:            public static final String CHARSET = "charset";
038:            public static final String NAMECOLUMN = "nameColumn";
039:            public static final String VALUECOLUMN = "valueColumn";
040:            public static final String CREATE = "create";
041:            public static final String FILE_EXTENSION = "fileExtension";
042:            //DEFAULT VALUES
043:
044:            //ZK added this
045:            public static final String DEFAULT_CHARSET = "UTF-8";
046:            public static final String DEFAULT_NAMECOLUMN = "name";
047:            public static final String DEFAULT_VALUECOLUMN = "value";
048:            public static final boolean DEFAULT_CREATE = false;
049:            public static final String DEFAULT_EXTENSION = ".properties";
050:            //data types
051:
052:            public static final String VARCHAR_TYPE = "VARCHAR";
053:            public static String FILE_NAME_EXT = "extension";
054:            private final static String URL_PREFIX = "jdbc:webdocwf:i18n:";
055:            private Properties info = null;
056:
057:            /* If set to true, driver will log into i18ndriver.log file, in working directory */
058:            private static boolean ENABLE_LOG = false;
059:
060:            /* If set to true, driver will show stack traces and other debug info */
061:            public static boolean DEBUG = false;
062:
063:            /**
064:             *Gets the propertyInfo attribute of the I18nJdbc object
065:             *
066:             * @param  url               Description of Parameter
067:             * @param  info              Description of Parameter
068:             * @return                   The propertyInfo value
069:             * @exception  SQLException  Description of Exception
070:             * @since
071:             */
072:            public DriverPropertyInfo[] getPropertyInfo(String url,
073:                    Properties info) throws SQLException {
074:                return new DriverPropertyInfo[0];
075:            }
076:
077:            /**
078:             *Gets the majorVersion attribute of the I18nJdbc object
079:             *
080:             * @return    The majorVersion value
081:             * @since
082:             */
083:            public int getMajorVersion() {
084:                return 1;
085:            }
086:
087:            /**
088:             *Gets the minorVersion attribute of the I18nJdbc object
089:             *
090:             * @return    The minorVersion value
091:             * @since
092:             */
093:            public int getMinorVersion() {
094:                return 0;
095:            }
096:
097:            /**
098:             *Description of the Method
099:             *
100:             * @param  url               Description of Parameter
101:             * @param  info              Description of Parameter
102:             * @return                   Description of the Returned Value
103:             * @exception  SQLException  Description of Exception
104:             * @since
105:             */
106:            public Connection connect(String url, Properties info)
107:                    throws SQLException {
108:                DriverManager.println("i18nJdbc - I18nDriver:connect() - url="
109:                        + url);
110:                // check for correct url
111:                if (!url.startsWith(URL_PREFIX)) {
112:                    return null;
113:                }
114:                // get filepath from url
115:                String filePath = url.substring(URL_PREFIX.length());
116:                String filePathAll = filePath;
117:                StringTokenizer st = new StringTokenizer(filePath, ";");
118:
119:                //System.out.println("filePathAll="+filePathAll);
120:
121:                filePath = st.nextToken();
122:                if (!filePath.endsWith(File.separator)) {
123:                    filePath += File.separator;
124:                }
125:                DriverManager
126:                        .println("i18nJdbc - i18nDriver:connect() - filePath="
127:                                + filePath);
128:                return new I18nConnection(filePathAll, info);
129:            }
130:
131:            /**
132:             * Description of the Method
133:             *
134:             * @param  url               Description of Parameter
135:             * @return                   Description of the Returned Value
136:             * @exception  SQLException  Description of Exception
137:             * @since
138:             */
139:            public boolean acceptsURL(String url) throws SQLException {
140:                DriverManager.println("I18nJdbc - I18nDriver:accept() - url="
141:                        + url);
142:                return url.startsWith(URL_PREFIX);
143:            }
144:
145:            /**
146:             *Description of the Method
147:             *
148:             * @return    Description of the Returned Value
149:             * @since
150:             */
151:            public boolean jdbcCompliant() {
152:                return false;
153:            }
154:
155:            // This static block inits the driver when the class is loaded by the JVM.
156:            static {
157:                try {
158:                    java.sql.DriverManager.registerDriver(new I18nDriver());
159:                } catch (SQLException e) {
160:                    throw new RuntimeException(
161:                            "FATAL ERROR: Could not initialise i18n driver ! Message was: "
162:                                    + e.getMessage());
163:                }
164:            }
165:
166:            public static void log(String message) {
167:                if (I18nDriver.ENABLE_LOG) {
168:                    try {
169:                        File file = new File("i18ndriver.log");
170:                        if (!file.exists())
171:                            file.createNewFile();
172:                        java.io.RandomAccessFile fileLogr = new java.io.RandomAccessFile(
173:                                file, "rw");
174:                        fileLogr.seek(fileLogr.length());
175:                        fileLogr.writeBytes("I18nJdbc, " + message + "\r\n");
176:                        fileLogr.close();
177:                    } catch (Exception ex) {
178:                        ex.printStackTrace();
179:                    }
180:                }
181:            }
182:
183:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.