1 22 package org.jboss.monitor.alarm; 23 24 import javax.management.ObjectName ; 25 26 34 class AlarmKey 35 { 36 38 private String alarmId; 39 40 42 public static AlarmKey createKey(Object mbean, String type) 43 { 44 if (mbean instanceof ObjectName ) 45 { 46 return new AlarmKey(mbean.toString(), type); 47 } 48 else if (mbean instanceof String ) 49 { 50 return new AlarmKey((String )mbean, type); 51 } 52 else 53 { 54 throw new IllegalArgumentException ("Bad non-ObjectName 'mbean' parameter: " + mbean); 55 } 56 } 57 58 60 public AlarmKey(String mbean, String type) 61 { 62 StringBuffer sbuf = new StringBuffer (256); 63 64 sbuf.append(mbean).append('+').append(type); 65 66 alarmId = sbuf.toString(); 67 } 68 69 71 74 public boolean equals(Object obj) 75 { 76 if (obj instanceof AlarmKey) 77 { 78 return ((AlarmKey)obj).alarmId.equals(this.alarmId); 79 } 80 else 81 { 82 return false; 83 } 84 } 85 86 89 public int hashCode() 90 { 91 return this.alarmId.hashCode(); 92 } 93 94 97 public String toString() 98 { 99 StringBuffer sbuf = new StringBuffer (256); 100 101 sbuf.append("AlarmKey[").append(this.alarmId).append("]"); 102 103 return sbuf.toString(); 104 } 105 } 106 | Popular Tags |