1 21 22 package org.apache.derby.impl.services.monitor; 23 24 import org.apache.derby.iapi.error.StandardException; 25 import org.apache.derby.iapi.services.monitor.Monitor; 26 27 28 31 32 33 class ProtocolKey { 34 35 38 39 42 protected Class factoryInterface; 43 44 47 protected String identifier; 48 49 52 53 protected ProtocolKey(Class factoryInterface, String identifier) 54 { 55 super(); 56 this.factoryInterface = factoryInterface; 57 this.identifier = identifier; 58 } 59 60 static ProtocolKey create(String className, String identifier) throws StandardException { 61 62 Throwable t; 63 try { 64 return new ProtocolKey(Class.forName(className), identifier); 65 66 } catch (ClassNotFoundException cnfe) { 67 t = cnfe; 68 } catch (IllegalArgumentException iae) { 69 t = iae; 70 } 71 72 throw Monitor.exceptionStartingModule(t); 73 } 74 75 78 79 protected Class getFactoryInterface() { 80 return factoryInterface; 81 } 82 83 protected String getIdentifier() { 84 return identifier; 85 } 86 87 90 91 public int hashCode() { 92 return factoryInterface.hashCode() + 93 (identifier == null ? 0 : identifier.hashCode()); 94 } 95 96 public boolean equals(Object other) { 97 if (other instanceof ProtocolKey) { 98 ProtocolKey otherKey = (ProtocolKey) other; 99 100 if (factoryInterface != otherKey.factoryInterface) 101 return false; 102 103 if (identifier == null) { 104 if (otherKey.identifier != null) 105 return false; 106 } else { 107 108 if (otherKey.identifier == null) 109 return false; 110 111 if (!identifier.equals(otherKey.identifier)) 112 return false; 113 } 114 115 return true; 116 } 117 return false; 118 } 119 120 public String toString() { 121 122 return factoryInterface.getName() + " (" + identifier + ")"; 123 } 124 } 125 | Popular Tags |