KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > management > AndQueryExp


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

18 class AndQueryExp extends QueryEval JavaDoc implements QueryExp JavaDoc {
19    
20     /* Serial version */
21     private static final long serialVersionUID = -1081892073854801359L;
22
23     /**
24      * @serial The first QueryExp of the conjunction
25      */

26     private QueryExp JavaDoc exp1;
27
28     /**
29      * @serial The second QueryExp of the conjunction
30      */

31     private QueryExp JavaDoc exp2;
32
33
34     /**
35      * Default constructor.
36      */

37     public AndQueryExp() {
38     }
39
40     /**
41      * Creates a new AndQueryExp with q1 and q2 QueryExp.
42      */

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

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

59     public QueryExp JavaDoc getRightExp() {
60     return exp2;
61     }
62
63     /**
64      * Applies the AndQueryExp on a MBean.
65      *
66      * @param name The name of the MBean on which the AndQueryExp will be applied.
67      *
68      * @return True if the query was successfully applied to the MBean, false otherwise.
69      *
70      *
71      * @exception BadStringOperationException The string passed to the method is invalid.
72      * @exception BadBinaryOpValueExpException The expression passed to the method is invalid.
73      * @exception BadAttributeValueExpException The attribute value passed to the method is invalid.
74      * @exception InvalidApplicationException An attempt has been made to apply a subquery expression to a
75      * managed object or a qualified attribute expression to a managed object of the wrong class.
76      */

77     public boolean apply(ObjectName JavaDoc name) throws BadStringOperationException JavaDoc, BadBinaryOpValueExpException JavaDoc,
78     BadAttributeValueExpException JavaDoc, 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 + ") and (" + exp2 + ")";
87    }
88    
89  }
90
91
Popular Tags