1. /*
  2. * @(#)NotQueryExp.java 4.17 03/12/19
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.management;
  8. /**
  9. * This class is used by the query-building mechanism to represent negations
  10. * of relational expressions.
  11. * @serial include
  12. *
  13. * @since 1.5
  14. */
  15. class NotQueryExp extends QueryEval implements QueryExp {
  16. /* Serial version */
  17. private static final long serialVersionUID = 5269643775896723397L;
  18. /**
  19. * @serial The negated {@link QueryExp}
  20. */
  21. private QueryExp exp;
  22. /**
  23. * Basic Constructor.
  24. */
  25. public NotQueryExp() {
  26. }
  27. /**
  28. * Creates a new NotQueryExp for negating the specified QueryExp.
  29. */
  30. public NotQueryExp(QueryExp q) {
  31. exp = q;
  32. }
  33. /**
  34. * Returns the negated query expression of the query.
  35. */
  36. public QueryExp getNegatedExp() {
  37. return exp;
  38. }
  39. /**
  40. * Applies the NotQueryExp on a MBean.
  41. *
  42. * @param name The name of the MBean on which the NotQueryExp will be applied.
  43. *
  44. * @return True if the query was successfully applied to the MBean, false otherwise.
  45. *
  46. * @exception BadStringOperationException
  47. * @exception BadBinaryOpValueExpException
  48. * @exception BadAttributeValueExpException
  49. * @exception InvalidApplicationException
  50. */
  51. public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException,
  52. BadAttributeValueExpException, InvalidApplicationException {
  53. return exp.apply(name) == false;
  54. }
  55. /**
  56. * Returns the string representing the object.
  57. */
  58. public String toString() {
  59. return "not (" + exp + ")";
  60. }
  61. }