--- /dev/null
+package com.quantum.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.sql.Driver;
+
+import com.quantum.util.JarUtil;
+
+
+/**
+ * @author BC
+ */
+public class JDBCDriver {
+ private String name;
+ private String version;
+ private String className;
+ private String jarFileName;
+ private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this);
+ /**
+ * @param className
+ * @param jarFileName
+ */
+ public JDBCDriver(String className, String jarFileName) {
+ super();
+ this.className = className;
+ this.jarFileName = jarFileName;
+ }
+ /**
+ *
+ */
+ public JDBCDriver() {
+ }
+ /**
+ * @param className
+ * @param jarFileName
+ * @param name
+ * @param version
+ */
+ public JDBCDriver(String className, String jarFileName, String name, String version) {
+ this.name = name;
+ this.version = version;
+ this.className = className;
+ this.jarFileName = jarFileName;
+ }
+ /**
+ * @return Returns the className.
+ */
+ public String getClassName() {
+ return this.className;
+ }
+ /**
+ * @param className The className to set.
+ */
+ public void setClassName(String className) {
+ if (className != null && !className.equals(this.className)) {
+ String original = this.className;
+ this.className = className;
+ this.propertyChangeSupport.firePropertyChange("className", original, className);
+ }
+ }
+ /**
+ * @return Returns the jarFileName.
+ */
+ public String getJarFileName() {
+ return this.jarFileName;
+ }
+ /**
+ * @param jarFileName The jarFileName to set.
+ */
+ public void setJarFileName(String jarFileName) {
+ if (jarFileName != null && !jarFileName.equals(this.jarFileName)) {
+ String original = this.jarFileName;
+ this.jarFileName = jarFileName;
+ this.propertyChangeSupport.firePropertyChange("jarFileName", original, jarFileName);
+ }
+ }
+ /**
+ * @return Returns the name.
+ */
+ public String getName() {
+ return this.name == null || this.name.trim().length() == 0 ? getClassName() : this.name;
+ }
+ /**
+ * @param name The name to set.
+ */
+ public void setName(String name) {
+ if (name != null && !name.equals(this.name)) {
+ String original = this.name;
+ this.name = name;
+ this.propertyChangeSupport.firePropertyChange("name", original, name);
+ }
+ }
+ /**
+ * @return Returns the version.
+ */
+ public String getVersion() {
+ return this.version;
+ }
+ /**
+ * @param version The version to set.
+ */
+ public void setVersion(String version) {
+ if (version != null && !version.equals(this.version)) {
+ String original = this.version;
+ this.version = version;
+ this.propertyChangeSupport.firePropertyChange("version", original, version);
+ }
+ }
+
+ public boolean equals(Object object) {
+ if (super.equals(object)) {
+ return true;
+ } else if (object == null) {
+ return false;
+ } else if (getClass() != object.getClass()) {
+ return false;
+ } else {
+ JDBCDriver that = (JDBCDriver) object;
+
+ if (this.className == null && that.className != null) {
+ return false;
+ } else if (this.className != null && !this.className.equals(that.className)) {
+ return false;
+ } else if (this.jarFileName == null && that.jarFileName != null) {
+ return false;
+ } else if (this.jarFileName != null && !this.jarFileName.equals(that.jarFileName)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+ }
+ public int hashCode() {
+ int hashCode = 31;
+ if (this.className != null) {
+ hashCode ^= this.className.hashCode();
+ }
+ if (this.jarFileName != null) {
+ hashCode ^= this.jarFileName.hashCode();
+ }
+ return hashCode;
+ }
+
+ public Driver getDriver() {
+ return JarUtil.loadDriver(getJarFileName(), getClassName());
+ }
+ /**
+ * @param listener
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ this.propertyChangeSupport.addPropertyChangeListener(listener);
+ }
+ /**
+ * @param propertyName
+ * @param listener
+ */
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ this.propertyChangeSupport.addPropertyChangeListener(propertyName, listener);
+ }
+ /**
+ * @param arg0
+ */
+ public void removePropertyChangeListener(PropertyChangeListener arg0) {
+ this.propertyChangeSupport.removePropertyChangeListener(arg0);
+ }
+ /**
+ * @param arg0
+ * @param arg1
+ */
+ public void removePropertyChangeListener(String arg0, PropertyChangeListener arg1) {
+ this.propertyChangeSupport.removePropertyChangeListener(arg0, arg1);
+ }
+}