APIdia Launch Partner
Top Description Fields Constructors Methods
javax.management

public Class Query

extends Object
Class Inheritance

Constructs query object constraints.

The MBean Server can be queried for MBeans that meet a particular condition, using its queryNames or queryMBeans method. The QueryExp parameter to the method can be any implementation of the interface QueryExp, but it is usually best to obtain the QueryExp value by calling the static methods in this class. This is particularly true when querying a remote MBean Server: a custom implementation of the QueryExp interface might not be present in the remote MBean Server, but the methods in this class return only standard classes that are part of the JMX implementation.

As an example, suppose you wanted to find all MBeans where the Enabled attribute is true and the Owner attribute is "Duke". Here is how you could construct the appropriate QueryExp by chaining together method calls:

QueryExp query =
    Query.and(Query.eq(Query.attr("Enabled"), Query.value(true)),
              Query.eq(Query.attr("Owner"), Query.value("Duke")));
Since
1.5

Field Summary

Modifier and TypeField and Description
public static final int
DIV

A code representing the Query#div expression.

public static final int
EQ

A code representing the Query#eq query.

public static final int
GE

A code representing the Query#geq query.

public static final int
GT

A code representing the Query#gt query.

public static final int
LE

A code representing the Query#leq query.

public static final int
LT

A code representing the Query#lt query.

public static final int
MINUS

A code representing the Query#minus expression.

public static final int
PLUS

A code representing the Query#plus expression.

public static final int
TIMES

A code representing the Query#times expression.

Constructor Summary

AccessConstructor and Description
public
Query()

Basic constructor.

Method Summary

Modifier and TypeMethod and Description
public static QueryExp

Returns:

The conjunction of the two arguments. The returned object will be serialized as an instance of the non-public class javax.management.AndQueryExp.
and
(QueryExp
A query expression.
q1
,
QueryExp
Another query expression.
q2
)

Returns a query expression that is the conjunction of two other query expressions.

public static QueryExp

Returns:

The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.
anySubString
(AttributeValueExp
An attribute expression.
a
,
StringValueExp
A string value expression representing the substring.
s
)

Returns a query expression that represents a matching constraint on a string argument.

public static AttributeValueExp

Returns:

An attribute expression for the attribute named name.
attr
(String
The name of the attribute.
name
)

Returns a new attribute expression.

public static AttributeValueExp

Returns:

An attribute expression for the attribute named name. The returned object will be serialized as an instance of the non-public class javax.management.QualifiedAttributeValueExp.
attr
(String
The name of the class possessing the attribute.
className
,
String
The name of the attribute.
name
)

Returns a new qualified attribute expression.

public static QueryExp

Returns:

The constraint that v1 lies between v2 and v3. The returned object will be serialized as an instance of the non-public class javax.management.BetweenQueryExp.
between
(ValueExp
A value expression that is "between" v2 and v3.
v1
,
ValueExp
Value expression that represents a boundary of the constraint.
v2
,
ValueExp
Value expression that represents a boundary of the constraint.
v3
)

Returns a query expression that represents the constraint that one value is between two other values.

public static AttributeValueExp

Returns:

A class attribute expression. The returned object will be serialized as an instance of the non-public class javax.management.ClassAttributeValueExp.
classattr
()

Returns a new class attribute expression which can be used in any Query call that expects a ValueExp.

public static ValueExp

Returns:

A ValueExp representing the quotient of two arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryOpValueExp with an op equal to DIV.
div
(ValueExp
The first '/' operand.
value1
,
ValueExp
The second '/' operand.
value2
)

Returns a binary expression representing the quotient of two numeric values.

public static QueryExp

Returns:

A "equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to EQ.
eq
(ValueExp
A value expression.
v1
,
ValueExp
Another value expression.
v2
)

Returns a query expression that represents an equality constraint on two values.

private static String
escapeString(String s)

Utility method to escape strings used with Query.{initial|any|final}SubString() methods.

