76 * 77 * @return the attribute name. 78 */ 79 public String getAttributeName() { 80 return attr; 81 } 82 83 /** 84 * <p>Applies the <CODE>AttributeValueExp</CODE> on an MBean. 85 * This method calls {@link #getAttribute getAttribute(name)} and wraps 86 * the result as a {@code ValueExp}. The value returned by 87 * {@code getAttribute} must be a {@code Number}, {@code String}, 88 * or {@code Boolean}; otherwise this method throws a 89 * {@code BadAttributeValueExpException}, which will cause 90 * the containing query to be false for this {@code name}.</p> 91 * 92 * @param name The name of the MBean on which the <CODE>AttributeValueExp</CODE> will be applied. 93 * 94 * @return The <CODE>ValueExp</CODE>. 95 * 96 * @exception BadAttributeValueExpException 97 * @exception InvalidApplicationException 98 * @exception BadStringOperationException 99 * @exception BadBinaryOpValueExpException 100 * 101 */ 102 @Override 103 public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, 104 BadAttributeValueExpException, InvalidApplicationException { 105 Object result = getAttribute(name); 106 107 if (result instanceof Number) { 108 return new NumericValueExp((Number)result); 109 } else if (result instanceof String) { 110 return new StringValueExp((String)result); 111 } else if (result instanceof Boolean) { 112 return new BooleanValueExp((Boolean)result); 113 } else { 114 throw new BadAttributeValueExpException(result); 115 } 116 } 117 118 /** 119 * Returns the string representing its value. 120 */ | 76 * 77 * @return the attribute name. 78 */ 79 public String getAttributeName() { 80 return attr; 81 } 82 83 /** 84 * <p>Applies the <CODE>AttributeValueExp</CODE> on an MBean. 85 * This method calls {@link #getAttribute getAttribute(name)} and wraps 86 * the result as a {@code ValueExp}. The value returned by 87 * {@code getAttribute} must be a {@code Number}, {@code String}, 88 * or {@code Boolean}; otherwise this method throws a 89 * {@code BadAttributeValueExpException}, which will cause 90 * the containing query to be false for this {@code name}.</p> 91 * 92 * @param name The name of the MBean on which the <CODE>AttributeValueExp</CODE> will be applied. 93 * 94 * @return The <CODE>ValueExp</CODE>. 95 * 96 * @throws BadStringOperationException {@inheritDoc} 97 * @throws BadBinaryOpValueExpException {@inheritDoc} 98 * @throws BadAttributeValueExpException {@inheritDoc} 99 * @throws InvalidApplicationException {@inheritDoc} 100 */ 101 @Override 102 public ValueExp apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException, 103 BadAttributeValueExpException, InvalidApplicationException { 104 Object result = getAttribute(name); 105 106 if (result instanceof Number) { 107 return new NumericValueExp((Number)result); 108 } else if (result instanceof String) { 109 return new StringValueExp((String)result); 110 } else if (result instanceof Boolean) { 111 return new BooleanValueExp((Boolean)result); 112 } else { 113 throw new BadAttributeValueExpException(result); 114 } 115 } 116 117 /** 118 * Returns the string representing its value. 119 */ |