FileDocCategorySizeDatePackage
AttributeValueExp.javaAPI DocJava SE 5 API3597Fri Aug 26 14:57:32 BST 2005javax.management

AttributeValueExp

public class AttributeValueExp extends Object implements ValueExp
Represents attributes used as arguments to relational constraints. An AttributeValueExp may be used anywhere a ValueExp is required.
since
1.5

Fields Summary
private static final long
serialVersionUID
private String
attr
Constructors Summary
public AttributeValueExp()
An AttributeValueExp with a null attribute.

deprecated
An instance created with this constructor cannot be used in a query.


                            
    
       
    
public AttributeValueExp(String attr)
Creates a new AttributeValueExp representing the specified object attribute, named attr.

param
attr the name of the attribute whose value is the value of this {@link ValueExp}.

 
	this.attr = attr;
    
Methods Summary
public javax.management.ValueExpapply(javax.management.ObjectName name)
Applies the AttributeValueExp on an MBean.

param
name The name of the MBean on which the AttributeValueExp will be applied.
return
The ValueExp.
exception
BadAttributeValueExpException
exception
InvalidApplicationException
exception
BadStringOperationException
exception
BadBinaryOpValueExpException

	Object result = getAttribute(name);
	
	if (result instanceof Number) {
	    return new NumericValueExp((Number)result);
	} else if (result instanceof String) {
	    return new StringValueExp((String)result);
	} else if (result instanceof Boolean) {
	    return new BooleanValueExp((Boolean)result);
	} else {
	    throw new BadAttributeValueExpException(result);
	}
    
protected java.lang.ObjectgetAttribute(javax.management.ObjectName name)
Return the value of the given attribute in the named MBean. If the attempt to access the attribute generates an exception, return null.

param
name the name of the MBean whose attribute is to be returned.
return
the value of the attribute, or null if it could not be obtained.

	try {
	    // Get the value from the MBeanServer

	    MBeanServer server = QueryEval.getMBeanServer();

	    return server.getAttribute(name, attr);
	} catch (Exception re) {
	    return null;
	}
    
public java.lang.StringgetAttributeName()
Returns a string representation of the name of the attribute.

return
the attribute name.

 
	return attr;
    
public voidsetMBeanServer(javax.management.MBeanServer s)
Sets the MBean server on which the query is to be performed.

param
s The MBean server on which the query is to be performed.

 
    
public java.lang.StringtoString()
Returns the string representing its value.

 
	return attr;