NotQueryExp.java revision 11
1N/A/*
1N/A * Copyright 1999-2003 Sun Microsystems, Inc. All Rights Reserved.
1N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1N/A *
1N/A * This code is free software; you can redistribute it and/or modify it
1N/A * under the terms of the GNU General Public License version 2 only, as
1N/A * published by the Free Software Foundation. Sun designates this
1N/A * particular file as subject to the "Classpath" exception as provided
1N/A * by Sun in the LICENSE file that accompanied this code.
1N/A *
1N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1N/A * version 2 for more details (a copy is included in the LICENSE file that
1N/A * accompanied this code).
1N/A *
1N/A * You should have received a copy of the GNU General Public License version
1N/A * 2 along with this work; if not, write to the Free Software Foundation,
1N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1N/A *
1N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
1N/A * CA 95054 USA or visit www.sun.com if you need additional information or
1N/A * have any questions.
1N/A */
1N/A
1N/Apackage javax.management;
1N/A
1N/A
1N/A/**
1N/A * This class is used by the query-building mechanism to represent negations
1N/A * of relational expressions.
1N/A * @serial include
1N/A *
1N/A * @since 1.5
1N/A */
1N/Aclass NotQueryExp extends QueryEval implements QueryExp {
1N/A
1N/A
1N/A /* Serial version */
1N/A private static final long serialVersionUID = 5269643775896723397L;
1N/A
1N/A /**
1N/A * @serial The negated {@link QueryExp}
1N/A */
1N/A private QueryExp exp;
1N/A
1N/A
1N/A /**
1N/A * Basic Constructor.
1N/A */
1N/A public NotQueryExp() {
1N/A }
1N/A
1N/A /**
1N/A * Creates a new NotQueryExp for negating the specified QueryExp.
1N/A */
1N/A public NotQueryExp(QueryExp q) {
1N/A exp = q;
1N/A }
1N/A
1N/A
1N/A /**
1N/A * Returns the negated query expression of the query.
*/
public QueryExp getNegatedExp() {
return exp;
}
/**
* Applies the NotQueryExp on a MBean.
*
* @param name The name of the MBean on which the NotQueryExp will be applied.
*
* @return True if the query was successfully applied to the MBean, false otherwise.
*
* @exception BadStringOperationException
* @exception BadBinaryOpValueExpException
* @exception BadAttributeValueExpException
* @exception InvalidApplicationException
*/
public boolean apply(ObjectName name) throws BadStringOperationException, BadBinaryOpValueExpException,
BadAttributeValueExpException, InvalidApplicationException {
return exp.apply(name) == false;
}
/**
* Returns the string representing the object.
*/
@Override
public String toString() {
return "not (" + exp + ")";
}
@Override
String toQueryString() {
return "not (" + Query.toString(exp) + ")";
}
}