KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > api > db > explorer > JDBCDriver


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.api.db.explorer;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import java.beans.PropertyChangeSupport JavaDoc;
24 import java.net.URL JavaDoc;
25 import java.util.Arrays JavaDoc;
26
27 /**
28  * Encapsulates a JDBC driver.
29  */

30 public final class JDBCDriver {
31
32     private URL JavaDoc[] urls;
33     private String JavaDoc clazz;
34     private String JavaDoc displayName;
35     private String JavaDoc name;
36
37     JDBCDriver(String JavaDoc name, String JavaDoc displayName, String JavaDoc clazz, URL JavaDoc[] urls) {
38         assert name != null && displayName != null && clazz != null && urls != null;
39         this.name = name;
40         this.displayName = displayName;
41         this.clazz = clazz;
42         this.urls = urls;
43     }
44
45     /**
46      * Creates a new JDBCDriver instance.
47      *
48      * @param name the programmatic name of the driver; must not be null.
49      * @param displayName the display name of the driver (used for example to display the driver in the UI); must not be null.
50      * @param clazz the JDBC driver class; must not be null.
51      * @param urls the array of the JDBC driver files URLs; must not be null.
52      *
53      * @throws NullPointerException if any of the parameters is null.
54      */

55     public static JDBCDriver create(String JavaDoc name, String JavaDoc displayName, String JavaDoc clazz, URL JavaDoc[] urls) {
56         if (name == null || displayName == null || clazz == null || urls == null) {
57             throw new NullPointerException JavaDoc();
58         }
59         return new JDBCDriver(name, displayName, clazz, urls);
60     }
61     
62     /**
63      * Returns the array of the JDBC driver files URLs.
64      *
65      * @return the non-null array of the JDBC driver files URLs.
66      */

67     public URL JavaDoc[] getURLs() {
68         return urls;
69     }
70     
71     /**
72      * Returns the JDBC driver class name.
73      *
74      * @return the JDBC driver class name.
75      */

76     public String JavaDoc getClassName() {
77         return clazz;
78     }
79     
80     /**
81      * Returns the display name of the driver (used for example to display the driver in the UI).
82      *
83      * @return the display name of the driver.
84      */

85     public String JavaDoc getDisplayName() {
86         return displayName;
87     }
88     
89     /**
90      * Return the programmatic driver name.
91      *
92      * @return the programmatic driver name.
93      */

94     public String JavaDoc getName() {
95         return name;
96     }
97     
98     public String JavaDoc toString() {
99         return "JDBCDriver[name='" + name + // NOI18N
100
"',displayName='" + displayName + // NOI18N
101
"',className='" + clazz + // NOI18N
102
"',urls=" + Arrays.asList(urls) + "]"; // NOI18N
103
}
104 }
105
Popular Tags