Source code: com/presumo/jms/selector/JmsLess.java
1 /**
2 * This file is part of Presumo.
3 *
4 * Presumo is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * Presumo is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with Presumo; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 *
19 * Copyright 2001 Dan Greff
20 */
21 package com.presumo.jms.selector;
22
23 import javax.jms.Message;
24
25 /**
26 * Expression node for the SQL less than expression. There is no
27 * implementation for less than equals "<=" because the parser
28 * represents such statements as a greater than with the operands
29 * switched.
30 *
31 * @author Dan Greff
32 */
33 final class JmsLess extends JmsBinaryOperand
34 {
35 static
36 {
37 STRING_REP = " < "; // Used in unparse
38 }
39
40 /////////////////////////////////////////////////////////////////////////
41 // Static Methods //
42 /////////////////////////////////////////////////////////////////////////
43
44 static JmsLess getInstance(JmsOperand lvalue, JmsOperand rvalue)
45 {
46 JmsLess retval;
47
48 retval = (JmsLess) getInstanceNonReflective(JmsOperand.JMS_LESS, lvalue, rvalue);
49 if (retval == null)
50 retval = new JmsLess(lvalue, rvalue);
51
52 return retval;
53 }
54
55 /////////////////////////////////////////////////////////////////////////
56 // Constructor //
57 /////////////////////////////////////////////////////////////////////////
58 protected JmsLess(JmsOperand lvalue, JmsOperand rvalue)
59 {
60 super(lvalue, rvalue);
61 }
62
63
64
65 /////////////////////////////////////////////////////////////////////////
66 // Package Methods //
67 /////////////////////////////////////////////////////////////////////////
68
69 JmsOperand evaluate(Message msg) throws SelectorFalseException
70 {
71
72 try {
73 JmsNumericLiteral leftSide = (JmsNumericLiteral) lvalue.evaluateOnce(msg);
74 JmsNumericLiteral rightSide = (JmsNumericLiteral) rvalue.evaluateOnce(msg);
75
76 if (leftSide == null || rightSide == null)
77 return JmsBooleanLiteral.UNKNOWN;
78
79 return leftSide.lt(rightSide);
80 } catch (ClassCastException e) {
81 throw SelectorFalseException.getInstance();
82 }
83 }
84
85 short getType() { return JmsOperand.JMS_LESS; }
86
87 }
88
89
90
91