1 28 29 package com.idaremedia.antx.go; 30 31 import org.apache.tools.ant.Project; 32 33 import com.idaremedia.antx.helpers.Tk; 34 35 47 48 public final class Iff 49 { 50 58 public static final boolean allowed(String property, Project P) 59 { 60 return allowed(property,P,false); 61 } 62 63 64 65 76 public static final boolean allowed(String property, Project P, 77 boolean onlyIfTrue) 78 { 79 if (property==null || "".equals(property)) { 80 return true; 81 } 82 String test = Tk.resolveString(P,property); 83 if (onlyIfTrue) { 84 return Tk.booleanFrom(P.getProperty(test)); } 86 return P.getProperty(test)!=null; 87 } 88 89 90 91 100 public static final class Exists extends Go.TestSkeleton { 101 public Exists() { 102 } 103 public Exists(String property) { 104 super(property); 105 } 106 public boolean pass(Project P) { 107 verifyInited(); 108 return Iff.allowed(getParameter(),P,false); 109 } 110 public String getParameterName() { 111 return "if"; 112 } 113 } 114 115 116 125 public static final class IsTrue extends Go.TestSkeleton { 126 public IsTrue() { 127 } 128 public IsTrue(String list) { 129 super(list); 130 } 131 public boolean pass(Project P) { 132 verifyInited(); 133 return Iff.allowed(getParameter(),P,true); 134 } 135 public String getParameterName() { 136 return "ifTrue"; 137 } 138 } 139 140 141 142 152 public static final class NotExists extends Go.TestSkeleton { 153 public NotExists() { 154 } 155 public NotExists(String property) { 156 super(property); 157 } 158 public boolean pass(Project P) { 159 verifyInited(); 160 return Unless.allowed(getParameter(),P,false); 161 } 162 public String getParameterName() { 163 return "unless"; 164 } 165 } 166 167 168 178 public static final class IsNotTrue extends Go.TestSkeleton { 179 public IsNotTrue() { 180 } 181 public IsNotTrue(String list) { 182 super(list); 183 } 184 public boolean pass(Project P) { 185 verifyInited(); 186 return Unless.allowed(getParameter(),P,true); 187 } 188 public String getParameterName() { 189 return "unlessTrue"; 190 } 191 } 192 193 194 195 private Iff() 196 { 197 } 198 } 199 200 201 | Popular Tags |