01: package org.wings.macro;
02:
03: import org.mvel.MVEL;
04:
05: /**
06: * <code>WhileMacro<code>.
07: * <p/>
08: * User: rrd
09: * Date: 14.08.2007
10: * Time: 08:52:44
11: *
12: * @author rrd
13: * @version $Id
14: */
15: public class WhileMacro extends AbstractMacro {
16:
17: private String condition;
18:
19: public WhileMacro(String condition) {
20: this .condition = condition;
21: }
22:
23: private boolean condition(MacroContext ctx) {
24: return MVEL.evalToBoolean(condition, ctx);
25: }
26:
27: public void execute(MacroContext ctx) {
28: while (condition(ctx)) {
29: for (Instruction instruction : instructions) {
30: instruction.execute(ctx);
31: }
32: }
33: }
34: }
|