Path: blob/master/src/java.management/share/classes/javax/management/AndQueryExp.java
41155 views
/*1* Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.management;262728/**29* This class is used by the query building mechanism to represent conjunctions30* of relational expressions.31* @serial include32*33* @since 1.534*/35class AndQueryExp extends QueryEval implements QueryExp {3637/* Serial version */38private static final long serialVersionUID = -1081892073854801359L;3940/**41* @serial The first QueryExp of the conjunction42*/43private QueryExp exp1;4445/**46* @serial The second QueryExp of the conjunction47*/48private QueryExp exp2;495051/**52* Default constructor.53*/54public AndQueryExp() {55}5657/**58* Creates a new AndQueryExp with q1 and q2 QueryExp.59*/60public AndQueryExp(QueryExp q1, QueryExp q2) {61exp1 = q1;62exp2 = q2;63}646566/**67* Returns the left query expression.68*/69public QueryExp getLeftExp() {70return exp1;71}7273/**74* Returns the right query expression.75*/76public QueryExp getRightExp() {77return exp2;78}7980/**81* Applies the AndQueryExp on a MBean.82*83* @param name The name of the MBean on which the AndQueryExp will be applied.84*85* @return True if the query was successfully applied to the MBean, false otherwise.86*87*88* @exception BadStringOperationException The string passed to the method is invalid.89* @exception BadBinaryOpValueExpException The expression passed to the method is invalid.90* @exception BadAttributeValueExpException The attribute value passed to the method is invalid.91* @exception InvalidApplicationException An attempt has been made to apply a subquery expression to a92* managed object or a qualified attribute expression to a managed object of the wrong class.93*/94public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException,95BadAttributeValueExpException, InvalidApplicationException {96return exp1.apply(name) && exp2.apply(name);97}9899/**100* Returns a string representation of this AndQueryExp101*/102@Override103public String toString() {104return "(" + exp1 + ") and (" + exp2 + ")";105}106}107108109