KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > presumo > jms > selector > JmsBinaryAnd


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 JavaDoc;
24
25
26 /**
27  * Expression node for the SQL "AND"
28  *
29  * @author Dan Greff
30  */

31 final class JmsBinaryAnd extends JmsBinaryOperand
32 {
33   static {
34     STRING_REP = " AND "; // Used in unparse
35
}
36
37
38     /////////////////////////////////////////////////////////////////////////
39
// Static Methods //
40
/////////////////////////////////////////////////////////////////////////
41

42   static JmsBinaryAnd getInstance(JmsOperand lvalue, JmsOperand rvalue)
43   {
44     JmsBinaryAnd retval;
45
46     retval = (JmsBinaryAnd) getInstanceReflective(JmsOperand.JMS_BINARY_AND, lvalue, rvalue);
47     if (retval == null)
48       retval = new JmsBinaryAnd(lvalue, rvalue);
49
50     return retval;
51   }
52
53     /////////////////////////////////////////////////////////////////////////
54
// Constructor //
55
/////////////////////////////////////////////////////////////////////////
56
protected JmsBinaryAnd(JmsOperand lvalue, JmsOperand rvalue) {
57     super(lvalue, rvalue);
58   }
59
60     /////////////////////////////////////////////////////////////////////////
61
// Package Methods //
62
/////////////////////////////////////////////////////////////////////////
63
JmsOperand evaluate(Message JavaDoc msg) throws SelectorFalseException
64   {
65
66     JmsBooleanLiteral leftSide = (JmsBooleanLiteral) lvalue.evaluateOnce(msg);
67     
68     if (leftSide == JmsBooleanLiteral.FALSE || leftSide == JmsBooleanLiteral.UNKNOWN)
69       return leftSide;
70
71     JmsBooleanLiteral rightSide = (JmsBooleanLiteral) rvalue.evaluateOnce(msg);
72     return rightSide; // T ^ F = F ; T ^ T = T ; T ^ U = U
73
}
74
75   short getType() { return JmsOperand.JMS_BINARY_AND; }
76
77   
78 }
79
80
81
82
83
84
85
86
87
88
89
90
91
Popular Tags