23.07.2013 Views

O'Reilly - Java Message Service

O'Reilly - Java Message Service

O'Reilly - Java Message Service

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Java</strong> <strong>Message</strong> <strong>Service</strong><br />

Numeric literals are expressed using exact numerical (+22, 30, -52134), approximate<br />

numerical with decimal (-33.22, 100.00, +7.0), or scientific (-9E4, 3.5E6) notation.<br />

Boolean literals are expressed as TRUE or FALSE.<br />

D.3 Comparison Operators<br />

Comparison operators compare identifiers to literals in a boolean expression that evaluates<br />

to TRUE or FALSE. Comparison operations can be combined into more complex expressions<br />

using the logical operators AND and OR. Expressions are evaluated from left to right:<br />

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

In this example, the expression would be evaluated as if it had parentheses placed as<br />

follows:<br />

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

Either the LName must be equal to 'Smith' or the LName can be any value as long as the Age<br />

is less than 30 and the Weight is greater than or equal to 100. Evaluating these kinds of<br />

expressions should be second nature for most programmers.<br />

The following message selector uses three of the six algebraic comparison operators,<br />

which are =, >, >=, = 100.00 OR LName LIKE 'Sm%th'<br />

The LIKE comparison operator attempts to match each character in the literal with<br />

characters of the property value. Two special wildcard characters, underscore (_) and<br />

percent (%), can be used with the LIKE comparison. The underscore stands for any single<br />

character. The percent symbol stands for any sequence of characters. All other characters<br />

stand for themselves and are case sensitive. Table D.1 provides some examples of<br />

successful and unsuccessful comparisons using the LIKE operator.<br />

Table D.1. Comparisons Using the LIKE Operator<br />

Expression True for Values False for Values<br />

LName LIKE 'Sm_th' Smith, Smeth, Sm4th Smooth, Smth, Smiths<br />

LName LIKE 'Smit_' Smith, Smitt, Smit4 Smoth, Smiths<br />

LName LIKE 'Sm%th' Smith, Smoo3th, Smth Smott, Rmith, Smiths<br />

LName LIKE '%ith' Smith, Synoonith, ith Smoth, Smiths<br />

175

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!