1 package org.apache.ojb.broker; 2 3 17 18 import java.io.Serializable ; 19 20 29 public class PBKey implements Cloneable , Serializable 30 { 31 private static final long serialVersionUID = -8858811398162391578L; 32 private final String jcdAlias; 33 private final String user; 34 private final String password; 35 private int hashCode; 36 37 44 public PBKey(final String jcdAlias, final String user, final String password) 45 { 46 this.jcdAlias = jcdAlias; 47 this.user = user; 48 this.password = password; 49 } 50 51 56 public PBKey(final String jcdAlias) 57 { 58 this(jcdAlias, null, null); 59 } 60 61 64 public boolean equals(Object obj) 65 { 66 if (obj == this) 67 { 68 return true; 69 } 70 if (!(obj instanceof PBKey)) 71 { 72 return false; 73 } 74 PBKey other = (PBKey) obj; 75 return this.jcdAlias.equals(other.getAlias()) 76 && (user != null ? user.equals(other.user) : null == other.user) 77 && (password != null ? password.equals(other.password) : null == other.password); 78 } 79 80 83 protected Object clone() throws CloneNotSupportedException 84 { 85 return new PBKey(this.jcdAlias, this.user, this.password); 86 } 87 88 91 public int hashCode() 92 { 93 if(hashCode == 0) 94 { 95 hashCode = jcdAlias.hashCode() 96 + (user != null ? user.hashCode() : 0) 97 + (password != null ? password.hashCode() : 0); 98 } 99 return hashCode; 100 } 101 102 105 public String toString() 106 { 107 return this.getClass().getName() + ": jcdAlias="+jcdAlias+", user="+user+ 108 (user != null ? ", password=*****" : ", password="+password); 109 } 110 111 116 public String getAlias() 117 { 118 return jcdAlias; 119 } 120 121 127 public String getRepositoryFile() 128 { 129 return jcdAlias; 130 } 131 132 137 public String getUser() 138 { 139 return user; 140 } 141 142 147 public String getPassword() 148 { 149 return password; 150 } 151 } 152 | Popular Tags |