1 19 package org.netbeans.modules.j2ee.sun.share; 20 21 32 public final class PrincipalNameMapping { 33 34 private String principalName; 35 private String className; 36 37 public PrincipalNameMapping(String pn) { 38 this(pn, null); 39 } 40 41 public PrincipalNameMapping(String pn, String cn) { 42 assert(pn != null) : "Principal name cannnot be null"; 43 44 principalName = pn; 45 className = cn; 46 } 47 48 public String toString() { 49 if(className == null || className.length() == 0) { 50 return principalName; 51 } 52 StringBuffer buffer = new StringBuffer (principalName.length() + className.length() + 10); 53 buffer.append(principalName); 54 buffer.append(" [cn="); 55 buffer.append(className); 56 buffer.append("]"); 57 return buffer.toString(); 58 } 59 60 public String getPrincipalName() { 61 return principalName; 62 } 63 64 public String getClassName() { 65 return className; 66 } 67 68 public boolean equals(Object obj) { 69 boolean result = false; 70 71 if(obj instanceof PrincipalNameMapping) { 72 result = principalName.equals(((PrincipalNameMapping) obj).getPrincipalName()); 73 } 74 75 return result; 76 } 77 78 public int hashCode() { 79 return principalName.hashCode(); 80 } 81 } 82 | Popular Tags |