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 String type; private PropertyChangeSupport propertyChangeSupport = new PropertyChangeSupport(this); /** * @param className * @param jarFileName */ public JDBCDriver(String className, String jarFileName, String type) { this(className, jarFileName, type, null, null); } /** * */ public JDBCDriver() { } /** * @param className * @param jarFileName * @param name * @param version */ public JDBCDriver(String className, String jarFileName, String type, String name, String version) { this.name = name; this.version = version; this.type = type; 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 if (this.type == null && that.type != null) { return false; } else if (this.type != null && !this.type.equals(that.type)) { 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(); } if (this.type != null) { hashCode ^= this.type.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); } /** * @return Returns the type. */ public String getType() { return this.type; } /** * @param type The type to set. */ public void setType(String type) { if (type != null && !type.equals(this.type)) { String original = this.type; this.type = type; this.propertyChangeSupport.firePropertyChange("type", original, type); } } }