O'Reilly logo

Java Message Service by Richard Monson-Haefel, David A Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Comparison Operators

Comparison operators compare identifiers to literals in a boolean expression that evaluates to either TRUE or FALSE. Comparison operations can be combined into more complex expressions using the logical operators AND and OR. Expressions are evaluated from left to right:

Age < 30 AND Weight >= 100.00 OR LName = 'Smith'

In this example, the expression would be evaluated as if it had parentheses placed as follows (parentheses can be used to group expressions and can change the precedence of evaluation):

            (Age < 30 AND Weight >= 100.00)  OR  (LName = 'Smith')

Either the LName must be equal to 'Smith' or the LName can be any value as long as the Age is less than 30 and the Weight is greater than or equal to 100. Evaluating these kinds of expressions should be second nature for most programmers.

The following message selector uses three of the six algebraic comparison operators, which are = , > , >= , < , <= , and <> (not equal):

Age < 30 AND Weight >= 100.00 OR LName = 'Smith'

These algebraic comparison operators can be used on any of the primitive property types except for boolean. The boolean and String property types are restricted to the = or the <> algebraic operators.

String types can be compared using the LIKE comparison operator. For example:

Age < 30 AND Weight >= 100.00 OR LName LIKE 'Sm%th'

The LIKE comparison operator attempts to match each character in the literal with characters of the property value. Two special wildcard characters, underscore (_) and percent ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required