javax.management

Class Query


public class Query
extends Object

Provides static methods for constructing queries. Queries may be used to list and enumerate management beans, via the MBeanServer. By using the methods in this class, complex queries can be created from their more basic components.
Since:
1.5

Field Summary

static int
DIV
A code representing the
static int
EQ
A code representing the
static int
GE
A code representing the
static int
GT
A code representing the
static int
LE
A code representing the
static int
LT
A code representing the
static int
MINUS
A code representing the
static int
PLUS
A code representing the
static int
TIMES
A code representing the

Method Summary

static QueryExp
and(QueryExp q1, QueryExp q2)
Returns a query expression formed from the conjunction of the two supplied query expressions.
static QueryExp
anySubString(AttributeValueExp attrib, StringValueExp string)
Returns a query expression which checks that an attribute value held by the specified AttributeValueExp contains the string specified by the given StringValueExp.
static AttributeValueExp
attr(String name)
Returns a value expression for the value of the named attribute.
static AttributeValueExp
attr(String className, String name)
Returns a value expression for the value of the named attribute from the specified class.
static QueryExp
between(ValueExp v1, ValueExp v2, ValueExp v3)
Returns a query expression representing the constraint that the value, v1, lies between v2 and v3.
static AttributeValueExp
classattr()
Returns a value expression which evaluates to the name of the class of the bean when applied.
static ValueExp
div(ValueExp v1, ValueExp v2)
Returns a value expression which evaluates to the result of dividing v1 by v2.
static QueryExp
eq(ValueExp v1, ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 for equality.
static QueryExp
finalSubString(AttributeValueExp attrib, StringValueExp string)
Returns a query expression which checks that an attribute value held by the specified AttributeValueExp ends with the string specified by the given StringValueExp.
static QueryExp
geq(ValueExp v1, ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 to see if v1 is greater than or equal to v2.
static QueryExp
gt(ValueExp v1, ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 to see if v1 is greater than v2.
static QueryExp
in(ValueExp v, ValueExp[] vlist)
Returns a query expression representing the constraint that the value, v, is a member of the list, vlist.
static QueryExp
initialSubString(AttributeValueExp attrib, StringValueExp string)
Returns a query expression which checks that an attribute value held by the specified AttributeValueExp starts with the string specified by the given StringValueExp.
static QueryExp
isInstanceOf(StringValueExp className)
Returns a query expression which checks that a bean is an instance of the class specified by the given StringValueExp.
static QueryExp
leq(ValueExp v1, ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 to see if v1 is less than or equal to v2.
static QueryExp
lt(ValueExp v1, ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 to see if v1 is less than v2.
static QueryExp
match(AttributeValueExp attrib, StringValueExp string)
Returns a query expression which checks that an attribute value matches the pattern specified by the given StringValueExp.
static ValueExp
minus(ValueExp v1, ValueExp v2)
Returns a value expression which evaluates to the result of subtracting v2 from v1.
static QueryExp
not(QueryExp q)
Returns a query expression representing the negation of the specified query expression.
static QueryExp
or(QueryExp q1, QueryExp q2)
Returns a query expression formed from the disjunction of the two supplied query expressions.
static ValueExp
plus(ValueExp v1, ValueExp v2)
Returns a value expression which evaluates to the result of adding v1 to v2.
static ValueExp
times(ValueExp v1, ValueExp v2)
Returns a value expression which evaluates to the result of multiplying v1 by v2.
static ValueExp
value(boolean val)
Returns a value expression wrapping the specified value.
static ValueExp
value(double val)
Returns a value expression wrapping the specified value.
static ValueExp
value(float val)
Returns a value expression wrapping the specified value.
static ValueExp
value(int val)
Returns a value expression wrapping the specified value.
static ValueExp
value(Number val)
Returns a value expression wrapping the specified value.
static StringValueExp
value(String val)
Returns a value expression wrapping the specified string.
static ValueExp
value(long val)
Returns a value expression wrapping the specified value.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

DIV

public static final int DIV
A code representing the #div(ValueExp, ValueExp) query to be used in serialization.
Field Value:
3

EQ

public static final int EQ
A code representing the #eq(ValueExp, ValueExp) query to be used in serialization.
Field Value:
4

GE

public static final int GE
A code representing the #ge(ValueExp, ValueExp) query to be used in serialization.
Field Value:
2

GT

public static final int GT
A code representing the #gt(ValueExp, ValueExp) query to be used in serialization.
Field Value:
0

LE

public static final int LE
A code representing the #le(ValueExp, ValueExp) query to be used in serialization.
Field Value:
3

LT

public static final int LT
A code representing the #lt(ValueExp, ValueExp) query to be used in serialization.
Field Value:
1

MINUS

public static final int MINUS
A code representing the #minus(ValueExp, ValueExp) query to be used in serialization.
Field Value:
1

PLUS

public static final int PLUS
A code representing the #plus(ValueExp, ValueExp) query to be used in serialization.
Field Value:
0

TIMES

public static final int TIMES
A code representing the #times(ValueExp, ValueExp) query to be used in serialization.
Field Value:
2

Method Details

and

public static QueryExp and(QueryExp q1,
                           QueryExp q2)
Returns a query expression formed from the conjunction of the two supplied query expressions.
Parameters:
q1 - the first query expression.
q2 - the second query expression.
Returns:
a query expression representing q1 && q2. This will be serialized as the non-public class AndQueryExp.

anySubString

public static QueryExp anySubString(AttributeValueExp attrib,
                                    StringValueExp string)
Returns a query expression which checks that an attribute value held by the specified AttributeValueExp contains the string specified by the given StringValueExp.
Parameters:
attrib - the attribute to match.
string - the substring to find.
Returns:
a query expression representing attrib.matches("*" + string + "*"). This will be serialized as the non-public class MatchQueryExp.

attr

public static AttributeValueExp attr(String name)
Returns a value expression for the value of the named attribute. Evaluating this using an ObjectName involves an underlying call to MBeanServer.getAttribute(ObjectName,String).
Parameters:
name - the name of the attribute.
Returns:
a value expression which returns the value of the named attribute when applied.

attr

public static AttributeValueExp attr(String className,
                                     String name)
Returns a value expression for the value of the named attribute from the specified class. Evaluating this using an ObjectName involves an underlying call to both MBeanServer.getObjectInstance(ObjectName) and MBeanServer.getAttribute(ObjectName,String).
Parameters:
className - the class containing the attribute.
name - the name of the attribute.
Returns:
a value expression which returns the value of the named attribute when applied. This will be serialized as the non-public class QualifiedAttributeValueExp.

between

public static QueryExp between(ValueExp v1,
                               ValueExp v2,
                               ValueExp v3)
Returns a query expression representing the constraint that the value, v1, lies between v2 and v3.
Parameters:
v1 - the value to compare against the boundaries.
v2 - the lower boundary.
v3 - the upper boundary.
Returns:
a query expression representing a comparison of v1 against v2 and v3. It returns true if v2 <= v1 <= v3. This will be serialized as the non-public class BetweenQueryExp.

classattr

public static AttributeValueExp classattr()
Returns a value expression which evaluates to the name of the class of the bean when applied. Associating the expression with an ObjectName involves an underlying call to both MBeanServer.getObjectInstance(ObjectName) to obtain this information.
Returns:
a value expression which returns the class name of the bean to which it is applied. This will be serialized as the non-public class ClassAttributeValueExp.

div

public static ValueExp div(ValueExp v1,
                           ValueExp v2)
Returns a value expression which evaluates to the result of dividing v1 by v2.
Parameters:
v1 - the left-hand operand.
v2 - the right-hand operand.
Returns:
a value expression which returns the result of the division when applied. This will be serialized as the non-public class BinaryOpValueExp with an operation of DIV.

eq

public static QueryExp eq(ValueExp v1,
                          ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 for equality.
Parameters:
v1 - the left-hand operand.
v2 - the right-hand operand.
Returns:
a value expression which returns the result of the comparison when applied. This will be serialized as the non-public class BinaryRelQueryExp with an operation of EQ.

finalSubString

public static QueryExp finalSubString(AttributeValueExp attrib,
                                      StringValueExp string)
Returns a query expression which checks that an attribute value held by the specified AttributeValueExp ends with the string specified by the given StringValueExp.
Parameters:
attrib - the attribute to match.
string - the substring to find.
Returns:
a query expression representing attrib.matches("*" + string). This will be serialized as the non-public class MatchQueryExp.

geq

public static QueryExp geq(ValueExp v1,
                           ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 to see if v1 is greater than or equal to v2.
Parameters:
v1 - the left-hand operand.
v2 - the right-hand operand.
Returns:
a value expression which returns the result of the comparison when applied. This will be serialized as the non-public class BinaryRelQueryExp with an operation of GE.

gt

public static QueryExp gt(ValueExp v1,
                          ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 to see if v1 is greater than v2.
Parameters:
v1 - the left-hand operand.
v2 - the right-hand operand.
Returns:
a value expression which returns the result of the comparison when applied. This will be serialized as the non-public class BinaryRelQueryExp with an operation of GT.

in

public static QueryExp in(ValueExp v,
                          ValueExp[] vlist)
Returns a query expression representing the constraint that the value, v, is a member of the list, vlist.
Parameters:
v - the value to look for in the list.
vlist - the list of allowed values.
Returns:
a query expression representing a membership check of v against the list, vlist. This will be serialized as the non-public class InQueryExp.

initialSubString

public static QueryExp initialSubString(AttributeValueExp attrib,
                                        StringValueExp string)
Returns a query expression which checks that an attribute value held by the specified AttributeValueExp starts with the string specified by the given StringValueExp.
Parameters:
attrib - the attribute to match.
string - the substring to find.
Returns:
a query expression representing attrib.matches(string + "*"). This will be serialized as the non-public class MatchQueryExp.

isInstanceOf

public static QueryExp isInstanceOf(StringValueExp className)
Returns a query expression which checks that a bean is an instance of the class specified by the given StringValueExp. Associating the expression with an ObjectName involves an underlying call to MBeanServer.isInstanceOf(ObjectName,String) using the value of ((StringValueExp) className.apply(objectName)).getValue() as the class name.
Parameters:
className - the name of the class which the bean should be an instance of.
Returns:
a query expression representing the inheritance check. This will be serialized as the non-public class InstanceOfQueryExp.
Since:
1.6

leq

public static QueryExp leq(ValueExp v1,
                           ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 to see if v1 is less than or equal to v2.
Parameters:
v1 - the left-hand operand.
v2 - the right-hand operand.
Returns:
a value expression which returns the result of the comparison when applied. This will be serialized as the non-public class BinaryRelQueryExp with an operation of LE.

lt

public static QueryExp lt(ValueExp v1,
                          ValueExp v2)
Returns a query expression which evaluates to the result of comparing v1 to v2 to see if v1 is less than v2.
Parameters:
v1 - the left-hand operand.
v2 - the right-hand operand.
Returns:
a value expression which returns the result of the comparison when applied. This will be serialized as the non-public class BinaryRelQueryExp with an operation of LT.

match

public static QueryExp match(AttributeValueExp attrib,
                             StringValueExp string)
Returns a query expression which checks that an attribute value matches the pattern specified by the given StringValueExp. The pattern uses file-globbing syntax:
  • '*' stands for any number of arbitrary characters.
  • '?' stands for a single arbitrary characters.
  • An expression within '[' and ']' specify a character class.
  • A range of characters can be specified by separating the start and end character with '-'.
  • The complement of the class can be obtained by using '!' as the first character of the class.
  • '?', '*' and '[' can occur freely within the class. '-' may occur as the first or last character. '!' may occur normally in any position other than the first. ']' may occur as the first element of the class.
  • '?', '*' and '[' may be escaped using a backslash character, '\'.
  • Parameters:
    attrib - the attribute to match.
    string - the substring to find.
    Returns:
    a query expression representing the result of matching the pattern against the evaluated value of the attribute. This will be serialized as the non-public class MatchQueryExp.

    minus

    public static ValueExp minus(ValueExp v1,
                                 ValueExp v2)
    Returns a value expression which evaluates to the result of subtracting v2 from v1.
    Parameters:
    v1 - the left-hand operand.
    v2 - the right-hand operand.
    Returns:
    a value expression which returns the result of the subtraction when applied. This will be serialized as the non-public class BinaryOpValueExp with an operation of MINUS.

    not

    public static QueryExp not(QueryExp q)
    Returns a query expression representing the negation of the specified query expression.
    Parameters:
    q - the query to negate.
    Returns:
    a query expression representing the negation of q. This will be serialized as the non-public class NotQueryExp.

    or

    public static QueryExp or(QueryExp q1,
                              QueryExp q2)
    Returns a query expression formed from the disjunction of the two supplied query expressions.
    Parameters:
    q1 - the first query expression.
    q2 - the second query expression.
    Returns:
    a query expression representing q1 || q2. This will be serialized as the non-public class OrQueryExp.

    plus

    public static ValueExp plus(ValueExp v1,
                                ValueExp v2)
    Returns a value expression which evaluates to the result of adding v1 to v2.
    Parameters:
    v1 - the left-hand operand.
    v2 - the right-hand operand.
    Returns:
    a value expression which returns the result of the addition when applied. This will be serialized as the non-public class BinaryOpValueExp with an operation of PLUS.

    times

    public static ValueExp times(ValueExp v1,
                                 ValueExp v2)
    Returns a value expression which evaluates to the result of multiplying v1 by v2.
    Parameters:
    v1 - the left-hand operand.
    v2 - the right-hand operand.
    Returns:
    a value expression which returns the result of the multiplication when applied. This will be serialized as the non-public class BinaryOpValueExp with an operation of TIMES.

    value

    public static ValueExp value(boolean val)
    Returns a value expression wrapping the specified value.
    Parameters:
    val - the boolean value to wrap.
    Returns:
    a value expression wrapping val. This will be serialized as the non-public class BooleanValueExp.

    value

    public static ValueExp value(double val)
    Returns a value expression wrapping the specified value.
    Parameters:
    val - the double value to wrap.
    Returns:
    a value expression wrapping val. This will be serialized as the non-public class NumericValueExp.

    value

    public static ValueExp value(float val)
    Returns a value expression wrapping the specified value.
    Parameters:
    val - the float value to wrap.
    Returns:
    a value expression wrapping val. This will be serialized as the non-public class NumericValueExp.

    value

    public static ValueExp value(int val)
    Returns a value expression wrapping the specified value.
    Parameters:
    val - the integer value to wrap.
    Returns:
    a value expression wrapping val. This will be serialized as the non-public class NumericValueExp.

    value

    public static ValueExp value(Number val)
    Returns a value expression wrapping the specified value.
    Parameters:
    val - the Number value to wrap.
    Returns:
    a value expression wrapping val. This will be serialized as the non-public class NumericValueExp.

    value

    public static StringValueExp value(String val)
    Returns a value expression wrapping the specified string.
    Parameters:
    val - the String to wrap.
    Returns:
    a StringValueExp wrapping val.

    value

    public static ValueExp value(long val)
    Returns a value expression wrapping the specified value.
    Parameters:
    val - the long value to wrap.
    Returns:
    a value expression wrapping val. This will be serialized as the non-public class NumericValueExp.

    Query.java -- Static methods for query construction. Copyright (C) 2007 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.