01: package org.ofbiz.rules.logikus;
02:
03: import java.util.*;
04: import org.ofbiz.rules.engine.*;
05: import org.ofbiz.rules.parse.*;
06:
07: /**
08: * <p><b>Title:</b> Axiom 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 the structures of a rule from an assembly's stack,
33: * and constructs and pushes a rule.
34: *
35: * @author Steven J. Metsker
36: * @version 1.0
37: */
38: public class AxiomAssembler extends Assembler {
39:
40: /**
41: * Pops all of the structures on the stack, builds a rule
42: * from them, and pushes it.
43: *
44: * @param Assembly the assembly to work on
45: */
46: public void workOn(Assembly a) {
47: Stack s = a.getStack();
48: Structure[] sa = new Structure[s.size()];
49:
50: for (int i = 0; i < s.size(); i++) {
51: sa[i] = (Structure) s.get(i);
52: }
53: s.removeAllElements();
54: a.push(new Rule(sa));
55: }
56: }
|