Source Code Cross Referenced for FlatfileDBConnectionDefinitionImpl.java in  » IDE-Netbeans » etl.project » org » netbeans » modules » mashup » db » model » impl » 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 » IDE Netbeans » etl.project » org.netbeans.modules.mashup.db.model.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.mashup.db.model.impl;
042:
043:        import com.sun.sql.framework.jdbc.DBConnectionParameters;
044:        import java.util.Map;
045:        import org.netbeans.modules.mashup.db.model.FlatfileDBConnectionDefinition;
046:
047:        import org.netbeans.modules.sql.framework.common.utils.TagParserUtility;
048:        import org.netbeans.modules.sql.framework.model.DBConnectionDefinition;
049:        import org.w3c.dom.Element;
050:
051:        /**
052:         * Implements FlatfileDBConnectionDefinition interface for Flatfile.
053:         * 
054:         * @author Jonathan Giron
055:         * @author Girish Patil
056:         * @version $Revision$
057:         */
058:        public class FlatfileDBConnectionDefinitionImpl extends
059:                DBConnectionParameters implements 
060:                FlatfileDBConnectionDefinition {
061:            /** Constants used in XML tags * */
062:            private static final String ATTR_DRIVER_CLASS = "driverClass";
063:            private static final String ATTR_NAME = "name";
064:            private static final String ATTR_PASSWORD = "password";
065:            private static final String ATTR_URL = "url";
066:            private static final String ATTR_USER_NAME = "userName";
067:            private static final String END_QUOTE_SPACE = "\" ";
068:            private static final String EQUAL_START_QUOTE = "=\"";
069:            private static final String TAG_CONNECTION_DEFINITION = "connectionDefinition";
070:
071:            /* JDBC driver class name for Axion */
072:            private static final String AXION_DRIVER = "org.axiondb.jdbc.AxionDriver";
073:
074:            /* JDBC URL */
075:            private String url;
076:
077:            /** Creates a new default instance of FlatfileDBConnectionDefinitionImpl. */
078:            public FlatfileDBConnectionDefinitionImpl() {
079:                userName = "sa";
080:                password = "sa";
081:                driverClass = AXION_DRIVER;
082:            }
083:
084:            /** Creates a new default instance of FlatfileDBConnectionDefinitionImpl. */
085:            public FlatfileDBConnectionDefinitionImpl(String connName) {
086:                name = connName;
087:                userName = "sa";
088:                password = "sa";
089:                driverClass = AXION_DRIVER;
090:                description = connName;
091:            }
092:
093:            /**
094:             * Creates a new instance of FlatfileDBConnectionDefinitionImpl with the given
095:             * attributes.
096:             * 
097:             * @param connName connection name
098:             * @param driverName driver name
099:             * @param connUrl JDBC URL for this connection
100:             * @param uname username used to establish connection
101:             * @param passwd password used to establish connection
102:             * @param desc description of connection
103:             */
104:            public FlatfileDBConnectionDefinitionImpl(String connName,
105:                    String driverName, String connUrl, String uname,
106:                    String passwd, String desc) {
107:                name = connName;
108:
109:                driverClass = driverName;
110:                url = connUrl;
111:                userName = uname;
112:                password = passwd;
113:                description = desc;
114:            }
115:
116:            /**
117:             * Creates a new instance of FlatfileDBConnectionDefinitionImpl using the values in
118:             * the given FlatfileDBConnectionDefinition.
119:             * 
120:             * @param connectionDefn DBConnectionDefinition to be copied
121:             */
122:            public FlatfileDBConnectionDefinitionImpl(
123:                    DBConnectionDefinition connectionDefn) {
124:                if (connectionDefn == null) {
125:                    throw new IllegalArgumentException(
126:                            "Must supply non-null DBConnectionDefinition instance for connectionDefn param.");
127:                }
128:
129:                if (connectionDefn instanceof  FlatfileDBConnectionDefinitionImpl) {
130:                    copyFrom((FlatfileDBConnectionDefinitionImpl) connectionDefn);
131:                }
132:            }
133:
134:            /**
135:             * @see org.netbeans.modules.model.database.DBConnectionDefinition#getConnectionURL()
136:             */
137:            @Override
138:            public String getConnectionURL() {
139:                return url;
140:            }
141:
142:            @Override
143:            public void setConnectionURL(String aUrl) {
144:                url = aUrl;
145:            }
146:
147:            public String getUrl() {
148:                return this .url;
149:            }
150:
151:            /**
152:             * @see org.netbeans.modules.model.database.DBConnectionDefinition#getDBType
153:             */
154:            @Override
155:            public String getDBType() {
156:                return "Internal";
157:            }
158:
159:            /**
160:             * Copies member values to those contained in the given DBConnectionDefinition
161:             * instance. Does shallow copy of properties and flatfile collections.
162:             * 
163:             * @param source DBConnectionDefinition whose contents are to be copied into this
164:             *        instance
165:             */
166:            public synchronized void copyFrom(DBConnectionDefinition source) {
167:                if (source == null) {
168:                    throw new IllegalArgumentException(
169:                            "Must supply non-null ref for source.");
170:                } else if (source == this ) {
171:                    return;
172:                }
173:
174:                this .description = source.getDescription();
175:                this .name = source.getName();
176:                this .driverClass = source.getDriverClass();
177:                this .url = source.getConnectionURL();
178:                this .userName = source.getUserName();
179:                this .password = source.getPassword();
180:            }
181:
182:            /**
183:             * Overrides default implementation.
184:             * 
185:             * @param o Object to compare for equality against this instance.
186:             * @return true if o is equivalent to this, false otherwise
187:             */
188:            @Override
189:            public boolean equals(Object o) {
190:                // Check for reflexivity.
191:                if (this  == o) {
192:                    return true;
193:                } else if (!(o instanceof  FlatfileDBConnectionDefinitionImpl)) {
194:                    return false;
195:                }
196:
197:                boolean response = true;
198:                FlatfileDBConnectionDefinitionImpl impl = (FlatfileDBConnectionDefinitionImpl) o;
199:
200:                boolean nameEqual = (name != null) ? name.equals(impl.name)
201:                        : (impl.name == null);
202:                response &= nameEqual;
203:
204:                boolean driverClassEqual = (driverClass != null) ? driverClass
205:                        .equals(impl.driverClass) : (impl.driverClass == null);
206:                response &= driverClassEqual;
207:
208:                boolean urlEqual = (url != null) ? url.equals(impl.url)
209:                        : (impl.url == null);
210:                response &= urlEqual;
211:
212:                boolean userNameEqual = (userName != null) ? userName
213:                        .equals(impl.userName) : (impl.userName == null);
214:                response &= userNameEqual;
215:
216:                boolean passwordEqual = (password != null) ? password
217:                        .equals(impl.password) : (impl.password == null);
218:                response &= passwordEqual;
219:
220:                boolean descEqual = (description != null) ? description
221:                        .equals(impl.description) : (impl.description == null);
222:                response &= descEqual;
223:
224:                return response;
225:            }
226:
227:            /**
228:             * Overrides default implementation to compute its value based on member variables.
229:             * 
230:             * @return computed hash code
231:             */
232:            @Override
233:            public int hashCode() {
234:                int hashCode = 0;
235:
236:                hashCode += (name != null) ? name.hashCode() : 0;
237:                hashCode += (driverClass != null) ? driverClass.hashCode() : 0;
238:                hashCode += (url != null) ? url.hashCode() : 0;
239:                hashCode += (userName != null) ? userName.hashCode() : 0;
240:                hashCode += (password != null) ? password.hashCode() : 0;
241:                hashCode += (description != null) ? description.hashCode() : 0;
242:
243:                return hashCode;
244:            }
245:
246:            @Override
247:            public void parseXML(Element xmlElement) {
248:                Map attrs = TagParserUtility.getNodeAttributes(xmlElement);
249:
250:                this .name = (String) attrs.get(ATTR_NAME);
251:                this .driverClass = (String) attrs.get(ATTR_DRIVER_CLASS);
252:                this .url = (String) attrs.get(ATTR_URL);
253:                this .userName = (String) attrs.get(ATTR_USER_NAME);
254:                this .password = (String) attrs.get(ATTR_PASSWORD);
255:            }
256:
257:            @Override
258:            public String toXMLString(String prefix) {
259:                StringBuilder sb = new StringBuilder();
260:                sb.append(prefix);
261:                sb.append("<");
262:                sb.append(TAG_CONNECTION_DEFINITION);
263:                sb.append(" ");
264:                sb.append(ATTR_NAME);
265:                sb.append(EQUAL_START_QUOTE);
266:                sb.append(this .getName());
267:                sb.append(END_QUOTE_SPACE);
268:                sb.append(ATTR_DRIVER_CLASS);
269:                sb.append(EQUAL_START_QUOTE);
270:                sb.append(this .getDriverClass());
271:                sb.append(END_QUOTE_SPACE);
272:                sb.append(ATTR_URL);
273:                sb.append(EQUAL_START_QUOTE);
274:                sb.append(this .getUrl());
275:                sb.append(END_QUOTE_SPACE);
276:                sb.append(ATTR_USER_NAME);
277:                sb.append(EQUAL_START_QUOTE);
278:                sb.append(this .getUserName());
279:                sb.append(END_QUOTE_SPACE);
280:                sb.append(ATTR_PASSWORD);
281:                sb.append(EQUAL_START_QUOTE);
282:                sb.append(this .getPassword());
283:                sb.append("\"/>\n");
284:                return sb.toString();
285:            }
286:        }
ww_w._j__a_va__2s__.__c_o___m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.