1 /*
2 Copyright (C) 2004 Grid Systems, S.A.
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License, version 2, as
6 published by the Free Software Foundation.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 */
17 package com.gridsystems.beanfilter;
18
19 /**
20 * AND operation node.
21 *
22 * @author Rodrigo Ruiz
23 * @author Xmas
24 * @version 1.0
25 */
26 public class AndNode extends EvalNode {
27 /**
28 * Left operand.
29 */
30 private EvalNode lnode;
31
32 /**
33 * Right operand.
34 */
35 private EvalNode rnode;
36
37 /**
38 * Creates a new instance.
39 *
40 * @param token Token of AND expression
41 * @param lnode The left operand
42 * @param rnode The right operand
43 */
44 public AndNode(Token token, EvalValue lnode, EvalValue rnode) {
45 super(token.beginLine, token.beginColumn);
46 this.lnode = new BooleanNode(lnode);
47 this.rnode = new BooleanNode(rnode);
48 }
49
50 /**
51 * Gets the left node.
52 *
53 * @return The left node
54 */
55 public EvalNode getLeftValue() {
56 return lnode;
57 }
58
59 /**
60 * Gets the right node.
61 *
62 * @return The right node
63 */
64 public EvalNode getRightNode() {
65 return rnode;
66 }
67
68 /**
69 * {@inheritDoc}
70 */
71 @Override public String toString() {
72 return lnode.toString() + " AND " + rnode.toString();
73 }
74
75 /**
76 * {@inheritDoc}
77 */
78 @Override public boolean eval(Object src) throws EvalException {
79 return lnode != null && rnode != null && lnode.eval(src) && rnode.eval(src);
80 }
81 }