1 22 package org.jboss.console.twiddle.command; 23 24 import javax.management.MBeanParameterInfo ; 25 26 31 public class MBeanOp 32 { 33 private String name; 34 private String [] sig; 35 36 public MBeanOp(String name, MBeanParameterInfo [] params) 37 { 38 this.name = name; 39 int count = params != null ? params.length : 0; 40 sig = new String [count]; 41 for(int n = 0; n < count; n ++) 42 { 43 MBeanParameterInfo p = params[n]; 44 sig[n] = p.getType(); 45 } 46 } 47 public MBeanOp(String name, int count) 48 { 49 this.name = name; 50 sig = new String [count]; 51 for(int n = 0; n < count; n ++) 52 { 53 sig[n] = String .class.getName(); 54 } 55 } 56 57 public String getName() 58 { 59 return name; 60 } 61 public String [] getSignature() 62 { 63 return sig; 64 } 65 public int getArgCount() 66 { 67 return sig.length; 68 } 69 public String getArgType(int n) 70 { 71 return sig[n]; 72 } 73 74 public boolean equals(Object obj) 75 { 76 MBeanOp op = (MBeanOp) obj; 77 if( op.name.equals(name) == false || sig.length != op.sig.length ) 78 return false; 79 for(int n = 0; n < sig.length; n ++) 80 { 81 if( sig[n].equals(op.sig[n]) == false ) 82 return false; 83 } 84 return true; 85 } 86 87 public int hashCode() 88 { 89 int hashCode = name.hashCode(); 90 for(int n = 0; n < sig.length; n ++) 91 { 92 hashCode += sig[n].hashCode(); 93 } 94 return hashCode; 95 } 96 } 97 | Popular Tags |