01: /*
02: * JBoss, Home of Professional Open Source.
03: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
04: * as indicated by the @author tags. See the copyright.txt file in the
05: * distribution for a full listing of individual contributors.
06: *
07: * This is free software; you can redistribute it and/or modify it
08: * under the terms of the GNU Lesser General Public License as
09: * published by the Free Software Foundation; either version 2.1 of
10: * the License, or (at your option) any later version.
11: *
12: * This software is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this software; if not, write to the Free
19: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21: */
22: package javax.management;
23:
24: /**
25: * An OR Query Expression.<p>
26: *
27: * Returns true when either expression is true.
28: *
29: * <p><b>Revisions:</b>
30: * <p><b>20020314 Adrian Brock:</b>
31: * <ul>
32: * <li>Fix the human readable expression
33: * </ul>
34: * <p><b>20020317 Adrian Brock:</b>
35: * <ul>
36: * <li>Make queries thread safe
37: * </ul>
38: *
39: * @author <a href="mailto:Adrian.Brock@HappeningTimes.com">Adrian Brock</a>.
40: * @version $Revision: 57200 $
41: */
42: class OrQueryExp extends QueryEval implements QueryExp {
43: // Constants ---------------------------------------------------
44:
45: private static final long serialVersionUID = 2962973084421716523L;
46:
47: // Attributes --------------------------------------------------
48:
49: /**
50: * The first query expression
51: */
52: private QueryExp exp1;
53:
54: /**
55: * The second query expression
56: */
57: private QueryExp exp2;
58:
59: // Constructors ------------------------------------------------
60:
61: public OrQueryExp() {
62: }
63:
64: /**
65: * Create a new OR query Expression
66: *
67: * @param first the first query expression
68: * @param second the second query expression
69: */
70: public OrQueryExp(QueryExp first, QueryExp second) {
71: this .exp1 = first;
72: this .exp2 = second;
73: }
74:
75: // Public ------------------------------------------------------
76:
77: // QueryExp implementation -------------------------------------
78:
79: public boolean apply(ObjectName name)
80: throws BadStringOperationException,
81: BadBinaryOpValueExpException,
82: BadAttributeValueExpException, InvalidApplicationException {
83: return exp1.apply(name) || exp2.apply(name);
84: }
85:
86: // Object overrides --------------------------------------------
87:
88: public String toString() {
89: return new String("(" + exp1.toString() + ") || ("
90: + exp2.toString())
91: + ")";
92: }
93:
94: }
|