1. /*
  2. * @(#)AndQueryExp.java 4.19 04/02/10
  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 conjunctions
  10. * of relational expressions.
  11. * @serial include
  12. *
  13. * @since 1.5
  14. */
  15. class AndQueryExp extends QueryEval implements QueryExp {
  16. /* Serial version */
  17. private static final long serialVersionUID = -1081892073854801359L;
  18. /**
  19. * @serial The first QueryExp of the conjunction
  20. */
  21. private QueryExp exp1;
  22. /**
  23. * @serial The second QueryExp of the conjunction
  24. */
  25. private QueryExp exp2;
  26. /**
  27. * Default constructor.
  28. */
  29. public AndQueryExp() {
  30. }
  31. /**
  32. * Creates a new AndQueryExp with q1 and q2 QueryExp.
  33. */
  34. public AndQueryExp(QueryExp q1, QueryExp q2) {
  35. exp1 = q1;
  36. exp2 = q2;
  37. }
  38. /**
  39. * Returns the left query expression.
  40. */
  41. public QueryExp getLeftExp() {
  42. return exp1;
  43. }
  44. /**
  45. * Returns the right query expression.
  46. */
  47. public QueryExp getRightExp() {
  48. return exp2;
  49. }
  50. /**
  51. * Applies the AndQueryExp on a MBean.
  52. *
  53. * @param name The name of the MBean on which the AndQueryExp will be applied.
  54. *
  55. * @return True if the query was successfully applied to the MBean, false otherwise.
  56. *
  57. *
  58. * @exception BadStringOperationException The string passed to the method is invalid.
  59. * @exception BadBinaryOpValueExpException The expression passed to the method is invalid.
  60. * @exception BadAttributeValueExpException The attribute value passed to the method is invalid.
  61. * @exception InvalidApplicationException An attempt has been made to apply a subquery expression to a
  62. * managed object or a qualified attribute expression to a managed object of the wrong class.
  63. */
  64. public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException,
  65. BadAttributeValueExpException, InvalidApplicationException {
  66. return exp1.apply(name) && exp2.apply(name);
  67. }
  68. /**
  69. * Returns a string representation of this AndQueryExp
  70. */
  71. public String toString() {
  72. return "(" + exp1 + ") and (" + exp2 + ")";
  73. }
  74. }