Query.java revision 0
196N/A * Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * <p>Constructs query object constraints. The static methods provided 0N/A * return query expressions that may be used in listing and 0N/A * enumerating MBeans. Individual constraint construction methods 0N/A * allow only appropriate types as arguments. Composition of calls can 0N/A * construct arbitrary nestings of constraints, as the following 0N/A * example illustrates:</p> 0N/A * QueryExp exp = Query.and(Query.gt(Query.attr("age"),Query.value(5)), 0N/A * Query.match(Query.attr("name"), 0N/A * Query.value("Smith"))); 0N/A * A code representing the {@link Query#gt} query. This is chiefly 0N/A * of interest for the serialized form of queries. 0N/A public static final int GT =
0;
0N/A * A code representing the {@link Query#lt} query. This is chiefly 0N/A * of interest for the serialized form of queries. 0N/A public static final int LT =
1;
0N/A * A code representing the {@link Query#geq} query. This is chiefly 0N/A * of interest for the serialized form of queries. 0N/A public static final int GE =
2;
0N/A * A code representing the {@link Query#leq} query. This is chiefly 0N/A * of interest for the serialized form of queries. 0N/A public static final int LE =
3;
0N/A * A code representing the {@link Query#eq} query. This is chiefly 0N/A * of interest for the serialized form of queries. 0N/A public static final int EQ =
4;
0N/A * A code representing the {@link Query#plus} expression. This 0N/A * is chiefly of interest for the serialized form of queries. 0N/A * A code representing the {@link Query#minus} expression. This 0N/A * is chiefly of interest for the serialized form of queries. 0N/A * A code representing the {@link Query#times} expression. This 0N/A * is chiefly of interest for the serialized form of queries. 0N/A * A code representing the {@link Query#div} expression. This is 0N/A * chiefly of interest for the serialized form of queries. 0N/A public static final int DIV =
3;
0N/A * Basic constructor. 0N/A * Returns a query expression that is the conjunction of two other query 0N/A * @param q1 A query expression. 0N/A * @param q2 Another query expression. 0N/A * @return The conjunction of the two arguments. The returned object 0N/A * will be serialized as an instance of the non-public class {@link 0N/A * javax.management.AndQueryExp</a>}. 0N/A * Returns a query expression that is the disjunction of two other query 0N/A * @param q1 A query expression. 0N/A * @param q2 Another query expression. 0N/A * @return The disjunction of the two arguments. The returned object 0N/A * will be serialized as an instance of the non-public class {@link 0N/A * javax.management.OrQueryExp</a>}. 0N/A * Returns a query expression that represents a "greater than" constraint on 0N/A * @param v1 A value expression. 0N/A * @param v2 Another value expression. 0N/A * @return A "greater than" constraint on the arguments. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal 0N/A * Returns a query expression that represents a "greater than or equal 0N/A * to" constraint on two values. 0N/A * @param v1 A value expression. 0N/A * @param v2 Another value expression. 0N/A * @return A "greater than or equal to" constraint on the 0N/A * arguments. The returned object will be serialized as an 0N/A * instance of the non-public class {@link <a 0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal 0N/A * Returns a query expression that represents a "less than or equal to" 0N/A * constraint on two values. 0N/A * @param v1 A value expression. 0N/A * @param v2 Another value expression. 0N/A * @return A "less than or equal to" constraint on the arguments. 0N/A * The returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal 0N/A * Returns a query expression that represents a "less than" constraint on 0N/A * @param v1 A value expression. 0N/A * @param v2 Another value expression. 0N/A * @return A "less than" constraint on the arguments. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal 0N/A * Returns a query expression that represents an equality constraint on 0N/A * @param v1 A value expression. 0N/A * @param v2 Another value expression. 0N/A * @return A "equal to" constraint on the arguments. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal 0N/A * Returns a query expression that represents the constraint that one 0N/A * value is between two other values. 0N/A * @param v1 A value expression that is "between" v2 and v3. 0N/A * @param v2 Value expression that represents a boundary of the constraint. 0N/A * @param v3 Value expression that represents a boundary of the constraint. 0N/A * @return The constraint that v1 lies between v2 and v3. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.BetweenQueryExp</a>}. 0N/A * Returns a query expression that represents a matching constraint on 0N/A * a string argument. The matching syntax is consistent with file globbing: 0N/A * supports "<code>?</code>", "<code>*</code>", "<code>[</code>", 0N/A * each of which may be escaped with "<code>\</code>"; 0N/A * character classes may use "<code>!</code>" for negation and 0N/A * "<code>-</code>" for range. 0N/A * (<code>*</code> for any character sequence, 0N/A * <code>?</code> for a single arbitrary character, 0N/A * <code>[...]</code> for a character sequence). 0N/A * For example: <code>a*b?c</code> would match a string starting 0N/A * with the character <code>a</code>, followed 0N/A * by any number of characters, followed by a <code>b</code>, 0N/A * any single character, and a <code>c</code>. 0N/A * @param a An attribute expression 0N/A * @param s A string value expression representing a matching constraint 0N/A * @return A query expression that represents the matching 0N/A * constraint on the string argument. The returned object will 0N/A * be serialized as an instance of the non-public class {@link <a 0N/A * javax.management.MatchQueryExp</a>}. 0N/A * <p>Returns a new attribute expression.</p> 0N/A * <p>Evaluating this expression for a given 0N/A * <code>objectName</code> includes performing {@link 0N/A * MBeanServer#getAttribute MBeanServer.getAttribute(objectName, 0N/A * @param name The name of the attribute. 0N/A * @return An attribute expression for the attribute named name. 0N/A * <p>Returns a new qualified attribute expression.</p> 0N/A * <p>Evaluating this expression for a given 0N/A * <code>objectName</code> includes performing {@link 0N/A * MBeanServer#getObjectInstance 0N/A * MBeanServer.getObjectInstance(objectName)} and {@link 0N/A * MBeanServer#getAttribute MBeanServer.getAttribute(objectName, 0N/A * @param className The name of the class possessing the attribute. 0N/A * @param name The name of the attribute. 0N/A * @return An attribute expression for the attribute named name. 0N/A * The returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.QualifiedAttributeValueExp</a>}. 0N/A * <p>Returns a new class attribute expression which can be used in any 0N/A * Query call that expects a ValueExp.</p> 0N/A * <p>Evaluating this expression for a given 0N/A * <code>objectName</code> includes performing {@link 0N/A * MBeanServer#getObjectInstance 0N/A * MBeanServer.getObjectInstance(objectName)}.</p> 0N/A * @return A class attribute expression. The returned object 0N/A * will be serialized as an instance of the non-public class 0N/A * javax.management.ClassAttributeValueExp</a>}. 0N/A * Returns a constraint that is the negation of its argument. 0N/A * @param queryExp The constraint to negate. 0N/A * @return A negated constraint. The returned object will be 0N/A * serialized as an instance of the non-public class {@link <a 0N/A * javax.management.NotQueryExp</a>}. 0N/A * Returns an expression constraining a value to be one of an explicit list. 0N/A * @param val A value to be constrained. 0N/A * @param valueList An array of ValueExps. 0N/A * @return A QueryExp that represents the constraint. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.InQueryExp</a>}. 0N/A * Returns a new string expression. 0N/A * @param val The string value. 0N/A * @return A ValueExp object containing the string argument. 0N/A * Returns a numeric value expression that can be used in any Query call 0N/A * that expects a ValueExp. 0N/A * @param val An instance of Number. 0N/A * @return A ValueExp object containing the argument. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.NumericValueExp</a>}. 0N/A * Returns a numeric value expression that can be used in any Query call 0N/A * that expects a ValueExp. 0N/A * @param val An int value. 0N/A * @return A ValueExp object containing the argument. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.NumericValueExp</a>}. 0N/A * Returns a numeric value expression that can be used in any Query call 0N/A * that expects a ValueExp. 0N/A * @param val A long value. 0N/A * @return A ValueExp object containing the argument. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.NumericValueExp</a>}. 0N/A * Returns a numeric value expression that can be used in any Query call 0N/A * that expects a ValueExp. 0N/A * @param val A float value. 0N/A * @return A ValueExp object containing the argument. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.NumericValueExp</a>}. 0N/A * Returns a numeric value expression that can be used in any Query call 0N/A * that expects a ValueExp. 0N/A * @param val A double value. 0N/A * @return A ValueExp object containing the argument. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.NumericValueExp</a>}. 0N/A * Returns a boolean value expression that can be used in any Query call 0N/A * that expects a ValueExp. 0N/A * @param val A boolean value. 0N/A * @return A ValueExp object containing the argument. The 0N/A * returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.BooleanValueExp</a>}. 0N/A * Returns a binary expression representing the sum of two numeric values, 0N/A * or the concatenation of two string values. 0N/A * @param value1 The first '+' operand. 0N/A * @param value2 The second '+' operand. 0N/A * @return A ValueExp representing the sum or concatenation of 0N/A * the two arguments. The returned object will be serialized as 0N/A * an instance of the non-public class {@link <a 0N/A * javax.management.BinaryOpValueExp</a>} with an {@code op} equal to 0N/A * Returns a binary expression representing the product of two numeric values. 0N/A * @param value1 The first '*' operand. 0N/A * @param value2 The second '*' operand. 0N/A * @return A ValueExp representing the product. The returned 0N/A * object will be serialized as an instance of the non-public 0N/A * javax.management.BinaryOpValueExp</a>} with an {@code op} equal to 0N/A * Returns a binary expression representing the difference between two numeric 0N/A * @param value1 The first '-' operand. 0N/A * @param value2 The second '-' operand. 0N/A * @return A ValueExp representing the difference between two 0N/A * arguments. The returned object will be serialized as an 0N/A * instance of the non-public class {@link <a 0N/A * javax.management.BinaryOpValueExp</a>} with an {@code op} equal to 0N/A * Returns a binary expression representing the quotient of two numeric 0N/A * @param value1 The first '/' operand. 0N/A * @param value2 The second '/' operand. 0N/A * @return A ValueExp representing the quotient of two arguments. 0N/A * The returned object will be serialized as an instance of the 0N/A * non-public class {@link <a 0N/A * javax.management.BinaryOpValueExp</a>} with an {@code op} equal to 0N/A * Returns a query expression that represents a matching constraint on 0N/A * a string argument. The value must start with the given literal string 0N/A * @param a An attribute expression. 0N/A * @param s A string value expression representing the beginning of the 0N/A * @return The constraint that a matches s. The returned object 0N/A * will be serialized as an instance of the non-public class 0N/A * javax.management.MatchQueryExp</a>}. 0N/A * Returns a query expression that represents a matching constraint on 0N/A * a string argument. The value must contain the given literal string 0N/A * @param a An attribute expression. 0N/A * @param s A string value expression representing the substring. 0N/A * @return The constraint that a matches s. The returned object 0N/A * will be serialized as an instance of the non-public class 0N/A * javax.management.MatchQueryExp</a>}. 0N/A * Returns a query expression that represents a matching constraint on 0N/A * a string argument. The value must end with the given literal string 0N/A * @param a An attribute expression. 0N/A * @param s A string value expression representing the end of the string 0N/A * @return The constraint that a matches s. The returned object 0N/A * will be serialized as an instance of the non-public class 0N/A * javax.management.MatchQueryExp</a>}. 0N/A * Returns a query expression that represents an inheritance constraint 0N/A * on an MBean class. 0N/A * <p>Example: to find MBeans that are instances of 0N/A * {@link NotificationBroadcaster}, use 0N/A * {@code Query.isInstanceOf(Query.value(NotificationBroadcaster.class.getName()))}. 0N/A * <p>Evaluating this expression for a given 0N/A * <code>objectName</code> includes performing {@link 0N/A * MBeanServer#isInstanceOf MBeanServer.isInstanceOf(objectName, 0N/A * ((StringValueExp)classNameValue.apply(objectName)).getValue()}.</p> 0N/A * @param classNameValue The {@link StringValueExp} returning the name 0N/A * of the class of which selected MBeans should be instances. 0N/A * @return a query expression that represents an inheritance 0N/A * constraint on an MBean class. The returned object will be 0N/A * serialized as an instance of the non-public class {@link <a 0N/A * javax.management.InstanceOfQueryExp</a>}. 0N/A * Utility method to escape strings used with 0N/A * Query.{initial|any|final}SubString() methods.