X-Git-Url: http://git.phpeclipse.com

diff --git a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/JDBCDriver.java b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/JDBCDriver.java
index 8f28a75..d768589 100644
--- a/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/JDBCDriver.java
+++ b/archive/net.sourceforge.phpeclipse.quantum.sql/src/com/quantum/model/JDBCDriver.java
@@ -2,32 +2,34 @@ package com.quantum.model;
 
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
+import java.io.File;
 import java.sql.Driver;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 
 import com.quantum.util.JarUtil;
+import com.quantum.util.StringArrayComparator;
 
 
 /**
  * @author BC
  */
-public class JDBCDriver {
+public class JDBCDriver implements Comparable, Displayable {
 	private String name;
 	private String version;
 	private String className;
-	private String jarFileName;
+	private List jarFileNames = Collections.synchronizedList(new ArrayList());
 	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() {
+	public JDBCDriver(String className, String[] jarFileNames, String type) {
+		this(className, jarFileNames, type, null, null);
 	}
 	/**
 	 * @param className
@@ -35,12 +37,12 @@ public class JDBCDriver {
 	 * @param name
 	 * @param version
 	 */
-	public JDBCDriver(String className, String jarFileName, String type, String name, String version) {
+	public JDBCDriver(String className, String[] jarFileNames, String type, String name, String version) {
 		this.name = name;
 		this.version = version;
 		this.type = type;
 		this.className = className;
-		this.jarFileName = jarFileName;
+		this.jarFileNames.addAll(Arrays.asList(jarFileNames));
 	}
 	/**
 	 * @return Returns the className.
@@ -61,17 +63,21 @@ public class JDBCDriver {
 	/**
 	 * @return Returns the jarFileName.
 	 */
-	public String getJarFileName() {
-		return this.jarFileName;
+	public String[] getJarFileNames() {
+		return (String[]) this.jarFileNames.toArray(new String[this.jarFileNames.size()]);
 	}
 	/**
 	 * @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);
+	public void setJarFileNames(String[] jarFileNames) {
+		StringArrayComparator comparator = new StringArrayComparator();
+		if (comparator.compare(
+				(String[]) this.jarFileNames.toArray(new String[this.jarFileNames.size()]),
+				jarFileNames) != 0) {
+			String[] original = getJarFileNames();
+			this.jarFileNames.clear();
+			this.jarFileNames.addAll(Arrays.asList(jarFileNames));
+			this.propertyChangeSupport.firePropertyChange("jarFileName", original, jarFileNames);
 		}
 	}
 	/**
@@ -115,23 +121,27 @@ public class JDBCDriver {
 		} 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;
-			}
+			return equals((JDBCDriver) object);
+		}
+	}
+	/**
+	 * @param that
+	 * @return
+	 */
+	private boolean equals(JDBCDriver that) {
+		if (this.className == null && that.className != null) {
+			return false;
+		} else if (this.className != null && !this.className.equals(that.className)) {
+			return false;
+		} else if ((new StringArrayComparator()).compare(
+				this.getJarFileNames(), that.getJarFileNames()) != 0) {
+			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() {
@@ -139,8 +149,11 @@ public class JDBCDriver {
 		if (this.className != null) {
 			hashCode ^= this.className.hashCode();
 		}
-		if (this.jarFileName != null) {
-			hashCode ^= this.jarFileName.hashCode();
+		for (Iterator i = this.jarFileNames.iterator(); i.hasNext();) {
+			Object jarFile = i.next();
+			if (jarFile != null) {
+				hashCode ^= jarFile.hashCode();
+			}
 		}
 		if (this.type != null) {
 			hashCode ^= this.type.hashCode();
@@ -149,7 +162,7 @@ public class JDBCDriver {
 	}
 	
 	public Driver getDriver() {
-		return JarUtil.loadDriver(getJarFileName(), getClassName());
+		return JarUtil.loadDriver(getJarFileNames(), getClassName());
 	}
 	/**
 	 * @param listener
@@ -193,4 +206,28 @@ public class JDBCDriver {
 			this.propertyChangeSupport.firePropertyChange("type", original, type);
 		}
 	}
+	/* (non-Javadoc)
+	 * @see java.lang.Comparable#compareTo(java.lang.Object)
+	 */
+	public int compareTo(Object object) {
+		return (new DisplayableComparator()).compare(this, object);
+	}
+	/* (non-Javadoc)
+	 * @see com.quantum.model.Displayable#getDisplayName()
+	 */
+	public String getDisplayName() {
+		return getName();
+	}
+	
+	public String getJarFilePath() {
+		StringBuffer buffer = new StringBuffer();
+		for (Iterator i = this.jarFileNames.iterator(); i.hasNext();) {
+			String element = (String) i.next();
+			buffer.append(element);
+			if (i.hasNext()) {
+				buffer.append(File.pathSeparator);
+			}
+		}
+		return buffer.toString();
+	}
 }