/**
   * Applies the QualifiedAttributeValueExp to an MBean.
   *
   * @param name The name of the MBean on which the QualifiedAttributeValueExp will be applied.
   * @return The ValueExp.
   * @exception BadStringOperationException
   * @exception BadBinaryOpValueExpException
   * @exception BadAttributeValueExpException
   * @exception InvalidApplicationException
   */
  public ValueExp apply(ObjectName name)
      throws BadStringOperationException, BadBinaryOpValueExpException,
          BadAttributeValueExpException, InvalidApplicationException {
    try {
      MBeanServer server = QueryEval.getMBeanServer();
      String v = server.getObjectInstance(name).getClassName();

      if (v.equals(className)) {
        return super.apply(name);
      }
      throw new InvalidApplicationException("Class name is " + v + ", should be " + className);

    } catch (Exception e) {
      throw new InvalidApplicationException("Qualified attribute: " + e);
      /* Can happen if MBean disappears between the time we
      construct the list of MBeans to query and the time we
      evaluate the query on this MBean, or if
      getObjectInstance throws SecurityException.  */
    }
  }