1
16package org.tp23.antinstaller.runtime;
17
18import org.tp23.antinstaller.InstallException;
19import org.tp23.antinstaller.InstallerContext;
20import org.tp23.antinstaller.page.Page;
21import org.tp23.antinstaller.page.SimpleInputPage;
22import org.tp23.antinstaller.runtime.logic.Expression;
23import org.tp23.antinstaller.runtime.logic.ExpressionBuilder;
24
25
26
39public class IfPropertyHelper {
40
41 private InstallerContext ctx = null;
42 public IfPropertyHelper(InstallerContext ctx){
43 this.ctx = ctx;
44 }
45
46
49 public boolean ifProperty(Page next) throws InstallException {
50 if(next instanceof SimpleInputPage) {
52 SimpleInputPage conditionalPage = (SimpleInputPage) next;
53 String ifProperty = conditionalPage.getIfProperty();
54 if (ifProperty != null) {
55 Expression expression;
56 try {
57 expression = ExpressionBuilder.parseLogicalExpressions( ctx.getInstaller().getResultContainer(),
58 ifProperty );
59 }
60 catch( ConfigurationException configExc ) {
61 throw new InstallException( "Error parsing ifProperty condition for page " + next.getName(),
62 configExc );
63 }
64 return expression.evaluate();
65 }
66
67 }
68 return true; }
70
71
74 public boolean ifTarget(Page next, Page[] pages){
75 if(next instanceof SimpleInputPage){
77 SimpleInputPage conditionalPage = (SimpleInputPage) next;
78 String ifTarget = conditionalPage.getIfTarget();
79 if (ifTarget != null) {
80 boolean show = false;
81 for (int p = 0; p < pages.length; p++) {
82 show |= pages[p].isTarget(ifTarget);
83 }
84 return show;
85 }
86 }
87 return true;
88 }
89}
90