1 30 package com.genimen.djeneric.repository; 31 32 38 public class DjRepositoryDescriptor implements Comparable , Cloneable 39 { 40 public static final String JNDI_DATASOURCE_KEY = "jndi"; 41 public static final String TEXTUAL_JNDI_DATASOURCE_KEY = "[JNDI Datasource]"; 42 String _name; 43 String _driver; 44 String _url; 45 String _location; 46 String _user = null; 47 String _password = null; 48 String _sharedUser = ""; 49 String _sharedPassword = ""; 50 boolean _sharedConnection = false; 51 int _traceLevel = DjPersistenceManager.TRACE_NOTHING; 52 53 61 public DjRepositoryDescriptor(String name, String location, String driver, String url) 62 { 63 _name = name; 64 _location = location; 65 _driver = driver; 66 _url = url; 67 _sharedConnection = false; 68 } 69 70 75 public Object clone() 76 { 77 DjRepositoryDescriptor nrd = new DjRepositoryDescriptor(getName(), getRepositoryLocation(), getDriver(), getUrl()); 78 nrd.setSharedConnection(isSharedConnection()); 79 nrd.setSharedPassword(getSharedPassword()); 80 nrd.setSharedUser(getSharedUser()); 81 82 return nrd; 83 } 84 85 90 public void setSharedConnection(boolean isShared) 91 { 92 _sharedConnection = isShared; 93 } 94 95 100 public boolean isSharedConnection() 101 { 102 return _sharedConnection; 103 } 104 105 110 public String getName() 111 { 112 return _name; 113 } 114 115 120 public void setName(String name) 121 { 122 _name = name; 123 } 124 125 130 public void setTraceLevel(int level) 131 { 132 _traceLevel = level; 133 } 134 135 140 public int getTraceLevel() 141 { 142 return _traceLevel; 143 } 144 145 150 public String getRepositoryLocation() 151 { 152 return _location; 153 } 154 155 160 public void setRepositoryLocation(String location) 161 { 162 _location = location; 163 } 164 165 170 public String getDriver() 171 { 172 return _driver; 173 } 174 175 180 public void setDriver(String driver) 181 { 182 _driver = driver; 183 } 184 185 190 public String getUrl() 191 { 192 return _url; 193 } 194 195 200 public void setUrl(String url) 201 { 202 _url = url; 203 } 204 205 210 public void setUser(String user) 211 { 212 _user = user; 213 } 214 215 220 public String getUser() 221 { 222 return _user; 223 } 224 225 230 public void setPassword(String password) 231 { 232 _password = password; 233 } 234 235 240 public String getPassword() 241 { 242 return _password; 243 } 244 245 252 public void setSharedUser(String user) 253 { 254 _sharedUser = user; 255 } 256 257 262 public String getSharedUser() 263 { 264 return _sharedUser; 265 } 266 267 272 public void setSharedPassword(String password) 273 { 274 _sharedPassword = password; 275 } 276 277 282 public String getSharedPassword() 283 { 284 return _sharedPassword; 285 } 286 287 293 public boolean equals(Object obj) 294 { 295 if (!(obj instanceof DjRepositoryDescriptor)) return false; 296 DjRepositoryDescriptor r = (DjRepositoryDescriptor) obj; 297 298 return getName().equals(r.getName()) && getDriver().equals(r.getDriver()) 299 && getRepositoryLocation().equals(r.getRepositoryLocation()) && getSharedUser().equals(r.getSharedUser()) 300 && getSharedPassword().equals(r.getSharedPassword()) && isSharedConnection() == r.isSharedConnection() 301 && getUrl().equals(r.getUrl()); 302 } 303 304 public int hashCode() 305 { 306 return getName().hashCode(); 307 } 308 309 315 public int compareTo(Object obj) 316 { 317 if (!(obj instanceof DjRepositoryDescriptor)) return -1; 318 DjRepositoryDescriptor r = (DjRepositoryDescriptor) obj; 319 320 return getName().toLowerCase().compareTo(r.getName().toLowerCase()); 321 } 322 323 328 public String toString() 329 { 330 return getName(); 331 } 332 333 336 public boolean isDatasource() 337 { 338 return JNDI_DATASOURCE_KEY.equals(getDriver()) || TEXTUAL_JNDI_DATASOURCE_KEY.equals(getDriver()); 339 } 340 341 } | Popular Tags |