public static QueryExp

Returns:

The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.
finalSubString
(AttributeValueExp
An attribute expression.
a
,
StringValueExp
A string value expression representing the end of the string value.
s
)

Returns a query expression that represents a matching constraint on a string argument.

public static QueryExp

Returns:

A "greater than or equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to GE.
geq
(ValueExp
A value expression.
v1
,
ValueExp
Another value expression.
v2
)

Returns a query expression that represents a "greater than or equal to" constraint on two values.

public static QueryExp

Returns:

A "greater than" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to GT.
gt
(ValueExp
A value expression.
v1
,
ValueExp
Another value expression.
v2
)

Returns a query expression that represents a "greater than" constraint on two values.

public static QueryExp

Returns:

A QueryExp that represents the constraint. The returned object will be serialized as an instance of the non-public class javax.management.InQueryExp.
in
(ValueExp
A value to be constrained.
val
,
ValueExp[]
An array of ValueExps.
valueList
)

Returns an expression constraining a value to be one of an explicit list.

public static QueryExp

Returns:

The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.
initialSubString
(AttributeValueExp
An attribute expression.
a
,
StringValueExp
A string value expression representing the beginning of the string value.
s
)

Returns a query expression that represents a matching constraint on a string argument.

public static QueryExp

Returns:

a query expression that represents an inheritance constraint on an MBean class. The returned object will be serialized as an instance of the non-public class javax.management.InstanceOfQueryExp.
isInstanceOf
(StringValueExp
The StringValueExp returning the name of the class of which selected MBeans should be instances.
classNameValue
)

Returns a query expression that represents an inheritance constraint on an MBean class.

public static QueryExp

Returns:

A "less than or equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to LE.
leq
(ValueExp
A value expression.
v1
,
ValueExp
Another value expression.
v2
)

Returns a query expression that represents a "less than or equal to" constraint on two values.

public static QueryExp

Returns:

A "less than" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to LT.
lt
(ValueExp
A value expression.
v1
,
ValueExp
Another value expression.
v2
)

Returns a query expression that represents a "less than" constraint on two values.

public static QueryExp

Returns:

A query expression that represents the matching constraint on the string argument. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.
match
(AttributeValueExp
An attribute expression
a
,
StringValueExp
A string value expression representing a matching constraint
s
)

Returns a query expression that represents a matching constraint on a string argument.

public static ValueExp

Returns:

A ValueExp representing the difference between two arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryOpValueExp with an op equal to MINUS.
minus
(ValueExp
The first '-' operand.
value1
,
ValueExp
The second '-' operand.
value2
)

Returns a binary expression representing the difference between two numeric values.

public static QueryExp

Returns:

A negated constraint. The returned object will be serialized as an instance of the non-public class javax.management.NotQueryExp.
not
(QueryExp
The constraint to negate.
queryExp
)

Returns a constraint that is the negation of its argument.

public static QueryExp

Returns:

The disjunction of the two arguments. The returned object will be serialized as an instance of the non-public class javax.management.OrQueryExp.
or
(QueryExp
A query expression.
q1
,
QueryExp
Another query expression.
q2
)

Returns a query expression that is the disjunction of two other query expressions.

public static ValueExp

Returns:

A ValueExp representing the sum or concatenation of the two arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryOpValueExp with an op equal to PLUS.
plus
(ValueExp
The first '+' operand.
value1
,
ValueExp
The second '+' operand.
value2
)

Returns a binary expression representing the sum of two numeric values, or the concatenation of two string values.

public static ValueExp

Returns:

A ValueExp representing the product. The returned object will be serialized as an instance of the non-public class javax.management.BinaryOpValueExp with an op equal to TIMES.
times
(ValueExp
The first '*' operand.
value1
,
ValueExp
The second '*' operand.
value2
)

Returns a binary expression representing the product of two numeric values.

public static StringValueExp

Returns:

A ValueExp object containing the string argument.
value
(String
The string value.
val
)

