1 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 28 33 public class DatabaseDriver extends Object implements Externalizable 34 { 35 private String name; 36 private String url; 37 private String prefix; 38 private String adaptor; 39 private transient JDBCDriver jdbcDriver; 40 41 static final long serialVersionUID =7937512184160164098L; 42 public DatabaseDriver() 43 { 44 } 45 46 public DatabaseDriver(String dname, String durl) 47 { 48 name = dname; 49 url = durl; 50 } 51 52 public DatabaseDriver(String dname, String durl, String dprefix) 53 { 54 name = dname; 55 url = durl; 56 prefix = dprefix; 57 } 58 59 public DatabaseDriver(String dname, String durl, String dprefix, JDBCDriver djdbcDriver) 60 { 61 name = dname; 62 url = durl; 63 prefix = dprefix; 64 jdbcDriver = djdbcDriver; 65 } 66 67 public DatabaseDriver(String dname, String durl, String dprefix, String dbadap) 68 { 69 name = dname; 70 url = durl; 71 prefix = dprefix; 72 adaptor = dbadap; 73 } 74 75 public String getName() 76 { 77 if (name != null) return name; 78 return url; 79 } 80 81 public void setName(String nname) 82 { 83 name = nname; 84 } 85 86 public String getURL() 87 { 88 return url; 89 } 90 91 public void setURL(String nurl) 92 { 93 url = nurl; 94 } 95 96 public String getDatabasePrefix() 97 { 98 return prefix; 99 } 100 101 public void setDatabasePrefix(String pref) 102 { 103 prefix = pref; 104 } 105 106 public String getDatabaseAdaptor() 107 { 108 return adaptor; 109 } 110 111 public void setDatabaseAdaptor(String name) 112 { 113 if (name == null || name.length() == 0) adaptor = null; 114 else if (name.startsWith("Database.Adaptors.")) adaptor = name; else adaptor = "Database.Adaptors."+name; } 118 119 public JDBCDriver getJDBCDriver() { 120 return jdbcDriver; 121 } 122 123 public boolean equals(Object obj) 124 { 125 if (obj instanceof String ) 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 toString() 132 { 133 return getName(); 134 } 135 136 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 150 public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException 151 { 152 name = (String )in.readObject(); 153 url = (String )in.readObject(); 154 prefix = (String )in.readObject(); 155 adaptor = (String )in.readObject(); 156 } 157 } 158 | Popular Tags |