Source Code Cross Referenced for SQLDriver.java in  » Database-Client » squirrel-sql-2.6.5a » net » sourceforge » squirrel_sql » fw » sql » 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 Client » squirrel sql 2.6.5a » net.sourceforge.squirrel_sql.fw.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sourceforge.squirrel_sql.fw.sql;
002:
003:        /*
004:         * Copyright (C) 2001-2002 Colin Bell
005:         * colbell@users.sourceforge.net
006:         *
007:         * This library is free software; you can redistribute it and/or
008:         * modify it under the terms of the GNU Lesser General Public
009:         * License as published by the Free Software Foundation; either
010:         * version 2.1 of the License, or (at your option) any later version.
011:         *
012:         * This library is distributed in the hope that it will be useful,
013:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
015:         * Lesser General Public License for more details.
016:         *
017:         * You should have received a copy of the GNU Lesser General Public
018:         * License along with this library; if not, write to the Free Software
019:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
020:         */
021:        import java.beans.PropertyChangeListener;
022:        import java.io.Serializable;
023:        import java.util.ArrayList;
024:        import java.util.List;
025:
026:        import net.sourceforge.squirrel_sql.fw.id.IIdentifier;
027:        import net.sourceforge.squirrel_sql.fw.persist.ValidationException;
028:        import net.sourceforge.squirrel_sql.fw.util.PropertyChangeReporter;
029:        import net.sourceforge.squirrel_sql.fw.util.StringManager;
030:        import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
031:        import net.sourceforge.squirrel_sql.fw.util.beanwrapper.StringWrapper;
032:
033:        /**
034:         * This represents a JDBC driver.
035:         * This class is a <CODE>JavaBean</CODE>.
036:         *
037:         * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
038:         */
039:        public class SQLDriver implements  ISQLDriver, Cloneable, Serializable {
040:            static final long serialVersionUID = 8506401259069527981L;
041:
042:            /** Internationalized strings for this class. */
043:            private static final StringManager s_stringMgr = StringManagerFactory
044:                    .getStringManager(SQLDriver.class);
045:
046:            private interface IStrings {
047:                String ERR_BLANK_NAME = s_stringMgr
048:                        .getString("SQLDriver.error.blankname");
049:                String ERR_BLANK_DRIVER = s_stringMgr
050:                        .getString("SQLDriver.error.blankdriver");
051:                String ERR_BLANK_URL = s_stringMgr
052:                        .getString("SQLDriver.error.blankurl");
053:            }
054:
055:            /** The <CODE>IIdentifier</CODE> that uniquely identifies this object. */
056:            private IIdentifier _id;
057:
058:            /** The name of this driver. */
059:            private String _name;
060:
061:            /**
062:             * File name associated with <CODE>_jarFileURL</CODE>.
063:             */
064:            private String _jarFileName = null;
065:
066:            /** Names for driver jar files. */
067:            private List<String> _jarFileNamesList = new ArrayList<String>();
068:
069:            /** The class name of the JDBC driver. */
070:            private String _driverClassName;
071:
072:            /** Default URL required to access the database. */
073:            private String _url;
074:
075:            /** Is the JDBC driver class for this object loaded? */
076:            private boolean _jdbcDriverClassLoaded;
077:
078:            /** Object to handle property change events. */
079:            private transient PropertyChangeReporter _propChgReporter;
080:
081:            /** Default Website URL for more info about the JDBC driver */
082:            private String _websiteUrl;
083:
084:            /**
085:             * Ctor specifying the identifier.
086:             *
087:             * @param	id	Uniquely identifies this object.
088:             */
089:            public SQLDriver(IIdentifier id) {
090:                super ();
091:                _id = id;
092:                _name = "";
093:                _jarFileName = null;
094:                _driverClassName = null;
095:                _url = "";
096:                _websiteUrl = "";
097:            }
098:
099:            /**
100:             * Default ctor.
101:             */
102:            public SQLDriver() {
103:                super ();
104:            }
105:
106:            /**
107:             * Assign data from the passed <CODE>ISQLDriver</CODE> to this one. This
108:             * does <B>not</B> copy the identifier.
109:             *
110:             * @param	rhs	 <CODE>ISQLDriver</CODE> to copy data from.
111:             *
112:             * @exception	ValidationException
113:             *				Thrown if an error occurs assigning data from
114:             *				<CODE>rhs</CODE>.
115:             */
116:            public synchronized void assignFrom(ISQLDriver rhs)
117:                    throws ValidationException {
118:                setName(rhs.getName());
119:                setJarFileNames(rhs.getJarFileNames());
120:                setDriverClassName(rhs.getDriverClassName());
121:                setUrl(rhs.getUrl());
122:                setJDBCDriverClassLoaded(rhs.isJDBCDriverClassLoaded());
123:                setWebSiteUrl(rhs.getWebSiteUrl());
124:            }
125:
126:            /**
127:             * Returns <TT>true</TT> if this objects is equal to the passed one. Two
128:             * <TT>ISQLDriver</TT> objects are considered equal if they have the same
129:             * identifier.
130:             */
131:            public boolean equals(Object rhs) {
132:                boolean rc = false;
133:                if (rhs != null && rhs.getClass().equals(getClass())) {
134:                    rc = ((ISQLDriver) rhs).getIdentifier().equals(
135:                            getIdentifier());
136:                }
137:                return rc;
138:            }
139:
140:            /**
141:             * Returns a hash code value for this object.
142:             */
143:            public synchronized int hashCode() {
144:                return getIdentifier().hashCode();
145:            }
146:
147:            /**
148:             * Returns the name of this <TT>ISQLDriver</TT>.
149:             */
150:            public String toString() {
151:                return getName();
152:            }
153:
154:            /**
155:             * Return a clone of this object.
156:             */
157:            public Object clone() {
158:                try {
159:                    final SQLDriver driver = (SQLDriver) super .clone();
160:                    driver._propChgReporter = null;
161:                    return driver;
162:                } catch (CloneNotSupportedException ex) {
163:                    throw new InternalError(ex.getMessage()); // Impossible.
164:                }
165:            }
166:
167:            /**
168:             * Compare this <TT>ISQLDriver</TT> to another <TT>ISQLDriver</TT>.  The 
169:             * <TT>getName()</TT> functions of the two <TT>ISQLDriver</TT> objects are 
170:             * used to compare them. 
171:             */
172:            public int compareTo(ISQLDriver rhs) {
173:                return _name.compareTo(rhs.getName());
174:            }
175:
176:            public void addPropertyChangeListener(
177:                    PropertyChangeListener listener) {
178:                getPropertyChangeReporter().addPropertyChangeListener(listener);
179:            }
180:
181:            public void removePropertyChangeListener(
182:                    PropertyChangeListener listener) {
183:                getPropertyChangeReporter().removePropertyChangeListener(
184:                        listener);
185:            }
186:
187:            public void setReportPropertyChanges(boolean report) {
188:                getPropertyChangeReporter().setNotify(report);
189:            }
190:
191:            public IIdentifier getIdentifier() {
192:                return _id;
193:            }
194:
195:            public void setIdentifier(IIdentifier id) {
196:                _id = id;
197:            }
198:
199:            public String getDriverClassName() {
200:                return _driverClassName;
201:            }
202:
203:            public void setDriverClassName(String driverClassName)
204:                    throws ValidationException {
205:                String data = getString(driverClassName);
206:                if (data.length() == 0) {
207:                    throw new ValidationException(IStrings.ERR_BLANK_DRIVER);
208:                }
209:                if (!data.equals(_driverClassName)) {
210:                    final String oldValue = _driverClassName;
211:                    _driverClassName = data;
212:                    getPropertyChangeReporter().firePropertyChange(
213:                            ISQLDriver.IPropertyNames.DRIVER_CLASS, oldValue,
214:                            _driverClassName);
215:                }
216:            }
217:
218:            /**
219:             * @deprecated	Replaced by getJarFileNames().
220:             */
221:            public String getJarFileName() {
222:                return _jarFileName;
223:            }
224:
225:            public void setJarFileName(String value) {
226:                if (value == null) {
227:                    value = "";
228:                }
229:                if (_jarFileName == null || !_jarFileName.equals(value)) {
230:                    final String oldValue = _jarFileName;
231:                    _jarFileName = value;
232:                    getPropertyChangeReporter().firePropertyChange(
233:                            ISQLDriver.IPropertyNames.JARFILE_NAME, oldValue,
234:                            _jarFileName);
235:                }
236:            }
237:
238:            public synchronized String[] getJarFileNames() {
239:                return _jarFileNamesList.toArray(new String[_jarFileNamesList
240:                        .size()]);
241:            }
242:
243:            public synchronized void setJarFileNames(String[] values) {
244:                String[] oldValue = _jarFileNamesList
245:                        .toArray(new String[_jarFileNamesList.size()]);
246:                _jarFileNamesList.clear();
247:
248:                if (values == null) {
249:                    values = new String[0];
250:                }
251:
252:                for (int i = 0; i < values.length; ++i) {
253:                    _jarFileNamesList.add(values[i]);
254:                }
255:
256:                getPropertyChangeReporter().firePropertyChange(
257:                        ISQLDriver.IPropertyNames.JARFILE_NAMES, oldValue,
258:                        values);
259:            }
260:
261:            public String getUrl() {
262:                return _url;
263:            }
264:
265:            public void setUrl(String url) throws ValidationException {
266:                String data = getString(url);
267:                if (data.length() == 0) {
268:                    throw new ValidationException(IStrings.ERR_BLANK_URL);
269:                }
270:                if (!data.equals(_url)) {
271:                    final String oldValue = _url;
272:                    _url = data;
273:                    getPropertyChangeReporter().firePropertyChange(
274:                            ISQLDriver.IPropertyNames.URL, oldValue, _url);
275:                }
276:            }
277:
278:            public String getName() {
279:                return _name;
280:            }
281:
282:            public void setName(String name) throws ValidationException {
283:                String data = getString(name);
284:                if (data.length() == 0) {
285:                    throw new ValidationException(IStrings.ERR_BLANK_NAME);
286:                }
287:                if (!data.equals(_name)) {
288:                    final String oldValue = _name;
289:                    _name = data;
290:                    getPropertyChangeReporter().firePropertyChange(
291:                            ISQLDriver.IPropertyNames.NAME, oldValue, _name);
292:                }
293:            }
294:
295:            public boolean isJDBCDriverClassLoaded() {
296:                return _jdbcDriverClassLoaded;
297:            }
298:
299:            public void setJDBCDriverClassLoaded(boolean cl) {
300:                _jdbcDriverClassLoaded = cl;
301:                //TODO: Decide whether this should be a bound property or not.
302:                //		getPropertyChangeReporter().firePropertyChange(ISQLDriver.IPropertyNames.NAME, _name, _name);
303:            }
304:
305:            public synchronized StringWrapper[] getJarFileNameWrappers() {
306:                StringWrapper[] wrappers = new StringWrapper[_jarFileNamesList
307:                        .size()];
308:                for (int i = 0; i < wrappers.length; ++i) {
309:                    wrappers[i] = new StringWrapper(_jarFileNamesList.get(i));
310:                }
311:                return wrappers;
312:            }
313:
314:            public StringWrapper getJarFileNameWrapper(int idx)
315:                    throws ArrayIndexOutOfBoundsException {
316:                return new StringWrapper(_jarFileNamesList.get(idx));
317:            }
318:
319:            public void setJarFileNameWrappers(StringWrapper[] value) {
320:                _jarFileNamesList.clear();
321:                if (value != null) {
322:                    for (int i = 0; i < value.length; ++i) {
323:                        _jarFileNamesList.add(value[i].getString());
324:                    }
325:                }
326:            }
327:
328:            public void setJarFileNameWrapper(int idx, StringWrapper value)
329:                    throws ArrayIndexOutOfBoundsException {
330:                _jarFileNamesList.set(idx, value.getString());
331:            }
332:
333:            private String getString(String data) {
334:                return data != null ? data.trim() : "";
335:            }
336:
337:            private synchronized PropertyChangeReporter getPropertyChangeReporter() {
338:                if (_propChgReporter == null) {
339:                    _propChgReporter = new PropertyChangeReporter(this );
340:                }
341:                return _propChgReporter;
342:            }
343:
344:            /* (non-Javadoc)
345:             * @see net.sourceforge.squirrel_sql.fw.sql.ISQLDriver#getWebSiteUrl()
346:             */
347:            public String getWebSiteUrl() {
348:                return _websiteUrl;
349:            }
350:
351:            /* (non-Javadoc)
352:             * @see net.sourceforge.squirrel_sql.fw.sql.ISQLDriver#setWebSiteUrl(java.lang.String)
353:             */
354:            public void setWebSiteUrl(String url) throws ValidationException {
355:                String data = getString(url);
356:                if (!data.equals(_websiteUrl)) {
357:                    final String oldValue = _websiteUrl;
358:                    _websiteUrl = data;
359:                    PropertyChangeReporter pcr = getPropertyChangeReporter();
360:                    pcr.firePropertyChange(
361:                            ISQLDriver.IPropertyNames.WEBSITE_URL, oldValue,
362:                            _websiteUrl);
363:                }
364:            }
365:
366:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.