Returns a new string expression.

public static ValueExp

Returns:

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
value
(Number
An instance of Number.
val
)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

public static ValueExp

Returns:

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
value
(int
An int value.
val
)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

public static ValueExp

Returns:

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
value
(long
A long value.
val
)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

public static ValueExp

Returns:

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
value
(float
A float value.
val
)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

public static ValueExp

Returns:

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
value
(double
A double value.
val
)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

public static ValueExp

Returns:

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.BooleanValueExp.
value
(boolean
A boolean value.
val
)

Returns a boolean value expression that can be used in any Query call that expects a ValueExp.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DIVback to summary
public static final int DIV

A code representing the Query#div expression. This is chiefly of interest for the serialized form of queries.

EQback to summary
public static final int EQ

A code representing the Query#eq query. This is chiefly of interest for the serialized form of queries.

GEback to summary
public static final int GE

A code representing the Query#geq query. This is chiefly of interest for the serialized form of queries.

GTback to summary
public static final int GT

A code representing the Query#gt query. This is chiefly of interest for the serialized form of queries.

LEback to summary
public static final int LE

A code representing the Query#leq query. This is chiefly of interest for the serialized form of queries.

LTback to summary
public static final int LT

A code representing the Query#lt query. This is chiefly of interest for the serialized form of queries.

MINUSback to summary
public static final int MINUS

A code representing the Query#minus expression. This is chiefly of interest for the serialized form of queries.

PLUSback to summary
public static final int PLUS

A code representing the Query#plus expression. This is chiefly of interest for the serialized form of queries.

TIMESback to summary
public static final int TIMES

A code representing the Query#times expression. This is chiefly of interest for the serialized form of queries.

Constructor Detail

Queryback to summary
public Query()

Basic constructor.

Method Detail

andback to summary
public static QueryExp and(QueryExp q1, QueryExp q2)

Returns a query expression that is the conjunction of two other query expressions.

Parameters
q1:QueryExp

A query expression.

q2:QueryExp

Another query expression.

Returns:QueryExp

The conjunction of the two arguments. The returned object will be serialized as an instance of the non-public class javax.management.AndQueryExp.

anySubStringback to summary
public static QueryExp anySubString(AttributeValueExp a, StringValueExp s)

Returns a query expression that represents a matching constraint on a string argument. The value must contain the given literal string value.

Parameters
a:AttributeValueExp

An attribute expression.

s:StringValueExp

A string value expression representing the substring.

Returns:QueryExp

The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.

attrback to summary
public static AttributeValueExp attr(String name)

Returns a new attribute expression. See AttributeValueExp for a detailed description of the semantics of the expression.

Evaluating this expression for a given objectName includes performing MBeanServer.getAttribute(objectName, name).

Parameters
name:String

The name of the attribute.

Returns:AttributeValueExp

An attribute expression for the attribute named name.

attrback to summary
public static AttributeValueExp attr(String className, String name)

Returns a new qualified attribute expression.

Evaluating this expression for a given objectName includes performing MBeanServer.getObjectInstance(objectName) and MBeanServer.getAttribute(objectName, name).

Parameters
className:String

The name of the class possessing the attribute.

name:String

The name of the attribute.

Returns:AttributeValueExp

An attribute expression for the attribute named name. The returned object will be serialized as an instance of the non-public class javax.management.QualifiedAttributeValueExp.

betweenback to summary
public static QueryExp between(ValueExp v1, ValueExp v2, ValueExp v3)

Returns a query expression that represents the constraint that one value is between two other values.

Parameters
v1:ValueExp

A value expression that is "between" v2 and v3.

v2:ValueExp

Value expression that represents a boundary of the constraint.

v3:ValueExp

Value expression that represents a boundary of the constraint.

Returns:QueryExp

The constraint that v1 lies between v2 and v3. The returned object will be serialized as an instance of the non-public class javax.management.BetweenQueryExp.

