01: package org.ofbiz.rules.logikus;
02:
03: import org.ofbiz.rules.parse.*;
04: import org.ofbiz.rules.parse.tokens.*;
05: import org.ofbiz.rules.engine.*;
06:
07: /**
08: * <p><b>Title:</b> Comparison Assembler
09: * <p><b>Description:</b> None
10: * <p>Copyright (c) 1999 Steven J. Metsker.
11: * <p>Copyright (c) 2001 The Open For Business Project - www.ofbiz.org
12: *
13: * <p>Permission is hereby granted, free of charge, to any person obtaining a
14: * copy of this software and associated documentation files (the "Software"),
15: * to deal in the Software without restriction, including without limitation
16: * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17: * and/or sell copies of the Software, and to permit persons to whom the
18: * Software is furnished to do so, subject to the following conditions:
19: *
20: * <p>The above copyright notice and this permission notice shall be included
21: * in all copies or substantial portions of the Software.
22: *
23: * <p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24: * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25: * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26: * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
27: * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
28: * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
29: * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30: *
31: * <br>
32: * <p>Pops two comparison terms and an operator, builds
33: * the comparison, and pushes it.
34: *
35: * @author Steven J. Metsker
36: * @version 1.0
37: */
38: public class ComparisonAssembler extends Assembler {
39:
40: /**
41: * Pops two comparison terms and an operator, builds
42: * the comparison, and pushes it.
43: *
44: * @param Assembly the assembly to work on
45: */
46: public void workOn(Assembly a) {
47: ComparisonTerm second = (ComparisonTerm) a.pop();
48: ComparisonTerm first = (ComparisonTerm) a.pop();
49: Token t = (Token) a.pop();
50:
51: a.push(new Comparison(t.sval(), first, second));
52: }
53: }
|