1 7 8 package javax.management; 9 10 11 18 class InQueryExp extends QueryEval implements QueryExp { 19 20 21 private static final long serialVersionUID = -5801329450358952434L; 22 23 26 private ValueExp val; 27 28 31 private ValueExp [] valueList; 32 33 34 37 public InQueryExp() { 38 } 39 40 44 public InQueryExp(ValueExp v1, ValueExp items[]) { 45 val = v1; 46 valueList = items; 47 } 48 49 50 53 public ValueExp getCheckedValue() { 54 return val; 55 } 56 57 60 public ValueExp [] getExplicitValues() { 61 return valueList; 62 } 63 64 76 public boolean apply(ObjectName name) throws BadStringOperationException , BadBinaryOpValueExpException , 77 BadAttributeValueExpException , InvalidApplicationException { 78 if (valueList != null) { 79 ValueExp v = val.apply(name); 80 boolean numeric = v instanceof NumericValueExp ; 81 82 for (int i = 0; i < valueList.length; i++) { 83 if (numeric) { 84 if (((NumericValueExp )valueList[i]).doubleValue() == 85 ((NumericValueExp )v).doubleValue()) { 86 return true; 87 } 88 } else { 89 if (((StringValueExp )valueList[i]).getValue().equals( 90 ((StringValueExp )v).getValue())) { 91 return true; 92 } 93 } 94 } 95 } 96 return false; 97 } 98 99 102 public String toString() { 103 return val + " in (" + generateValueList() + ")"; 104 } 105 106 107 private String generateValueList() { 108 if (valueList == null || valueList.length == 0) { 109 return ""; 110 } 111 112 StringBuffer result = new StringBuffer (valueList[0].toString()); 113 114 for (int i = 1; i < valueList.length; i++) { 115 result.append(", "); 116 result.append(valueList[i]); 117 } 118 119 return result.toString(); 120 } 121 122 } 123 | Popular Tags |