classattrback to summary
public static AttributeValueExp classattr()

Returns a new class attribute expression which can be used in any Query call that expects a ValueExp.

Evaluating this expression for a given objectName includes performing MBeanServer.getObjectInstance(objectName).

Returns:AttributeValueExp

A class attribute expression. The returned object will be serialized as an instance of the non-public class javax.management.ClassAttributeValueExp.

divback to summary
public static ValueExp div(ValueExp value1, ValueExp value2)

Returns a binary expression representing the quotient of two numeric values.

Parameters
value1:ValueExp

The first '/' operand.

value2:ValueExp

The second '/' operand.

Returns:ValueExp

A ValueExp representing the quotient of two arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryOpValueExp with an op equal to DIV.

eqback to summary
public static QueryExp eq(ValueExp v1, ValueExp v2)

Returns a query expression that represents an equality constraint on two values.

Parameters
v1:ValueExp

A value expression.

v2:ValueExp

Another value expression.

Returns:QueryExp

A "equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to EQ.

escapeStringback to summary
private static String escapeString(String s)

Utility method to escape strings used with Query.{initial|any|final}SubString() methods.

finalSubStringback to summary
public static QueryExp finalSubString(AttributeValueExp a, StringValueExp s)

Returns a query expression that represents a matching constraint on a string argument. The value must end with the given literal string value.

Parameters
a:AttributeValueExp

An attribute expression.

s:StringValueExp

A string value expression representing the end of the string value.

Returns:QueryExp

The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.

geqback to summary
public static QueryExp geq(ValueExp v1, ValueExp v2)

Returns a query expression that represents a "greater than or equal to" constraint on two values.

Parameters
v1:ValueExp

A value expression.

v2:ValueExp

Another value expression.

Returns:QueryExp

A "greater than or equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to GE.

gtback to summary
public static QueryExp gt(ValueExp v1, ValueExp v2)

Returns a query expression that represents a "greater than" constraint on two values.

Parameters
v1:ValueExp

A value expression.

v2:ValueExp

Another value expression.

Returns:QueryExp

A "greater than" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to GT.

inback to summary
public static QueryExp in(ValueExp val, ValueExp[] valueList)

Returns an expression constraining a value to be one of an explicit list.

Parameters
val:ValueExp

A value to be constrained.

valueList:ValueExp[]

An array of ValueExps.

Returns:QueryExp

A QueryExp that represents the constraint. The returned object will be serialized as an instance of the non-public class javax.management.InQueryExp.

initialSubStringback to summary
public static QueryExp initialSubString(AttributeValueExp a, StringValueExp s)

Returns a query expression that represents a matching constraint on a string argument. The value must start with the given literal string value.

Parameters
a:AttributeValueExp

An attribute expression.

s:StringValueExp

A string value expression representing the beginning of the string value.

Returns:QueryExp

The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.

isInstanceOfback to summary
public static QueryExp isInstanceOf(StringValueExp classNameValue)

Returns a query expression that represents an inheritance constraint on an MBean class.

Example: to find MBeans that are instances of NotificationBroadcaster, use Query.isInstanceOf(Query.value(NotificationBroadcaster.class.getName())).

