KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > OrQueryExp


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
8 package javax.management;
9
10
11
12 /**
13  * This class is used by the query-building mechanism to represent
14  * disjunctions of relational expressions.
15  * @serial include
16  *
17  * @since 1.5
18  */

19 class OrQueryExp extends QueryEval JavaDoc implements QueryExp JavaDoc {
20
21     /* Serial version */
22     private static final long serialVersionUID = 2962973084421716523L;
23
24     /**
25      * @serial The left query expression
26      */

27     private QueryExp JavaDoc exp1;
28
29     /**
30      * @serial The right query expression
31      */

32     private QueryExp JavaDoc exp2;
33
34     
35     /**
36      * Basic Constructor.
37      */

38     public OrQueryExp() {
39     }
40     
41     /**
42      * Creates a new OrQueryExp with the specified ValueExps
43      */

44     public OrQueryExp(QueryExp JavaDoc q1, QueryExp JavaDoc q2) {
45     exp1 = q1;
46     exp2 = q2;
47     }
48
49
50     /**
51      * Returns the left query expression.
52      */

53     public QueryExp JavaDoc getLeftExp() {
54     return exp1;
55     }
56
57     /**
58      * Returns the right query expression.
59      */

60     public QueryExp JavaDoc getRightExp() {
61     return exp2;
62     }
63       
64     /**
65      * Applies the OrQueryExp on a MBean.
66      *
67      * @param name The name of the MBean on which the OrQueryExp will be applied.
68      *
69      * @return True if the query was successfully applied to the MBean, false otherwise.
70      *
71      *
72      * @exception BadStringOperationException The string passed to the method is invalid.
73      * @exception BadBinaryOpValueExpException The expression passed to the method is invalid.
74      * @exception BadAttributeValueExpException The attribute value passed to the method is invalid.
75      */

76     public boolean apply(ObjectName JavaDoc name) throws BadStringOperationException JavaDoc,
77     BadBinaryOpValueExpException JavaDoc, BadAttributeValueExpException JavaDoc,
78     InvalidApplicationException JavaDoc {
79     return exp1.apply(name) || exp2.apply(name);
80     }
81     
82     /**
83      * Returns a string representation of this AndQueryExp
84      */

85     public String JavaDoc toString() {
86     return "(" + exp1 + ") or (" + exp2 + ")";
87     }
88 }
89
Popular Tags