Java Reference
In-Depth Information
Table 8.9 Methods of the
Query
class that create
QueryExp
objects (or subclasses) that can be
used in more complex query expressions.
(continued)
Method
Return type
Description
Creates an expression that means the first
ValueExp
should be less than the second
lt( ValueExp,
ValueExp)
QueryExp
Creates an expression that means the first
ValueExp
should match the
String
expression represented by
the second argument; for example, the second argu-
ment might be
va*lu?
match( AttributeValue-
Exp, StringValueExp)
QueryExp
Creates an expression that means the first
ValueExp
should have a prefix matching the
String
expression
represented by the second argument; for example, the
second argument might be
va*lu?
initialSubString(
AttributeValueExp,
StringValueExp)
QueryExp
Creates an expression that means the first
ValueExp
should contain the
String
expression represented by
the second argument; for example, the second argu-
ment might be
va*lu?
anySubString(
AttributeValueExp,
StringValueExp)
QueryExp
Creates an expression that means the first
ValueExp
should have a suffix matching the
String
expression
represented by the second argument; for example, the
second argument might be
va*lu?
finalSubString(
AttributeValueExp,
StringValueExp)
QueryExp
If you are overwhelmed with all these methods right now, don't worry—the next
section presents several examples to get you started.
8.3.3
Constructing examples
Now that you have seen the methods of the
Query
class that are used to create
simple and complex queries, we can present some examples. To create meaning-
ful query examples, let's first imagine the scenario in which the example queries
might exist. Each query will be described in a textual sentence, and then shown
in code using the methods of the
Query
class.
Imagine you have a
JMX
agent with the domain
Hardware
. The agent will con-
tain five MBeans that monitor different pieces of hardware (modem, printer, and
so forth). Each MBean has its own unique object name, but some MBeans have
common attributes. Table 8.10 lists the devices being monitored, along with the
object names and a few attributes of the MBeans.
Use this table as a reference as you develop the queries in the following para-
graphs. As you can see, you have five devices ranging from modems to a fax
machine. All the devices have a
status
attribute, and one has an
error
value.
The printer, fax, and copier all have identical attributes with varying values (as