1 19 20 package org.netbeans.modules.tomcat5.config; 21 22 import org.netbeans.modules.j2ee.deployment.common.api.Datasource; 23 24 29 public class TomcatDatasource implements Datasource { 30 31 private final String username; 32 private final String url; 33 private final String password; 34 private final String jndiName; 35 private final String driverClassName; 36 private int hash; 37 38 41 public TomcatDatasource(String username, String url, String password, String jndiName, String driverClassName) { 42 this.username = username; 43 this.url = url; 44 this.password = password; 45 this.jndiName = jndiName; 46 this.driverClassName = driverClassName; 47 } 48 49 public String getUsername() { 50 return username; 51 } 52 53 public String getUrl() { 54 return url; 55 } 56 57 public String getPassword() { 58 return password; 59 } 60 61 public String getJndiName() { 62 return jndiName; 63 } 64 65 public String getDriverClassName() { 66 return driverClassName; 67 } 68 69 public String getDisplayName() { 70 return jndiName + " [" + url + "]"; } 72 73 public boolean equals(Object obj) { 74 if (this == obj) { 75 return true; 76 } 77 if (!(obj instanceof TomcatDatasource)) { 78 return false; 79 } 80 TomcatDatasource ds = (TomcatDatasource)obj; 81 if ((jndiName == null && ds.jndiName != null) || (jndiName != null && !jndiName.equals(ds.jndiName))) { 82 return false; 83 } 84 if ((url == null && ds.url != null) || (url != null && !url.equals(ds.url))) { 85 return false; 86 } 87 if ((username == null && ds.username != null) || (username != null && !username.equals(ds.username))) { 88 return false; 89 } 90 if ((password == null && ds.password != null) || (password != null && !password.equals(ds.password))) { 91 return false; 92 } 93 if ((driverClassName == null && ds.driverClassName != null) || (driverClassName != null && !driverClassName.equals(ds.driverClassName))) { 94 return false; 95 } 96 return true; 97 } 98 99 public int hashCode() { 100 if (hash == 0) { 101 int result = 17; 102 result += 37 * result + (jndiName == null ? 0 : jndiName.hashCode()); 103 result += 37 * result + (url == null ? 0 : url.hashCode()); 104 result += 37 * result + (username == null ? 0 : username.hashCode()); 105 result += 37 * result + (password == null ? 0 : password.hashCode()); 106 result += 37 * result + (driverClassName == null ? 0 : driverClassName.hashCode()); 107 hash = result; 108 } 109 return hash; 110 } 111 112 public String toString() { 113 StringBuilder sb = new StringBuilder (); 114 sb.append("TomcatDatasource [username=").append(username); sb.append(", url=").append(url); sb.append(", password=").append(password); sb.append(", jndiName=").append(jndiName); sb.append(", driverClassName=").append(driverClassName).append("]"); return sb.toString(); 120 } 121 122 } 123 | Popular Tags |