1 28 29 package com.idaremedia.antx.ownhelpers; 30 31 import org.apache.tools.ant.BuildException; 32 import org.apache.tools.ant.Project; 33 34 import com.idaremedia.antx.AntX; 35 import com.idaremedia.antx.AssertableProjectComponent; 36 import com.idaremedia.antx.helpers.Tk; 37 import com.idaremedia.antx.parameters.IgnoreCaseEnabled; 38 import com.idaremedia.antx.parameters.PropertySource; 39 40 63 64 public class InnerProperties extends AssertableProjectComponent 65 implements IgnoreCaseEnabled, Cloneable 66 { 67 private static final String PATTERN="like"; 68 private static final String PREFIX="prefix"; 69 private static final String NOTLIKE="notlike"; 70 71 72 75 public InnerProperties() 76 { 77 super(AntX.nopackage); 78 } 79 80 81 85 public InnerProperties(String iam) 86 { 87 super(iam); 88 } 89 90 91 92 96 public Object clone() 97 { 98 try { 99 return super.clone(); 100 } catch(CloneNotSupportedException clnX) { 101 throw new CloneBrokenError(); 102 } 103 } 104 105 106 107 110 public void setLike(String pattern) 111 { 112 require_(!Tk.isWhitespace(pattern),"setLik- nonzro pattern"); 113 setNewFilter(PATTERN,pattern); 114 } 115 116 117 121 public String getLikeFilterPattern() 122 { 123 return getFilterParameter(PATTERN); 124 } 125 126 127 130 public void setPrefix(String prefix) 131 { 132 require_(prefix!=null,"setPrefx- nonzro prefix"); 133 setNewFilter(PREFIX,prefix); 134 } 135 136 137 141 public String getPrefixFilterPattern() 142 { 143 return getFilterParameter(PREFIX); 144 } 145 146 147 150 public void setNotLike(String pattern) 151 { 152 require_(!Tk.isWhitespace(pattern),"setNotLik- nonzro pattern"); 153 setNewFilter(NOTLIKE,pattern); 154 } 155 156 157 161 public String getNotLikeFilterPattern() 162 { 163 return getFilterParameter(NOTLIKE); 164 } 165 166 167 174 public void setDomain(String domainname) 175 { 176 PropertySource domain = PropertySource.from(domainname); 177 require_(domain!=null,"setDomain- nonzro domain"); 178 m_domain = domain; 179 } 180 181 182 187 public PropertySource getDomain() 188 { 189 return m_domain; 190 } 191 192 193 198 public void setIgnoreCase(boolean ignore) 199 { 200 m_ignoreCase = ignore; 201 } 202 203 204 208 public boolean isIgnoreCase() 209 { 210 return m_ignoreCase; 211 } 212 213 214 218 private void setNewFilter(String choice, String param) 219 { 220 if (m_filterType!=null) { 221 String error = uistrs().get 222 ("task.one.or.other.attr","like","prefix"); 223 log(error, Project.MSG_ERR); 224 throw new BuildException(error); 225 } 226 m_filterType = choice; 227 m_filterParameter = param; 228 } 229 230 231 235 private String getFilterParameter(String choice) 236 { 237 return (m_filterType==choice) ? m_filterParameter : null; 238 } 239 240 241 private String m_filterType; 242 private String m_filterParameter; 243 private PropertySource m_domain = PropertySource.SCRIPTlite; 244 private boolean m_ignoreCase; 245 } 246 247 248 | Popular Tags |