Evaluating this expression for a given objectName includes performing MBeanServer.isInstanceOf(objectName, ((StringValueExp)classNameValue.apply(objectName)).getValue().

Parameters
classNameValue:StringValueExp

The StringValueExp returning the name of the class of which selected MBeans should be instances.

Returns:QueryExp

a query expression that represents an inheritance constraint on an MBean class. The returned object will be serialized as an instance of the non-public class javax.management.InstanceOfQueryExp.

Since
1.6
leqback to summary
public static QueryExp leq(ValueExp v1, ValueExp v2)

Returns a query expression that represents a "less than or equal to" constraint on two values.

Parameters
v1:ValueExp

A value expression.

v2:ValueExp

Another value expression.

Returns:QueryExp

A "less than or equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to LE.

ltback to summary
public static QueryExp lt(ValueExp v1, ValueExp v2)

Returns a query expression that represents a "less than" constraint on two values.

Parameters
v1:ValueExp

A value expression.

v2:ValueExp

Another value expression.

Returns:QueryExp

A "less than" constraint on the arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryRelQueryExp with a relOp equal to LT.

matchback to summary
public static QueryExp match(AttributeValueExp a, StringValueExp s)

Returns a query expression that represents a matching constraint on a string argument. The matching syntax is consistent with file globbing: supports "?", "*", "[", each of which may be escaped with "\"; character classes may use "!" for negation and "-" for range. (* for any character sequence, ? for a single arbitrary character, [...] for a character sequence). For example: a*b?c would match a string starting with the character a, followed by any number of characters, followed by a b, any single character, and a c.

Parameters
a:AttributeValueExp

An attribute expression

s:StringValueExp

A string value expression representing a matching constraint

Returns:QueryExp

A query expression that represents the matching constraint on the string argument. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.

minusback to summary
public static ValueExp minus(ValueExp value1, ValueExp value2)

Returns a binary expression representing the difference between two numeric values.

Parameters
value1:ValueExp

The first '-' operand.

value2:ValueExp

The second '-' operand.

Returns:ValueExp

A ValueExp representing the difference between two arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryOpValueExp with an op equal to MINUS.

notback to summary
public static QueryExp not(QueryExp queryExp)

Returns a constraint that is the negation of its argument.

Parameters
queryExp:QueryExp

The constraint to negate.

Returns:QueryExp

A negated constraint. The returned object will be serialized as an instance of the non-public class javax.management.NotQueryExp.

orback to summary
public static QueryExp or(QueryExp q1, QueryExp q2)

Returns a query expression that is the disjunction of two other query expressions.

Parameters
q1:QueryExp

A query expression.

q2:QueryExp

Another query expression.

Returns:QueryExp

The disjunction of the two arguments. The returned object will be serialized as an instance of the non-public class javax.management.OrQueryExp.

plusback to summary
public static ValueExp plus(ValueExp value1, ValueExp value2)

Returns a binary expression representing the sum of two numeric values, or the concatenation of two string values.

Parameters
value1:ValueExp

The first '+' operand.

value2:ValueExp

The second '+' operand.

Returns:ValueExp

A ValueExp representing the sum or concatenation of the two arguments. The returned object will be serialized as an instance of the non-public class javax.management.BinaryOpValueExp with an op equal to PLUS.

timesback to summary
public static ValueExp times(ValueExp value1, ValueExp value2)

Returns a binary expression representing the product of two numeric values.

Parameters
value1:ValueExp

The first '*' operand.

value2:ValueExp

The second '*' operand.

Returns:ValueExp

A ValueExp representing the product. The returned object will be serialized as an instance of the non-public class javax.management.BinaryOpValueExp with an op equal to TIMES.

valueback to summary
public static StringValueExp value(String val)

Returns a new string expression.

Parameters
val:String

The string value.

Returns:StringValueExp

A ValueExp object containing the string argument.

valueback to summary
public static ValueExp value(Number val)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

Parameters
val:Number

An instance of Number.

Returns:ValueExp

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.

valueback to summary
public static ValueExp value(int val)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

Parameters
val:int

An int value.

Returns:ValueExp

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.

valueback to summary
public static ValueExp value(long val)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

Parameters
val:long

A long value.

Returns:ValueExp

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.

valueback to summary
public static ValueExp value(float val)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

Parameters
val:float

A float value.

Returns:ValueExp

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.

valueback to summary
public static ValueExp value(double val)

Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

Parameters
val:double

A double value.

Returns:ValueExp

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.

valueback to summary
public static ValueExp value(boolean val)

Returns a boolean value expression that can be used in any Query call that expects a ValueExp.

Parameters
val:boolean

A boolean value.

Returns:ValueExp

A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.BooleanValueExp.