public class Query extends Object
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
- 
Constructor SummaryConstructors Constructor Description Query()Basic constructor.
- 
Method SummaryModifier and Type Method Description static QueryExpand(QueryExp q1, QueryExp q2)Returns a query expression that is the conjunction of two other query expressions.static QueryExpanySubString(AttributeValueExp a, StringValueExp s)Returns a query expression that represents a matching constraint on a string argument.static AttributeValueExpattr(String name)Returns a new attribute expression.static AttributeValueExpattr(String className, String name)Returns a new qualified attribute expression.static QueryExpbetween(ValueExp v1, ValueExp v2, ValueExp v3)Returns a query expression that represents the constraint that one value is between two other values.static AttributeValueExpclassattr()Returns a new class attribute expression which can be used in any Query call that expects a ValueExp.static ValueExpdiv(ValueExp value1, ValueExp value2)Returns a binary expression representing the quotient of two numeric values.static QueryExpeq(ValueExp v1, ValueExp v2)Returns a query expression that represents an equality constraint on two values.static QueryExpfinalSubString(AttributeValueExp a, StringValueExp s)Returns a query expression that represents a matching constraint on a string argument.static QueryExpgeq(ValueExp v1, ValueExp v2)Returns a query expression that represents a "greater than or equal to" constraint on two values.static QueryExpgt(ValueExp v1, ValueExp v2)Returns a query expression that represents a "greater than" constraint on two values.static QueryExpin(ValueExp val, ValueExp[] valueList)Returns an expression constraining a value to be one of an explicit list.static QueryExpinitialSubString(AttributeValueExp a, StringValueExp s)Returns a query expression that represents a matching constraint on a string argument.static QueryExpisInstanceOf(StringValueExp classNameValue)Returns a query expression that represents an inheritance constraint on an MBean class.static QueryExpleq(ValueExp v1, ValueExp v2)Returns a query expression that represents a "less than or equal to" constraint on two values.static QueryExplt(ValueExp v1, ValueExp v2)Returns a query expression that represents a "less than" constraint on two values.static QueryExpmatch(AttributeValueExp a, StringValueExp s)Returns a query expression that represents a matching constraint on a string argument.static ValueExpminus(ValueExp value1, ValueExp value2)Returns a binary expression representing the difference between two numeric values.static QueryExpnot(QueryExp queryExp)Returns a constraint that is the negation of its argument.static QueryExpor(QueryExp q1, QueryExp q2)Returns a query expression that is the disjunction of two other query expressions.static ValueExpplus(ValueExp value1, ValueExp value2)Returns a binary expression representing the sum of two numeric values, or the concatenation of two string values.static ValueExptimes(ValueExp value1, ValueExp value2)Returns a binary expression representing the product of two numeric values.static ValueExpvalue(boolean val)Returns a boolean value expression that can be used in any Query call that expects a ValueExp.static ValueExpvalue(double val)Returns a numeric value expression that can be used in any Query call that expects a ValueExp.static ValueExpvalue(float val)Returns a numeric value expression that can be used in any Query call that expects a ValueExp.static ValueExpvalue(int val)Returns a numeric value expression that can be used in any Query call that expects a ValueExp.static ValueExpvalue(long val)Returns a numeric value expression that can be used in any Query call that expects a ValueExp.static ValueExpvalue(Number val)Returns a numeric value expression that can be used in any Query call that expects a ValueExp.static StringValueExpvalue(String val)Returns a new string expression.
- 
Field Details- 
GTpublic static final int GTA code representing thegt(javax.management.ValueExp, javax.management.ValueExp)query. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
- 
LTpublic static final int LTA code representing thelt(javax.management.ValueExp, javax.management.ValueExp)query. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
- 
GEpublic static final int GEA code representing thegeq(javax.management.ValueExp, javax.management.ValueExp)query. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
- 
LEpublic static final int LEA code representing theleq(javax.management.ValueExp, javax.management.ValueExp)query. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
- 
EQpublic static final int EQA code representing theeq(javax.management.ValueExp, javax.management.ValueExp)query. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
- 
PLUSpublic static final int PLUSA code representing theplus(javax.management.ValueExp, javax.management.ValueExp)expression. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
- 
MINUSpublic static final int MINUSA code representing theminus(javax.management.ValueExp, javax.management.ValueExp)expression. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
- 
TIMESpublic static final int TIMESA code representing thetimes(javax.management.ValueExp, javax.management.ValueExp)expression. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
- 
DIVpublic static final int DIVA code representing thediv(javax.management.ValueExp, javax.management.ValueExp)expression. This is chiefly of interest for the serialized form of queries.- See Also:
- Constant Field Values
 
 
- 
- 
Constructor Details- 
Querypublic Query()Basic constructor.
 
- 
- 
Method Details- 
andReturns a query expression that is the conjunction of two other query expressions.- Parameters:
- q1- A query expression.
- q2- Another query expression.
- Returns:
- The conjunction of the two arguments. The returned object will be serialized as an instance of the non-public class javax.management.AndQueryExp.
 
- 
orReturns a query expression that is the disjunction of two other query expressions.- Parameters:
- q1- A query expression.
- q2- Another query expression.
- Returns:
- The disjunction of the two arguments. The returned object will be serialized as an instance of the non-public class javax.management.OrQueryExp.
 
- 
gtReturns a query expression that represents a "greater than" constraint on two values.- Parameters:
- v1- A value expression.
- v2- Another value expression.
- 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 relOpequal toGT.
 
- 
geqReturns a query expression that represents a "greater than or equal to" constraint on two values.- Parameters:
- v1- A value expression.
- v2- Another value expression.
- 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 relOpequal toGE.
 
