1 28 29 package com.idaremedia.antx.condition.solo; 30 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.Project; 33 import org.apache.tools.ant.TaskAdapter; 34 import org.apache.tools.ant.taskdefs.condition.Condition; 35 36 import com.idaremedia.antx.Iteration; 37 import com.idaremedia.antx.apis.Requester; 38 import com.idaremedia.antx.helpers.Strings; 39 40 49 50 public final class RulesTk 51 { 52 private RulesTk() 53 { 54 } 56 57 58 67 public static boolean evalTest(String testId, Requester clnt) 68 { 69 ConditionValueURIHandler runner = new ConditionValueURIHandler(); 70 String result = runner.valueFrom(testId,"$test:"+testId, clnt); 71 return Strings.TRUE.equals(result); 72 } 73 74 75 76 86 public static void verifyTest(String refid, Requester clnt) 87 { 88 if (refid==null || clnt==null) { 89 throw new IllegalArgumentException (); 90 } 91 String error = null; 92 Object ref = clnt.getProject().getReference(refid); 93 if (ref==null) { 94 error = Iteration.uistrs().get("task.missing.refid",refid); 95 } else { 96 if (ref instanceof TaskAdapter) { 97 ref = ((TaskAdapter)ref).getProxy(); 98 } 99 if (!(ref instanceof Condition) && !(ref instanceof ShareableCondition)) { 100 error = Iteration.uistrs().get("task.bad.refid",refid, 101 Condition.class.getName(), ref.getClass().getName()); 102 } 103 } 104 105 if (error!=null) { 106 clnt.problem(error, Project.MSG_ERR); 107 throw new BuildException(error, clnt.getLocation()); 108 } 109 } 110 } 111 112 | Popular Tags |