1700N/A/*
1700N/A * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
1700N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1700N/A *
1700N/A * This code is free software; you can redistribute it and/or modify it
1700N/A * under the terms of the GNU General Public License version 2 only, as
1700N/A * published by the Free Software Foundation. Oracle designates this
1700N/A * particular file as subject to the "Classpath" exception as provided
1700N/A * by Oracle in the LICENSE file that accompanied this code.
1700N/A *
1700N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1700N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1700N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1700N/A * version 2 for more details (a copy is included in the LICENSE file that
1700N/A * accompanied this code).
1700N/A *
1700N/A * You should have received a copy of the GNU General Public License version
1700N/A * 2 along with this work; if not, write to the Free Software Foundation,
2362N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2362N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1700N/A * or visit www.oracle.com if you need additional information or have any
1700N/A * questions.
1700N/A */
1700N/A
1700N/Apackage javax.management;
1700N/A
1700N/A
1700N/A/**
1700N/A * This class is used by the query building mechanism to represent conjunctions
1700N/A * of relational expressions.
1700N/A * @serial include
1700N/A *
1700N/A * @since 1.5
1700N/A */
1700N/Aclass AndQueryExp extends QueryEval implements QueryExp {
1700N/A
1700N/A /* Serial version */
1700N/A private static final long serialVersionUID = -1081892073854801359L;
1700N/A
1700N/A /**
1700N/A * @serial The first QueryExp of the conjunction
1700N/A */
1700N/A private QueryExp exp1;
1700N/A
1700N/A /**
1700N/A * @serial The second QueryExp of the conjunction
1700N/A */
1700N/A private QueryExp exp2;
1700N/A
1700N/A
1700N/A /**
1700N/A * Default constructor.
1700N/A */
1700N/A public AndQueryExp() {
1700N/A }
1700N/A
1700N/A /**
1700N/A * Creates a new AndQueryExp with q1 and q2 QueryExp.
1700N/A */
1700N/A public AndQueryExp(QueryExp q1, QueryExp q2) {
1700N/A exp1 = q1;
1700N/A exp2 = q2;
1700N/A }
1700N/A
1700N/A
1700N/A /**
1700N/A * Returns the left query expression.
1700N/A */
1700N/A public QueryExp getLeftExp() {
1700N/A return exp1;
1700N/A }
1700N/A
1700N/A /**
1700N/A * Returns the right query expression.
1700N/A */
1700N/A public QueryExp getRightExp() {
1700N/A return exp2;
1700N/A }
1700N/A
/**
* Applies the AndQueryExp on a MBean.
*
* @param name The name of the MBean on which the AndQueryExp will be applied.
*
* @return True if the query was successfully applied to the MBean, false otherwise.
*
*
* @exception BadStringOperationException The string passed to the method is invalid.
* @exception BadBinaryOpValueExpException The expression passed to the method is invalid.
* @exception BadAttributeValueExpException The attribute value passed to the method is invalid.
* @exception InvalidApplicationException An attempt has been made to apply a subquery expression to a
* managed object or a qualified attribute expression to a managed object of the wrong class.
*/
public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException,
BadAttributeValueExpException, InvalidApplicationException {
return exp1.apply(name) && exp2.apply(name);
}
/**
* Returns a string representation of this AndQueryExp
*/
@Override
public String toString() {
return "(" + exp1 + ") and (" + exp2 + ")";
}
}