- 
leqReturns a query expression that represents a "less than or equal to" constraint on two values.- Parameters:
- v1- A value expression.
- v2- Another value expression.
- 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 relOpequal toLE.
 
- 
ltReturns a query expression that represents a "less than" constraint on two values.- Parameters:
- v1- A value expression.
- v2- Another value expression.
- 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 relOpequal toLT.
 
- 
eqReturns a query expression that represents an equality constraint on two values.- Parameters:
- v1- A value expression.
- v2- Another value expression.
- 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 relOpequal toEQ.
 
- 
betweenReturns a query expression that represents the constraint that one value is between two other values.- Parameters:
- v1- A value expression that is "between" v2 and v3.
- v2- Value expression that represents a boundary of the constraint.
- v3- Value expression that represents a boundary of the constraint.
- 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.
 
- 
matchReturns 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?cwould match a string starting with the charactera, followed by any number of characters, followed by ab, any single character, and ac.- Parameters:
- a- An attribute expression
- s- A string value expression representing a matching constraint
- 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.
 
- 
attrReturns a new attribute expression. See AttributeValueExpfor a detailed description of the semantics of the expression.Evaluating this expression for a given objectNameincludes performingMBeanServer.getAttribute(objectName, name).- Parameters:
- name- The name of the attribute.
- Returns:
- An attribute expression for the attribute named name.
 
- 
attrReturns a new qualified attribute expression. Evaluating this expression for a given objectNameincludes performingMBeanServer.getObjectInstance(objectName)andMBeanServer.getAttribute(objectName, name).- Parameters:
- className- The name of the class possessing the attribute.
- name- The name of the attribute.
- 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.
 
- 
classattrReturns a new class attribute expression which can be used in any Query call that expects a ValueExp. Evaluating this expression for a given objectNameincludes performingMBeanServer.getObjectInstance(objectName).- Returns:
- A class attribute expression. The returned object will be serialized as an instance of the non-public class javax.management.ClassAttributeValueExp.
 
- 
notReturns a constraint that is the negation of its argument.- Parameters:
- queryExp- The constraint to negate.
- Returns:
- A negated constraint. The returned object will be serialized as an instance of the non-public class javax.management.NotQueryExp.
 
- 
inReturns an expression constraining a value to be one of an explicit list.- Parameters:
- val- A value to be constrained.
- valueList- An array of ValueExps.
- Returns:
- A QueryExp that represents the constraint. The returned object will be serialized as an instance of the non-public class javax.management.InQueryExp.
 
- 
valueReturns a new string expression.- Parameters:
- val- The string value.
- Returns:
- A ValueExp object containing the string argument.
 
- 
valueReturns a numeric value expression that can be used in any Query call that expects a ValueExp.- Parameters:
- val- An instance of Number.
- Returns:
- A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
 
- 
valueReturns a numeric value expression that can be used in any Query call that expects a ValueExp.- Parameters:
- val- An int value.
- Returns:
- A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
 
- 
valueReturns a numeric value expression that can be used in any Query call that expects a ValueExp.- Parameters:
- val- A long value.
- Returns:
- A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
 
- 
valueReturns a numeric value expression that can be used in any Query call that expects a ValueExp.- Parameters:
- val- A float value.
- Returns:
- A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
 
- 
valueReturns a numeric value expression that can be used in any Query call that expects a ValueExp.- Parameters:
- val- A double value.
- Returns:
- A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.NumericValueExp.
 
- 
valueReturns a boolean value expression that can be used in any Query call that expects a ValueExp.- Parameters:
- val- A boolean value.
- Returns:
- A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class javax.management.BooleanValueExp.
 
- 
plusReturns a binary expression representing the sum of two numeric values, or the concatenation of two string values.- Parameters:
- value1- The first '+' operand.
- value2- The second '+' operand.
- 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 opequal toPLUS.
 
- 
timesReturns a binary expression representing the product of two numeric values.- Parameters:
- value1- The first '*' operand.
- value2- The second '*' operand.
- 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 opequal toTIMES.
 
- 
minusReturns a binary expression representing the difference between two numeric values.- Parameters:
- value1- The first '-' operand.
- value2- The second '-' operand.
- 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 opequal toMINUS.
 
- 
divReturns a binary expression representing the quotient of two numeric values.- Parameters:
- value1- The first '/' operand.
- value2- The second '/' operand.
- 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 opequal toDIV.
 
- 
initialSubStringReturns a query expression that represents a matching constraint on a string argument. The value must start with the given literal string value.- Parameters:
- a- An attribute expression.
- s- A string value expression representing the beginning of the string value.
- Returns:
- The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.
 
- 
anySubStringReturns a query expression that represents a matching constraint on a string argument. The value must contain the given literal string value.- Parameters:
- a- An attribute expression.
- s- A string value expression representing the substring.
- Returns:
- The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.
 
- 
finalSubStringReturns a query expression that represents a matching constraint on a string argument. The value must end with the given literal string value.- Parameters:
- a- An attribute expression.
- s- A string value expression representing the end of the string value.
- Returns:
- The constraint that a matches s. The returned object will be serialized as an instance of the non-public class javax.management.MatchQueryExp.
 
- 
isInstanceOfReturns a query expression that represents an inheritance constraint on an MBean class.Example: to find MBeans that are instances of NotificationBroadcaster, useQuery.isInstanceOf(Query.value(NotificationBroadcaster.class.getName())).Evaluating this expression for a given objectNameincludes performingMBeanServer.isInstanceOf(objectName, ((StringValueExp)classNameValue.apply(objectName)).getValue().- Parameters:
- classNameValue- The- StringValueExpreturning the name of the class of which selected MBeans should be instances.
- 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.
- Since:
- 1.6
 
 
-