KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > explorer > DatabaseDriver


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.modules.db.explorer;
21
22 import java.util.*;
23 import java.io.*;
24 import org.netbeans.api.db.explorer.JDBCDriver;
25
26 // XXX this class is completely unuseful and should be removed
27

28 /**
29 * xxx
30 *
31 * @author Slavek Psenicka
32 */

33 public class DatabaseDriver extends Object JavaDoc implements Externalizable
34 {
35     private String JavaDoc name;
36     private String JavaDoc url;
37     private String JavaDoc prefix;
38     private String JavaDoc adaptor;
39     private transient JDBCDriver jdbcDriver;
40
41     static final long serialVersionUID =7937512184160164098L;
42     public DatabaseDriver()
43     {
44     }
45
46     public DatabaseDriver(String JavaDoc dname, String JavaDoc durl)
47     {
48         name = dname;
49         url = durl;
50     }
51
52     public DatabaseDriver(String JavaDoc dname, String JavaDoc durl, String JavaDoc dprefix)
53     {
54         name = dname;
55         url = durl;
56         prefix = dprefix;
57     }
58     
59     public DatabaseDriver(String JavaDoc dname, String JavaDoc durl, String JavaDoc dprefix, JDBCDriver djdbcDriver)
60     {
61         name = dname;
62         url = durl;
63         prefix = dprefix;
64         jdbcDriver = djdbcDriver;
65     }
66
67     public DatabaseDriver(String JavaDoc dname, String JavaDoc durl, String JavaDoc dprefix, String JavaDoc dbadap)
68     {
69         name = dname;
70         url = durl;
71         prefix = dprefix;
72         adaptor = dbadap;
73     }
74
75     public String JavaDoc getName()
76     {
77         if (name != null) return name;
78         return url;
79     }
80
81     public void setName(String JavaDoc nname)
82     {
83         name = nname;
84     }
85
86     public String JavaDoc getURL()
87     {
88         return url;
89     }
90
91     public void setURL(String JavaDoc nurl)
92     {
93         url = nurl;
94     }
95
96     public String JavaDoc getDatabasePrefix()
97     {
98         return prefix;
99     }
100
101     public void setDatabasePrefix(String JavaDoc pref)
102     {
103         prefix = pref;
104     }
105
106     public String JavaDoc getDatabaseAdaptor()
107     {
108         return adaptor;
109     }
110
111     public void setDatabaseAdaptor(String JavaDoc name)
112     {
113         if (name == null || name.length() == 0) adaptor = null;
114         else if (name.startsWith("Database.Adaptors.")) adaptor = name; //NOI18N
115
else adaptor = "Database.Adaptors."+name; //NOI18N
116
// System.out.println("Metadata adaptor class set = "+adaptor);
117
}
118     
119     public JDBCDriver getJDBCDriver() {
120         return jdbcDriver;
121     }
122
123     public boolean equals(Object JavaDoc obj)
124     {
125         if (obj instanceof String JavaDoc) return obj.equals(url);
126         boolean c1 = ((DatabaseDriver)obj).getURL().equals(url);
127         boolean c2 = ((DatabaseDriver)obj).getName().equals(name);
128         return c1 && c2;
129     }
130
131     public String JavaDoc toString()
132     {
133         return getName();
134     }
135
136     /** Writes data
137     * @param out ObjectOutputStream
138     */

139     public void writeExternal(ObjectOutput out) throws IOException
140     {
141         out.writeObject(name);
142         out.writeObject(url);
143         out.writeObject(prefix);
144         out.writeObject(adaptor);
145     }
146
147     /** Reads data
148     * @param in ObjectInputStream
149     */

150     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException JavaDoc
151     {
152         name = (String JavaDoc)in.readObject();
153         url = (String JavaDoc)in.readObject();
154         prefix = (String JavaDoc)in.readObject();
155         adaptor = (String JavaDoc)in.readObject();
156     }
157 }
158
Popular Tags