1 package com.quantum.model;
3 import java.beans.PropertyChangeListener;
4 import java.beans.PropertyChangeSupport;
5 import java.sql.Driver;
7 import com.quantum.util.JarUtil;
13 public class JDBCDriver {
15 private String version;
16 private String className;
17 private String jarFileName;
18 private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
23 public JDBCDriver(String className, String jarFileName) {
25 this.className = className;
26 this.jarFileName = jarFileName;
39 public JDBCDriver(String className, String jarFileName, String name, String version) {
41 this.version = version;
42 this.className = className;
43 this.jarFileName = jarFileName;
46 * @return Returns the className.
48 public String getClassName() {
49 return this.className;
52 * @param className The className to set.
54 public void setClassName(String className) {
55 if (className != null && !className.equals(this.className)) {
56 String original = this.className;
57 this.className = className;
58 this.propertyChangeSupport.firePropertyChange("className", original, className);
62 * @return Returns the jarFileName.
64 public String getJarFileName() {
65 return this.jarFileName;
68 * @param jarFileName The jarFileName to set.
70 public void setJarFileName(String jarFileName) {
71 if (jarFileName != null && !jarFileName.equals(this.jarFileName)) {
72 String original = this.jarFileName;
73 this.jarFileName = jarFileName;
74 this.propertyChangeSupport.firePropertyChange("jarFileName", original, jarFileName);
78 * @return Returns the name.
80 public String getName() {
81 return this.name == null || this.name.trim().length() == 0 ? getClassName() : this.name;
84 * @param name The name to set.
86 public void setName(String name) {
87 if (name != null && !name.equals(this.name)) {
88 String original = this.name;
90 this.propertyChangeSupport.firePropertyChange("name", original, name);
94 * @return Returns the version.
96 public String getVersion() {
100 * @param version The version to set.
102 public void setVersion(String version) {
103 if (version != null && !version.equals(this.version)) {
104 String original = this.version;
105 this.version = version;
106 this.propertyChangeSupport.firePropertyChange("version", original, version);
110 public boolean equals(Object object) {
111 if (super.equals(object)) {
113 } else if (object == null) {
115 } else if (getClass() != object.getClass()) {
118 JDBCDriver that = (JDBCDriver) object;
120 if (this.className == null && that.className != null) {
122 } else if (this.className != null && !this.className.equals(that.className)) {
124 } else if (this.jarFileName == null && that.jarFileName != null) {
126 } else if (this.jarFileName != null && !this.jarFileName.equals(that.jarFileName)) {
133 public int hashCode() {
135 if (this.className != null) {
136 hashCode ^= this.className.hashCode();
138 if (this.jarFileName != null) {
139 hashCode ^= this.jarFileName.hashCode();
144 public Driver getDriver() {
145 return JarUtil.loadDriver(getJarFileName(), getClassName());
150 public void addPropertyChangeListener(PropertyChangeListener listener) {
151 this.propertyChangeSupport.addPropertyChangeListener(listener);
154 * @param propertyName
157 public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
158 this.propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
163 public void removePropertyChangeListener(PropertyChangeListener arg0) {
164 this.propertyChangeSupport.removePropertyChangeListener(arg0);
170 public void removePropertyChangeListener(String arg0, PropertyChangeListener arg1) {
171 this.propertyChangeSupport.removePropertyChangeListener(arg0, arg1);