Source Code Cross Referenced for JRCustomConnection.java in  » Report » iReport-2.0.5 » it » businesslogic » ireport » connection » 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 » Report » iReport 2.0.5 » it.businesslogic.ireport.connection 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2005 - 2008 JasperSoft Corporation.  All rights reserved. 
003:         * http://www.jaspersoft.com.
004:         *
005:         * Unless you have purchased a commercial license agreement from JasperSoft,
006:         * the following license terms apply:
007:         *
008:         * This program is free software; you can redistribute it and/or modify
009:         * it under the terms of the GNU General Public License version 2 as published by
010:         * the Free Software Foundation.
011:         *
012:         * This program is distributed WITHOUT ANY WARRANTY; and without the
013:         * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
014:         * See the GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
018:         * or write to:
019:         *
020:         * Free Software Foundation, Inc.,
021:         * 59 Temple Place - Suite 330,
022:         * Boston, MA  USA  02111-1307
023:         *
024:         *
025:         *
026:         *
027:         * JRCustomDataSourceConnection.java
028:         * 
029:         * Created on 4 giugno 2003, 18.15
030:         *
031:         */
032:
033:        package it.businesslogic.ireport.connection;
034:
035:        import it.businesslogic.ireport.*;
036:        import it.businesslogic.ireport.gui.MainFrame;
037:        import it.businesslogic.ireport.util.I18n;
038:        import java.util.HashMap;
039:        import java.util.Iterator;
040:
041:        /**
042:         *
043:         * @author  Administrator
044:         */
045:        public class JRCustomConnection extends
046:                it.businesslogic.ireport.IReportConnection {
047:
048:            public static final String CLASSNAME_PROPERTY = "iReportConnectionClassName";
049:            public static final String PROPERTY_PREFIX = "prop_";
050:
051:            /**
052:             * The map to store the static connection parameters
053:             */
054:            private java.util.HashMap innerConnectionProperties = new java.util.HashMap();
055:            private IReportConnection innerConnection = null;
056:            private String iReportConnectionClassName = null;
057:
058:            /** Creates a new instance of JDBCConnection */
059:
060:            public JRCustomConnection() {
061:            }
062:
063:            /**  This method return an instanced connection to the database.
064:             *  If isJDBCConnection() return false => getConnection() return null
065:             *
066:             */
067:            public java.sql.Connection getConnection() {
068:                if (getInnerConnection() == null)
069:                    return super .getConnection();
070:                return getInnerConnection().getConnection();
071:            }
072:
073:            public boolean isJDBCConnection() {
074:                if (getInnerConnection() == null)
075:                    return super .isJDBCConnection();
076:                return getInnerConnection().isJDBCConnection();
077:            }
078:
079:            /*
080:             *  This method return all properties used by this connection
081:             */
082:            public java.util.HashMap getProperties() {
083:                HashMap map = new HashMap();
084:                HashMap map2 = getInnerConnectionProperties();
085:                Iterator iterator = map2.keySet().iterator();
086:                while (iterator.hasNext()) {
087:                    Object key = iterator.next();
088:                    map.put(PROPERTY_PREFIX + key, map2.get(key));
089:                }
090:
091:                if (getIReportConnectionClassName() != null) {
092:                    map
093:                            .put(CLASSNAME_PROPERTY,
094:                                    getIReportConnectionClassName());
095:                }
096:                return map;
097:            }
098:
099:            public void loadProperties(java.util.HashMap map) {
100:                HashMap map2 = new HashMap();
101:                Iterator iterator = map.keySet().iterator();
102:                while (iterator.hasNext()) {
103:                    String key = "" + iterator.next();
104:                    Object value = map.get(key);
105:
106:                    if (key.startsWith(PROPERTY_PREFIX)) {
107:                        map2
108:                                .put(key.substring(PROPERTY_PREFIX.length()),
109:                                        value);
110:                    } else if (key.equals(CLASSNAME_PROPERTY)) {
111:                        this .setIReportConnectionClassName(""
112:                                + map.get(CLASSNAME_PROPERTY));
113:                    }
114:                }
115:
116:                setInnerConnectionProperties(map2);
117:                setInnerConnection(null);
118:            }
119:
120:            /**
121:             *  This method return an instanced JRDataDource to the database.
122:             *  If isJDBCConnection() return true => getJRDataSource() return false
123:             */
124:            public net.sf.jasperreports.engine.JRDataSource getJRDataSource() {
125:                if (getInnerConnection() == null)
126:                    return super .getJRDataSource();
127:                return getInnerConnection().getJRDataSource();
128:            }
129:
130:            public java.util.Map getSpecialParameters(java.util.Map map)
131:                    throws net.sf.jasperreports.engine.JRException {
132:
133:                if (getInnerConnection() == null)
134:                    return super .getSpecialParameters(map);
135:                return getInnerConnection().getSpecialParameters(map);
136:            }
137:
138:            public java.util.Map disposeSpecialParameters(java.util.Map map) {
139:
140:                if (getInnerConnection() == null)
141:                    return super .disposeSpecialParameters(map);
142:                return getInnerConnection().disposeSpecialParameters(map);
143:            }
144:
145:            public boolean isJRDataSource() {
146:
147:                if (getInnerConnection() == null)
148:                    return super .isJRDataSource();
149:                return getInnerConnection().isJRDataSource();
150:            }
151:
152:            public String getIReportConnectionClassName() {
153:                return iReportConnectionClassName;
154:            }
155:
156:            public void setIReportConnectionClassName(
157:                    String iReportConnectionClassName) {
158:                this .iReportConnectionClassName = iReportConnectionClassName;
159:            }
160:
161:            public IReportConnection getInnerConnection() {
162:
163:                if (innerConnection == null) {
164:                    try {
165:
166:                        innerConnection = (IReportConnection) Class.forName(
167:                                getIReportConnectionClassName(),
168:                                true,
169:                                MainFrame.getMainInstance()
170:                                        .getReportClassLoader()).newInstance();
171:                        innerConnection
172:                                .loadProperties(getInnerConnectionProperties());
173:
174:                    } catch (Throwable ex) {
175:                        ex.printStackTrace();
176:                    }
177:                }
178:
179:                return innerConnection;
180:            }
181:
182:            public void setInnerConnection(IReportConnection innerConnection) {
183:                this .innerConnection = innerConnection;
184:            }
185:
186:            public java.util.HashMap getInnerConnectionProperties() {
187:                return innerConnectionProperties;
188:            }
189:
190:            public void setInnerConnectionProperties(
191:                    java.util.HashMap innerConnectionProperties) {
192:                this .innerConnectionProperties = innerConnectionProperties;
193:            }
194:
195:            public void test() throws Exception {
196:                IReportConnection testConnection = (IReportConnection) Class
197:                        .forName(
198:                                getIReportConnectionClassName(),
199:                                true,
200:                                MainFrame.getMainInstance()
201:                                        .getReportClassLoader()).newInstance();
202:                if (testConnection != null) {
203:                    testConnection
204:                            .loadProperties(getInnerConnectionProperties());
205:                    testConnection.test();
206:                }
207:            }
208:
209:            public String getDescription() {
210:                return I18n.getString("connectionType.customIReportConnection",
211:                        "Custom iReport connection");
212:            }
213:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.