FileDocCategorySizeDatePackage
Query.javaAPI DocJava SE 6 API23428Tue Jun 10 00:26:14 BST 2008javax.management

Query

public class Query extends Object

Constructs query object constraints. The static methods provided return query expressions that may be used in listing and enumerating MBeans. Individual constraint construction methods allow only appropriate types as arguments. Composition of calls can construct arbitrary nestings of constraints, as the following example illustrates:

QueryExp exp = Query.and(Query.gt(Query.attr("age"),Query.value(5)),
Query.match(Query.attr("name"),
Query.value("Smith")));
since
1.5

Fields Summary
public static final int
GT
A code representing the {@link Query#gt} query. This is chiefly of interest for the serialized form of queries.
public static final int
LT
A code representing the {@link Query#lt} query. This is chiefly of interest for the serialized form of queries.
public static final int
GE
A code representing the {@link Query#geq} query. This is chiefly of interest for the serialized form of queries.
public static final int
LE
A code representing the {@link Query#leq} query. This is chiefly of interest for the serialized form of queries.
public static final int
EQ
A code representing the {@link Query#eq} query. This is chiefly of interest for the serialized form of queries.
public static final int
PLUS
A code representing the {@link Query#plus} expression. This is chiefly of interest for the serialized form of queries.
public static final int
MINUS
A code representing the {@link Query#minus} expression. This is chiefly of interest for the serialized form of queries.
public static final int
TIMES
A code representing the {@link Query#times} expression. This is chiefly of interest for the serialized form of queries.
public static final int
DIV
A code representing the {@link Query#div} expression. This is chiefly of interest for the serialized form of queries.
Constructors Summary
public Query()
Basic constructor.

     

             
        
     
Methods Summary
public static javax.management.QueryExpand(javax.management.QueryExp q1, javax.management.QueryExp q2)
Returns a query expression that is the conjunction of two other query expressions.

param
q1 A query expression.
param
q2 Another query expression.
return
The conjunction of the two arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.AndQueryExp}.

 
	 return new AndQueryExp(q1, q2);
     
public static javax.management.QueryExpanySubString(javax.management.AttributeValueExp a, javax.management.StringValueExp s)
Returns a query expression that represents a matching constraint on a string argument. The value must contain the given literal string value.

param
a An attribute expression.
param
s A string value expression representing the substring.
return
The constraint that a matches s. The returned object will be serialized as an instance of the non-public class {@link javax.management.MatchQueryExp}.

	 return new MatchQueryExp(a,
             new StringValueExp("*" + escapeString(s.getValue()) + "*"));
     
public static javax.management.AttributeValueExpattr(java.lang.String name)

Returns a new attribute expression.

Evaluating this expression for a given objectName includes performing {@link MBeanServer#getAttribute MBeanServer.getAttribute(objectName, name)}.

param
name The name of the attribute.
return
An attribute expression for the attribute named name.

 
	 return new AttributeValueExp(name);
     
public static javax.management.AttributeValueExpattr(java.lang.String className, java.lang.String name)

Returns a new qualified attribute expression.

Evaluating this expression for a given objectName includes performing {@link MBeanServer#getObjectInstance MBeanServer.getObjectInstance(objectName)} and {@link MBeanServer#getAttribute MBeanServer.getAttribute(objectName, name)}.

param
className The name of the class possessing the attribute.
param
name The name of the attribute.
return
An attribute expression for the attribute named name. The returned object will be serialized as an instance of the non-public class {@link javax.management.QualifiedAttributeValueExp}.

 
	 return new QualifiedAttributeValueExp(className, name);
     
public static javax.management.QueryExpbetween(javax.management.ValueExp v1, javax.management.ValueExp v2, javax.management.ValueExp v3)
Returns a query expression that represents the constraint that one value is between two other values.

param
v1 A value expression that is "between" v2 and v3.
param
v2 Value expression that represents a boundary of the constraint.
param
v3 Value expression that represents a boundary of the constraint.
return
The constraint that v1 lies between v2 and v3. The returned object will be serialized as an instance of the non-public class {@link javax.management.BetweenQueryExp}.

	 return new BetweenQueryExp(v1, v2, v3); 
     
public static javax.management.AttributeValueExpclassattr()

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 {@link MBeanServer#getObjectInstance MBeanServer.getObjectInstance(objectName)}.

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

 
	 return new ClassAttributeValueExp();
     
public static javax.management.ValueExpdiv(javax.management.ValueExp value1, javax.management.ValueExp value2)
Returns a binary expression representing the quotient of two numeric values.

param
value1 The first '/' operand.
param
value2 The second '/' operand.
return
A ValueExp representing the quotient of two arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.BinaryOpValueExp} with an {@code op} equal to {@link #DIV}.

	 return new BinaryOpValueExp(DIV, value1, value2); 
     
public static javax.management.QueryExpeq(javax.management.ValueExp v1, javax.management.ValueExp v2)
Returns a query expression that represents an equality constraint on two values.

param
v1 A value expression.
param
v2 Another value expression.
return
A "equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.BinaryRelQueryExp} with a {@code relOp} equal to {@link #EQ}.

 
	 return new BinaryRelQueryExp(EQ, v1, v2);
     
private static java.lang.StringescapeString(java.lang.String s)
Utility method to escape strings used with Query.{initial|any|final}SubString() methods.

         if (s == null)
             return null;
         s = s.replace("\\", "\\\\");
         s = s.replace("*", "\\*");
         s = s.replace("?", "\\?");
         s = s.replace("[", "\\[");
         return s;
     
public static javax.management.QueryExpfinalSubString(javax.management.AttributeValueExp a, javax.management.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.

param
a An attribute expression.
param
s A string value expression representing the end of the string value.
return
The constraint that a matches s. The returned object will be serialized as an instance of the non-public class {@link javax.management.MatchQueryExp}.

	 return new MatchQueryExp(a,
             new StringValueExp("*" + escapeString(s.getValue())));
     
public static javax.management.QueryExpgeq(javax.management.ValueExp v1, javax.management.ValueExp v2)
Returns a query expression that represents a "greater than or equal to" constraint on two values.

param
v1 A value expression.
param
v2 Another value expression.
return
A "greater than or equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.BinaryRelQueryExp} with a {@code relOp} equal to {@link #GE}.

 
	 return new BinaryRelQueryExp(GE, v1, v2);
     
public static javax.management.QueryExpgt(javax.management.ValueExp v1, javax.management.ValueExp v2)
Returns a query expression that represents a "greater than" constraint on two values.

param
v1 A value expression.
param
v2 Another value expression.
return
A "greater than" constraint on the arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.BinaryRelQueryExp} with a {@code relOp} equal to {@link #GT}.

 
	 return new BinaryRelQueryExp(GT, v1, v2);
     
public static javax.management.QueryExpin(javax.management.ValueExp val, javax.management.ValueExp[] valueList)
Returns an expression constraining a value to be one of an explicit list.

param
val A value to be constrained.
param
valueList An array of ValueExps.
return
A QueryExp that represents the constraint. The returned object will be serialized as an instance of the non-public class {@link javax.management.InQueryExp}.

 
	 return new InQueryExp(val, valueList);
     
public static javax.management.QueryExpinitialSubString(javax.management.AttributeValueExp a, javax.management.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.

param
a An attribute expression.
param
s A string value expression representing the beginning of the string value.
return
The constraint that a matches s. The returned object will be serialized as an instance of the non-public class {@link javax.management.MatchQueryExp}.

	 return new MatchQueryExp(a,
             new StringValueExp(escapeString(s.getValue()) + "*"));
     
public static javax.management.QueryExpisInstanceOf(javax.management.StringValueExp classNameValue)
Returns a query expression that represents an inheritance constraint on an MBean class.

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

Evaluating this expression for a given objectName includes performing {@link MBeanServer#isInstanceOf MBeanServer.isInstanceOf(objectName, ((StringValueExp)classNameValue.apply(objectName)).getValue()}.

param
classNameValue The {@link StringValueExp} returning the name of the class of which selected MBeans should be instances.
return
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 {@link javax.management.InstanceOfQueryExp}.
since
1.6

        return new InstanceOfQueryExp(classNameValue);
     
public static javax.management.QueryExpleq(javax.management.ValueExp v1, javax.management.ValueExp v2)
Returns a query expression that represents a "less than or equal to" constraint on two values.

param
v1 A value expression.
param
v2 Another value expression.
return
A "less than or equal to" constraint on the arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.BinaryRelQueryExp} with a {@code relOp} equal to {@link #LE}.

 
	 return new BinaryRelQueryExp(LE, v1, v2);
     
public static javax.management.QueryExplt(javax.management.ValueExp v1, javax.management.ValueExp v2)
Returns a query expression that represents a "less than" constraint on two values.

param
v1 A value expression.
param
v2 Another value expression.
return
A "less than" constraint on the arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.BinaryRelQueryExp} with a {@code relOp} equal to {@link #LT}.

 
	 return new BinaryRelQueryExp(LT, v1, v2);
     
public static javax.management.QueryExpmatch(javax.management.AttributeValueExp a, javax.management.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.

param
a An attribute expression
param
s A string value expression representing a matching constraint
return
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 {@link javax.management.MatchQueryExp}.

 
	 return new MatchQueryExp(a, s);
     
public static javax.management.ValueExpminus(javax.management.ValueExp value1, javax.management.ValueExp value2)
Returns a binary expression representing the difference between two numeric values.

param
value1 The first '-' operand.
param
value2 The second '-' operand.
return
A ValueExp representing the difference between two arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.BinaryOpValueExp} with an {@code op} equal to {@link #MINUS}.

	 return new BinaryOpValueExp(MINUS, value1, value2);
     
public static javax.management.QueryExpnot(javax.management.QueryExp queryExp)
Returns a constraint that is the negation of its argument.

param
queryExp The constraint to negate.
return
A negated constraint. The returned object will be serialized as an instance of the non-public class {@link javax.management.NotQueryExp}.

 
	 return new NotQueryExp(queryExp);
     
public static javax.management.QueryExpor(javax.management.QueryExp q1, javax.management.QueryExp q2)
Returns a query expression that is the disjunction of two other query expressions.

param
q1 A query expression.
param
q2 Another query expression.
return
The disjunction of the two arguments. The returned object will be serialized as an instance of the non-public class {@link javax.management.OrQueryExp}.

 
	 return new OrQueryExp(q1, q2);
     
public static javax.management.ValueExpplus(javax.management.ValueExp value1, javax.management.ValueExp value2)
Returns a binary expression representing the sum of two numeric values, or the concatenation of two string values.

param
value1 The first '+' operand.
param
value2 The second '+' operand.
return
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 {@link javax.management.BinaryOpValueExp} with an {@code op} equal to {@link #PLUS}.

	 return new BinaryOpValueExp(PLUS, value1, value2); 
     
public static javax.management.ValueExptimes(javax.management.ValueExp value1, javax.management.ValueExp value2)
Returns a binary expression representing the product of two numeric values.

param
value1 The first '*' operand.
param
value2 The second '*' operand.
return
A ValueExp representing the product. The returned object will be serialized as an instance of the non-public class {@link javax.management.BinaryOpValueExp} with an {@code op} equal to {@link #TIMES}.

	 return new BinaryOpValueExp(TIMES, value1, value2); 
     
public static javax.management.StringValueExpvalue(java.lang.String val)
Returns a new string expression.

param
val The string value.
return
A ValueExp object containing the string argument.

 
	 return new StringValueExp(val);
     
public static javax.management.ValueExpvalue(java.lang.Number val)
Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

param
val An instance of Number.
return
A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class {@link javax.management.NumericValueExp}.

 
	 return new NumericValueExp(val);
     
public static javax.management.ValueExpvalue(int val)
Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

param
val An int value.
return
A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class {@link javax.management.NumericValueExp}.

 
	 return new NumericValueExp((long) val);
     
public static javax.management.ValueExpvalue(long val)
Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

param
val A long value.
return
A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class {@link javax.management.NumericValueExp}.

 
	 return new NumericValueExp(val);
     
public static javax.management.ValueExpvalue(float val)
Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

param
val A float value.
return
A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class {@link javax.management.NumericValueExp}.

 
	 return new NumericValueExp((double) val);
     
public static javax.management.ValueExpvalue(double val)
Returns a numeric value expression that can be used in any Query call that expects a ValueExp.

param
val A double value.
return
A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class {@link javax.management.NumericValueExp}.

 
	 return new NumericValueExp(val);
     
public static javax.management.ValueExpvalue(boolean val)
Returns a boolean value expression that can be used in any Query call that expects a ValueExp.

param
val A boolean value.
return
A ValueExp object containing the argument. The returned object will be serialized as an instance of the non-public class {@link javax.management.BooleanValueExp}.

 
	 return new BooleanValueExp(val);