1. /*
  2. * @(#)OrQueryExp.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
  10. * disjunctions of relational expressions.
  11. * @serial include
  12. *
  13. * @since 1.5
  14. */
  15. class OrQueryExp extends QueryEval implements QueryExp {
  16. /* Serial version */
  17. private static final long serialVersionUID = 2962973084421716523L;
  18. /**
  19. * @serial The left query expression
  20. */
  21. private QueryExp exp1;
  22. /**
  23. * @serial The right query expression
  24. */
  25. private QueryExp exp2;
  26. /**
  27. * Basic Constructor.
  28. */
  29. public OrQueryExp() {
  30. }
  31. /**
  32. * Creates a new OrQueryExp with the specified ValueExps
  33. */
  34. public OrQueryExp(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 OrQueryExp on a MBean.
  52. *
  53. * @param name The name of the MBean on which the OrQueryExp 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. */
  62. public boolean apply(ObjectName name) throws BadStringOperationException,
  63. BadBinaryOpValueExpException, BadAttributeValueExpException,
  64. InvalidApplicationException {
  65. return exp1.apply(name) || exp2.apply(name);
  66. }
  67. /**
  68. * Returns a string representation of this AndQueryExp
  69. */
  70. public String toString() {
  71. return "(" + exp1 + ") or (" + exp2 + ")";
  72. }
  73. }