0N/A/*
2362N/A * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
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
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
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 *
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 *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.management;
0N/A
0N/A
0N/A/**
11N/A * <p>Constructs query object constraints.</p>
11N/A *
11N/A * <p>The MBean Server can be queried for MBeans that meet a particular
11N/A * condition, using its {@link MBeanServer#queryNames queryNames} or
11N/A * {@link MBeanServer#queryMBeans queryMBeans} method. The {@link QueryExp}
11N/A * parameter to the method can be any implementation of the interface
11N/A * {@code QueryExp}, but it is usually best to obtain the {@code QueryExp}
11N/A * value by calling the static methods in this class. This is particularly
11N/A * true when querying a remote MBean Server: a custom implementation of the
11N/A * {@code QueryExp} interface might not be present in the remote MBean Server,
11N/A * but the methods in this class return only standard classes that are
11N/A * part of the JMX implementation.</p>
11N/A *
11N/A * <p>As an example, suppose you wanted to find all MBeans where the {@code
11N/A * Enabled} attribute is {@code true} and the {@code Owner} attribute is {@code
11N/A * "Duke"}. Here is how you could construct the appropriate {@code QueryExp} by
11N/A * chaining together method calls:</p>
11N/A *
11N/A * <pre>
11N/A * QueryExp query =
11N/A * Query.and(Query.eq(Query.attr("Enabled"), Query.value(true)),
11N/A * Query.eq(Query.attr("Owner"), Query.value("Duke")));
11N/A * </pre>
11N/A *
0N/A * @since 1.5
0N/A */
0N/A public class Query extends Object {
0N/A
0N/A
0N/A /**
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 */
0N/A public static final int GT = 0;
0N/A
0N/A /**
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 */
0N/A public static final int LT = 1;
0N/A
0N/A /**
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 */
0N/A public static final int GE = 2;
0N/A
0N/A /**
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 */
0N/A public static final int LE = 3;
0N/A
0N/A /**
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 */
0N/A public static final int EQ = 4;
0N/A
0N/A
0N/A /**
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 */
0N/A public static final int PLUS = 0;
0N/A
0N/A /**
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 */
0N/A public static final int MINUS = 1;
0N/A
0N/A /**
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 */
0N/A public static final int TIMES = 2;
0N/A
0N/A /**
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 */
0N/A public static final int DIV = 3;
0N/A
0N/A
0N/A /**
0N/A * Basic constructor.
0N/A */
0N/A public Query() {
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Returns a query expression that is the conjunction of two other query
0N/A * expressions.
0N/A *
0N/A * @param q1 A query expression.
0N/A * @param q2 Another query expression.
0N/A *
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 * <a href="../../serialized-form.html#javax.management.AndQueryExp">
0N/A * javax.management.AndQueryExp</a>}.
0N/A */
0N/A public static QueryExp and(QueryExp q1, QueryExp q2) {
0N/A return new AndQueryExp(q1, q2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a query expression that is the disjunction of two other query
0N/A * expressions.
0N/A *
0N/A * @param q1 A query expression.
0N/A * @param q2 Another query expression.
0N/A *
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 * <a href="../../serialized-form.html#javax.management.OrQueryExp">
0N/A * javax.management.OrQueryExp</a>}.
0N/A */
0N/A public static QueryExp or(QueryExp q1, QueryExp q2) {
0N/A return new OrQueryExp(q1, q2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a query expression that represents a "greater than" constraint on
0N/A * two values.
0N/A *
0N/A * @param v1 A value expression.
0N/A * @param v2 Another value expression.
0N/A *
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 * href="../../serialized-form.html#javax.management.BinaryRelQueryExp">
0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal
0N/A * to {@link #GT}.
0N/A */
0N/A public static QueryExp gt(ValueExp v1, ValueExp v2) {
0N/A return new BinaryRelQueryExp(GT, v1, v2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a query expression that represents a "greater than or equal
0N/A * to" constraint on two values.
0N/A *
0N/A * @param v1 A value expression.
0N/A * @param v2 Another value expression.
0N/A *
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 * href="../../serialized-form.html#javax.management.BinaryRelQueryExp">
0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal
0N/A * to {@link #GE}.
0N/A */
0N/A public static QueryExp geq(ValueExp v1, ValueExp v2) {
0N/A return new BinaryRelQueryExp(GE, v1, v2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a query expression that represents a "less than or equal to"
0N/A * constraint on two values.
0N/A *
0N/A * @param v1 A value expression.
0N/A * @param v2 Another value expression.
0N/A *
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 * href="../../serialized-form.html#javax.management.BinaryRelQueryExp">
0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal
0N/A * to {@link #LE}.
0N/A */
0N/A public static QueryExp leq(ValueExp v1, ValueExp v2) {
0N/A return new BinaryRelQueryExp(LE, v1, v2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a query expression that represents a "less than" constraint on
0N/A * two values.
0N/A *
0N/A * @param v1 A value expression.
0N/A * @param v2 Another value expression.
0N/A *
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 * href="../../serialized-form.html#javax.management.BinaryRelQueryExp">
0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal
0N/A * to {@link #LT}.
0N/A */
0N/A public static QueryExp lt(ValueExp v1, ValueExp v2) {
0N/A return new BinaryRelQueryExp(LT, v1, v2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a query expression that represents an equality constraint on
0N/A * two values.
0N/A *
0N/A * @param v1 A value expression.
0N/A * @param v2 Another value expression.
0N/A *
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 * href="../../serialized-form.html#javax.management.BinaryRelQueryExp">
0N/A * javax.management.BinaryRelQueryExp</a>} with a {@code relOp} equal
0N/A * to {@link #EQ}.
0N/A */
0N/A public static QueryExp eq(ValueExp v1, ValueExp v2) {
0N/A return new BinaryRelQueryExp(EQ, v1, v2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a query expression that represents the constraint that one
0N/A * value is between two other values.
0N/A *
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 *
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 * href="../../serialized-form.html#javax.management.BetweenQueryExp">
0N/A * javax.management.BetweenQueryExp</a>}.
0N/A */
0N/A public static QueryExp between(ValueExp v1, ValueExp v2, ValueExp v3) {
0N/A return new BetweenQueryExp(v1, v2, v3);
0N/A }
0N/A
0N/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 *
0N/A * @param a An attribute expression
0N/A * @param s A string value expression representing a matching constraint
0N/A *
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 * href="../../serialized-form.html#javax.management.MatchQueryExp">
0N/A * javax.management.MatchQueryExp</a>}.
0N/A */
0N/A public static QueryExp match(AttributeValueExp a, StringValueExp s) {
0N/A return new MatchQueryExp(a, s);
0N/A }
0N/A
0N/A /**
11N/A * <p>Returns a new attribute expression. See {@link AttributeValueExp}
11N/A * for a detailed description of the semantics of the expression.</p>
0N/A *
1790N/A * <p>Evaluating this expression for a given
1790N/A * <code>objectName</code> includes performing {@link
1790N/A * MBeanServer#getAttribute MBeanServer.getAttribute(objectName,
1790N/A * name)}.</p>
1790N/A *
0N/A * @param name The name of the attribute.
0N/A *
11N/A * @return An attribute expression for the attribute named {@code name}.
0N/A */
0N/A public static AttributeValueExp attr(String name) {
0N/A return new AttributeValueExp(name);
0N/A }
0N/A
0N/A /**
0N/A * <p>Returns a new qualified attribute expression.</p>
0N/A *
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 * name)}.</p>
0N/A *
0N/A * @param className The name of the class possessing the attribute.
0N/A * @param name The name of the attribute.
0N/A *
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 * href="../../serialized-form.html#javax.management.QualifiedAttributeValueExp">
0N/A * javax.management.QualifiedAttributeValueExp</a>}.
0N/A */
0N/A public static AttributeValueExp attr(String className, String name) {
0N/A return new QualifiedAttributeValueExp(className, name);
0N/A }
0N/A
0N/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 *
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 *
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 * {@link <a
0N/A * href="../../serialized-form.html#javax.management.ClassAttributeValueExp">
0N/A * javax.management.ClassAttributeValueExp</a>}.
0N/A */
0N/A public static AttributeValueExp classattr() {
0N/A return new ClassAttributeValueExp();
0N/A }
0N/A
0N/A /**
0N/A * Returns a constraint that is the negation of its argument.
0N/A *
0N/A * @param queryExp The constraint to negate.
0N/A *
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 * href="../../serialized-form.html#javax.management.NotQueryExp">
0N/A * javax.management.NotQueryExp</a>}.
0N/A */
0N/A public static QueryExp not(QueryExp queryExp) {
0N/A return new NotQueryExp(queryExp);
0N/A }
0N/A
0N/A /**
0N/A * Returns an expression constraining a value to be one of an explicit list.
0N/A *
0N/A * @param val A value to be constrained.
0N/A * @param valueList An array of ValueExps.
0N/A *
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 * href="../../serialized-form.html#javax.management.InQueryExp">
0N/A * javax.management.InQueryExp</a>}.
0N/A */
0N/A public static QueryExp in(ValueExp val, ValueExp valueList[]) {
0N/A return new InQueryExp(val, valueList);
0N/A }
0N/A
0N/A /**
0N/A * Returns a new string expression.
0N/A *
0N/A * @param val The string value.
0N/A *
0N/A * @return A ValueExp object containing the string argument.
0N/A */
0N/A public static StringValueExp value(String val) {
0N/A return new StringValueExp(val);
0N/A }
0N/A
0N/A /**
0N/A * Returns a numeric value expression that can be used in any Query call
0N/A * that expects a ValueExp.
0N/A *
0N/A * @param val An instance of Number.
0N/A *
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 * href="../../serialized-form.html#javax.management.NumericValueExp">
0N/A * javax.management.NumericValueExp</a>}.
0N/A */
0N/A public static ValueExp value(Number val) {
0N/A return new NumericValueExp(val);
0N/A }
0N/A
0N/A /**
0N/A * Returns a numeric value expression that can be used in any Query call
0N/A * that expects a ValueExp.
0N/A *
0N/A * @param val An int value.
0N/A *
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 * href="../../serialized-form.html#javax.management.NumericValueExp">
0N/A * javax.management.NumericValueExp</a>}.
0N/A */
0N/A public static ValueExp value(int val) {
0N/A return new NumericValueExp((long) val);
0N/A }
0N/A
0N/A /**
0N/A * Returns a numeric value expression that can be used in any Query call
0N/A * that expects a ValueExp.
0N/A *
0N/A * @param val A long value.
0N/A *
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 * href="../../serialized-form.html#javax.management.NumericValueExp">
0N/A * javax.management.NumericValueExp</a>}.
0N/A */
0N/A public static ValueExp value(long val) {
0N/A return new NumericValueExp(val);
0N/A }
0N/A
0N/A /**
0N/A * Returns a numeric value expression that can be used in any Query call
0N/A * that expects a ValueExp.
0N/A *
0N/A * @param val A float value.
0N/A *
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 * href="../../serialized-form.html#javax.management.NumericValueExp">
0N/A * javax.management.NumericValueExp</a>}.
0N/A */
0N/A public static ValueExp value(float val) {
0N/A return new NumericValueExp((double) val);
0N/A }
0N/A
0N/A /**
0N/A * Returns a numeric value expression that can be used in any Query call
0N/A * that expects a ValueExp.
0N/A *
0N/A * @param val A double value.
0N/A *
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 * href="../../serialized-form.html#javax.management.NumericValueExp">
0N/A * javax.management.NumericValueExp</a>}.
0N/A */
0N/A public static ValueExp value(double val) {
0N/A return new NumericValueExp(val);
0N/A }
0N/A
0N/A /**
0N/A * Returns a boolean value expression that can be used in any Query call
0N/A * that expects a ValueExp.
0N/A *
0N/A * @param val A boolean value.
0N/A *
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 * href="../../serialized-form.html#javax.management.BooleanValueExp">
0N/A * javax.management.BooleanValueExp</a>}.
0N/A */
0N/A public static ValueExp value(boolean val) {
0N/A return new BooleanValueExp(val);
0N/A }
0N/A
0N/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 *
0N/A * @param value1 The first '+' operand.
0N/A * @param value2 The second '+' operand.
0N/A *
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 * href="../../serialized-form.html#javax.management.BinaryOpValueExp">
0N/A * javax.management.BinaryOpValueExp</a>} with an {@code op} equal to
0N/A * {@link #PLUS}.
0N/A */
0N/A public static ValueExp plus(ValueExp value1, ValueExp value2) {
0N/A return new BinaryOpValueExp(PLUS, value1, value2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a binary expression representing the product of two numeric values.
0N/A *
0N/A *
0N/A * @param value1 The first '*' operand.
0N/A * @param value2 The second '*' operand.
0N/A *
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 * class {@link <a
0N/A * href="../../serialized-form.html#javax.management.BinaryOpValueExp">
0N/A * javax.management.BinaryOpValueExp</a>} with an {@code op} equal to
0N/A * {@link #TIMES}.
0N/A */
0N/A public static ValueExp times(ValueExp value1,ValueExp value2) {
0N/A return new BinaryOpValueExp(TIMES, value1, value2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a binary expression representing the difference between two numeric
0N/A * values.
0N/A *
0N/A * @param value1 The first '-' operand.
0N/A * @param value2 The second '-' operand.
0N/A *
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 * href="../../serialized-form.html#javax.management.BinaryOpValueExp">
0N/A * javax.management.BinaryOpValueExp</a>} with an {@code op} equal to
0N/A * {@link #MINUS}.
0N/A */
0N/A public static ValueExp minus(ValueExp value1, ValueExp value2) {
0N/A return new BinaryOpValueExp(MINUS, value1, value2);
0N/A }
0N/A
0N/A /**
0N/A * Returns a binary expression representing the quotient of two numeric
0N/A * values.
0N/A *
0N/A * @param value1 The first '/' operand.
0N/A * @param value2 The second '/' operand.
0N/A *
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 * href="../../serialized-form.html#javax.management.BinaryOpValueExp">
0N/A * javax.management.BinaryOpValueExp</a>} with an {@code op} equal to
0N/A * {@link #DIV}.
0N/A */
0N/A public static ValueExp div(ValueExp value1, ValueExp value2) {
0N/A return new BinaryOpValueExp(DIV, value1, value2);
0N/A }
0N/A
0N/A /**
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 * value.
0N/A *
0N/A * @param a An attribute expression.
0N/A * @param s A string value expression representing the beginning of the
0N/A * string value.
0N/A *
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 * {@link <a
0N/A * href="../../serialized-form.html#javax.management.MatchQueryExp">
0N/A * javax.management.MatchQueryExp</a>}.
0N/A */
0N/A public static QueryExp initialSubString(AttributeValueExp a, StringValueExp s) {
0N/A return new MatchQueryExp(a,
0N/A new StringValueExp(escapeString(s.getValue()) + "*"));
0N/A }
0N/A
0N/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 * value.
0N/A *
0N/A * @param a An attribute expression.
0N/A * @param s A string value expression representing the substring.
0N/A *
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 * {@link <a
0N/A * href="../../serialized-form.html#javax.management.MatchQueryExp">
0N/A * javax.management.MatchQueryExp</a>}.
0N/A */
0N/A public static QueryExp anySubString(AttributeValueExp a, StringValueExp s) {
0N/A return new MatchQueryExp(a,
0N/A new StringValueExp("*" + escapeString(s.getValue()) + "*"));
0N/A }
0N/A
0N/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 * value.
0N/A *
0N/A * @param a An attribute expression.
0N/A * @param s A string value expression representing the end of the string
0N/A * value.
0N/A *
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 * {@link <a
0N/A * href="../../serialized-form.html#javax.management.MatchQueryExp">
0N/A * javax.management.MatchQueryExp</a>}.
0N/A */
0N/A public static QueryExp finalSubString(AttributeValueExp a, StringValueExp s) {
0N/A return new MatchQueryExp(a,
0N/A new StringValueExp("*" + escapeString(s.getValue())));
0N/A }
0N/A
0N/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>
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 *
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 * href="../../serialized-form.html#javax.management.InstanceOfQueryExp">
0N/A * javax.management.InstanceOfQueryExp</a>}.
0N/A * @since 1.6
0N/A */
0N/A public static QueryExp isInstanceOf(StringValueExp classNameValue) {
0N/A return new InstanceOfQueryExp(classNameValue);
0N/A }
0N/A
0N/A /**
0N/A * Utility method to escape strings used with
0N/A * Query.{initial|any|final}SubString() methods.
0N/A */
0N/A private static String escapeString(String s) {
0N/A if (s == null)
0N/A return null;
0N/A s = s.replace("\\", "\\\\");
0N/A s = s.replace("*", "\\*");
0N/A s = s.replace("?", "\\?");
0N/A s = s.replace("[", "\\[");
0N/A return s;
0N/A }
0N/A }