| 1 28 29 package com.idaremedia.antx.condition; 30 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.Project; 33 34 import com.idaremedia.antx.FlexString; 35 import com.idaremedia.antx.StringEquality; 36 import com.idaremedia.antx.parameters.IgnoreCaseEnabled; 37 import com.idaremedia.antx.parameters.TrimEnabled; 38 import com.idaremedia.antx.parameters.ValueMatchEnabled; 39 40 62 63 public final class Matches extends FlexCondition 64 implements IgnoreCaseEnabled, TrimEnabled, ValueMatchEnabled 65 { 66 69 public Matches() 70 { 71 super(); 72 m_impl.setOperator(StringEquality.OP_MATCHES); 73 getValueHelper().setLenient(false); 74 } 75 76 77 82 public Matches(String pattern, Project P) 83 { 84 this(); 85 setProject(P); 86 setPattern(pattern); 87 } 88 89 90 94 public void setProject(Project P) 95 { 96 super.setProject(P); 97 m_impl.setProject(P); 98 } 99 100 101 105 protected final FlexString getValueHelper() 106 { 107 return m_impl.getUnknownValueGetter(); 108 } 109 110 111 115 119 public void setPattern(String pattern) 120 { 121 require_(pattern!=null,"setPattern- nonzro"); 122 m_impl.setKnownArg(pattern); 123 } 124 125 126 130 public final String getPattern() 131 { 132 return m_impl.getKnownArg(); 133 } 134 135 136 141 public final void setMatch(String pattern) 142 { 143 setPattern(pattern); 144 } 145 146 147 151 public final void setValue(String value) 152 { 153 require_(value!=null,"setValue- nonzro"); 154 setLiteral(value); 155 } 156 157 158 159 163 public void setTrim(boolean trim) 164 { 165 getValueHelper().setTrim(trim); 166 } 167 168 169 173 public final boolean willTrim() 174 { 175 return getValueHelper().isTrimmed(); 176 } 177 178 179 180 184 public void setIgnoreCase(boolean ignore) 185 { 186 getValueHelper().setIgnoreCase(ignore); 187 } 188 189 190 194 public final boolean isIgnoreCase() 195 { 196 return getValueHelper().isIgnoreCase(); 197 } 198 199 200 204 207 public boolean eval() 208 { 209 verifyCanEvaluate_("eval"); 210 211 return m_impl.eval(); 212 } 213 214 215 221 protected void verifyCanEvaluate_(String calr) 222 { 223 super.verifyCanEvaluate_(calr); 224 225 if (getPattern()==null) { 226 String ermsg = uistrs().get("task.needs.this.attr", 227 getTypicalName(),"pattern"); 228 log(ermsg,Project.MSG_ERR); 229 throw new BuildException(ermsg); 230 } 231 } 232 233 234 private final StringEquality m_impl = new StringEquality(); 235 } 236 237 238 | Popular Tags |