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;
19 private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
24 public JDBCDriver(String className, String jarFileName, String type) {
25 this(className, jarFileName, type, null, null);
38 public JDBCDriver(String className, String jarFileName, String type, String name, String version) {
40 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)) {
128 } else if (this.type == null && that.type != null) {
130 } else if (this.type != null && !this.type.equals(that.type)) {
137 public int hashCode() {
139 if (this.className != null) {
140 hashCode ^= this.className.hashCode();
142 if (this.jarFileName != null) {
143 hashCode ^= this.jarFileName.hashCode();
145 if (this.type != null) {
146 hashCode ^= this.type.hashCode();
151 public Driver getDriver() {
152 return JarUtil.loadDriver(getJarFileName(), getClassName());
157 public void addPropertyChangeListener(PropertyChangeListener listener) {
158 this.propertyChangeSupport.addPropertyChangeListener(listener);
161 * @param propertyName
164 public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
165 this.propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
170 public void removePropertyChangeListener(PropertyChangeListener arg0) {
171 this.propertyChangeSupport.removePropertyChangeListener(arg0);
177 public void removePropertyChangeListener(String arg0, PropertyChangeListener arg1) {
178 this.propertyChangeSupport.removePropertyChangeListener(arg0, arg1);
181 * @return Returns the type.
183 public String getType() {
187 * @param type The type to set.
189 public void setType(String type) {
190 if (type != null && !type.equals(this.type)) {
191 String original = this.type;
193 this.propertyChangeSupport.firePropertyChange("type", original, type);