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-2006 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:
042: package org.netbeans.modules.db.explorer;
043:
044: import java.util.*;
045: import java.io.*;
046: import org.netbeans.api.db.explorer.JDBCDriver;
047:
048: // XXX this class is completely unuseful and should be removed
049:
050: /**
051: * xxx
052: *
053: * @author Slavek Psenicka
054: */
055: public class DatabaseDriver extends Object implements Externalizable {
056: private String name;
057: private String url;
058: private String prefix;
059: private String adaptor;
060: private transient JDBCDriver jdbcDriver;
061:
062: static final long serialVersionUID = 7937512184160164098L;
063:
064: public DatabaseDriver() {
065: }
066:
067: public DatabaseDriver(String dname, String durl) {
068: name = dname;
069: url = durl;
070: }
071:
072: public DatabaseDriver(String dname, String durl, String dprefix) {
073: name = dname;
074: url = durl;
075: prefix = dprefix;
076: }
077:
078: public DatabaseDriver(String dname, String durl, String dprefix,
079: JDBCDriver djdbcDriver) {
080: name = dname;
081: url = durl;
082: prefix = dprefix;
083: jdbcDriver = djdbcDriver;
084: }
085:
086: public DatabaseDriver(String dname, String durl, String dprefix,
087: String dbadap) {
088: name = dname;
089: url = durl;
090: prefix = dprefix;
091: adaptor = dbadap;
092: }
093:
094: public String getName() {
095: if (name != null)
096: return name;
097: return url;
098: }
099:
100: public void setName(String nname) {
101: name = nname;
102: }
103:
104: public String getURL() {
105: return url;
106: }
107:
108: public void setURL(String nurl) {
109: url = nurl;
110: }
111:
112: public String getDatabasePrefix() {
113: return prefix;
114: }
115:
116: public void setDatabasePrefix(String pref) {
117: prefix = pref;
118: }
119:
120: public String getDatabaseAdaptor() {
121: return adaptor;
122: }
123:
124: public void setDatabaseAdaptor(String name) {
125: if (name == null || name.length() == 0)
126: adaptor = null;
127: else if (name.startsWith("Database.Adaptors."))
128: adaptor = name; //NOI18N
129: else
130: adaptor = "Database.Adaptors." + name; //NOI18N
131: // System.out.println("Metadata adaptor class set = "+adaptor);
132: }
133:
134: public JDBCDriver getJDBCDriver() {
135: return jdbcDriver;
136: }
137:
138: public boolean equals(Object obj) {
139: if (obj instanceof String)
140: return obj.equals(url);
141: boolean c1 = ((DatabaseDriver) obj).getURL().equals(url);
142: boolean c2 = ((DatabaseDriver) obj).getName().equals(name);
143: return c1 && c2;
144: }
145:
146: public String toString() {
147: return getName();
148: }
149:
150: /** Writes data
151: * @param out ObjectOutputStream
152: */
153: public void writeExternal(ObjectOutput out) throws IOException {
154: out.writeObject(name);
155: out.writeObject(url);
156: out.writeObject(prefix);
157: out.writeObject(adaptor);
158: }
159:
160: /** Reads data
161: * @param in ObjectInputStream
162: */
163: public void readExternal(ObjectInput in) throws IOException,
164: ClassNotFoundException {
165: name = (String) in.readObject();
166: url = (String) in.readObject();
167: prefix = (String) in.readObject();
168: adaptor = (String) in.readObject();
169: }
170: }
|