1 56 57 package org.objectstyle.cayenne.conn; 58 59 import java.io.Serializable ; 60 61 import org.objectstyle.cayenne.util.Util; 62 63 71 public class DataSourceInfo implements Cloneable , Serializable { 72 protected String userName; 73 protected String password; 74 protected String jdbcDriver; 75 protected String dataSourceUrl; 76 protected String adapterClassName; 77 protected int minConnections = 1; 78 protected int maxConnections = 1; 79 80 public boolean equals(Object obj) { 81 if (obj == this) 82 return true; 83 84 if (obj == null) 85 return false; 86 87 if (obj.getClass() != this.getClass()) 88 return false; 89 90 DataSourceInfo dsi = (DataSourceInfo) obj; 91 if (!Util.nullSafeEquals(this.userName, dsi.userName)) 92 return false; 93 94 if (!Util.nullSafeEquals(this.password, dsi.password)) 95 return false; 96 97 if (!Util.nullSafeEquals(this.jdbcDriver, dsi.jdbcDriver)) 98 return false; 99 100 if (!Util.nullSafeEquals(this.dataSourceUrl, dsi.dataSourceUrl)) 101 return false; 102 103 if (!Util.nullSafeEquals(this.adapterClassName, dsi.adapterClassName)) 104 return false; 105 106 if (this.minConnections != dsi.minConnections) 107 return false; 108 109 if (this.maxConnections != dsi.maxConnections) 110 return false; 111 112 return true; 113 } 114 115 public DataSourceInfo cloneInfo() { 116 try { 117 return (DataSourceInfo) super.clone(); 118 } catch (CloneNotSupportedException ex) { 119 throw new RuntimeException ("Cloning error", ex); 120 } 121 } 122 123 public String toString() { 124 StringBuffer buf = new StringBuffer (); 125 buf 126 .append("[") 127 .append(this.getClass().getName()) 128 .append(":") 129 .append("\n user name: ") 130 .append(userName) 131 .append("\n password: "); 132 133 if (password == null) 134 buf.append("null"); 135 else 136 buf.append("**********"); 137 138 buf 139 .append("\n driver: ") 140 .append(jdbcDriver) 141 .append("\n db adapter class: ") 142 .append(adapterClassName) 143 .append("\n url: ") 144 .append(dataSourceUrl) 145 .append("\n min. connections: ") 146 .append(minConnections) 147 .append("\n max. connections: ") 148 .append(maxConnections) 149 .append("\n]"); 150 151 return buf.toString(); 152 } 153 154 public String getAdapterClassName() { 155 return adapterClassName; 156 } 157 158 public void setAdapterClassName(String adapterClassName) { 159 this.adapterClassName = adapterClassName; 160 } 161 162 public void setMinConnections(int minConnections) { 163 this.minConnections = minConnections; 164 } 165 166 public int getMinConnections() { 167 return minConnections; 168 } 169 170 public void setMaxConnections(int maxConnections) { 171 this.maxConnections = maxConnections; 172 } 173 174 public int getMaxConnections() { 175 return maxConnections; 176 } 177 178 public void setUserName(String userName) { 179 this.userName = userName; 180 } 181 182 public String getUserName() { 183 return userName; 184 } 185 186 public void setPassword(String password) { 187 this.password = password; 188 } 189 190 public String getPassword() { 191 return password; 192 } 193 194 public void setJdbcDriver(String jdbcDriver) { 195 this.jdbcDriver = jdbcDriver; 196 } 197 198 public String getJdbcDriver() { 199 return jdbcDriver; 200 } 201 202 public void setDataSourceUrl(String dataSourceUrl) { 203 this.dataSourceUrl = dataSourceUrl; 204 } 205 206 public String getDataSourceUrl() { 207 return dataSourceUrl; 208 } 209 210 } 211 | Popular Tags |