1 28 29 package com.idaremedia.antx.flowcontrol.call; 30 31 import java.util.List ; 32 33 import org.apache.tools.ant.BuildException; 34 import org.apache.tools.ant.Project; 35 import org.apache.tools.ant.types.PropertySet; 36 37 import com.idaremedia.antx.AntX; 38 import com.idaremedia.antx.AntXFixture; 39 import com.idaremedia.antx.helpers.Tk; 40 import com.idaremedia.antx.solo.CopyPropertyTask; 41 42 64 65 public final class LocalTargetTask extends CallerTask 66 { 67 70 public LocalTargetTask() 71 { 72 super(AntX.flow+"callinline"); 73 } 74 75 76 77 81 public LocalTargetTask(String iam) 82 { 83 super(iam); 84 } 85 86 90 91 96 public void setTargets(String setOfTargetNames) 97 { 98 require_(setOfTargetNames!=null,"setTargets- nonzro names"); 99 if (m_targetNames!=null) { 100 String error = uistrs().get("task.one.or.other.attr","targets","steps"); 101 log(error,Project.MSG_ERR); 102 throw new BuildException(error,getLocation()); 103 } 104 m_targetNames = setOfTargetNames; 105 m_topLevel = true; 106 } 107 108 109 110 117 public final void setSuper(String importedProjectName) 118 { 119 require_(importedProjectName!=null,"setSuper- nonzro projectname"); 120 verifyInTarget_("setsuper"); 121 String mytarget = getOwningTarget().getName(); 122 setTargets(importedProjectName+"."+mytarget); 123 } 124 125 126 127 132 public final String getTargetNamesList() 133 { 134 return m_topLevel ? m_targetNames : null; 135 } 136 137 138 139 144 public void setSteps(String setOfStepNames) 145 { 146 require_(setOfStepNames!=null,"setSteps- nonzro names"); 147 if (m_targetNames!=null) { 148 String error = uistrs().get("task.one.or.other.attr","targets","steps"); 149 log(error,Project.MSG_ERR); 150 throw new BuildException(error,getLocation()); 151 } 152 m_targetNames = setOfStepNames; 153 m_topLevel = false; 154 } 155 156 157 158 163 public final String getStepNamesList() 164 { 165 return m_topLevel ? null : m_targetNames; 166 } 167 168 169 170 177 public void addProperty(CopyPropertyTask param) 178 { 179 require_(param!=null,"addProperty- nonzro item"); 180 getParametersKeeper().addParameter(param); 181 } 182 183 184 185 192 public void addPropertySet(PropertySet param) 193 { 194 require_(param!=null,"addPropertySet- nonzro item"); 195 getParametersKeeper().addParameter(param); 196 } 197 198 199 200 206 protected void verifyCanExecute_(String calr) 207 { 208 super.verifyCanExecute_(calr); 209 210 if (m_targetNames==null) { 211 String error = uistrs().get("task.needs.this.attr", 212 getTaskName(),"targets|steps"); 213 log(error,Project.MSG_ERR); 214 throw new BuildException(error,getLocation()); 215 } 216 217 List l= Tk.splitList(m_targetNames); 218 m_targets = l; 219 220 if (m_topLevel) { 221 String tn; 222 for (int i=0,N=l.size();i<N;i++) { 223 tn = l.get(i).toString(); 224 if (!targetExists(tn)) { 225 String error = uistrs().get 226 ("flow.steplaunch.missing.target",tn,getProject().getName()); 227 log(error,Project.MSG_ERR); 228 throw new BuildException(error,getLocation()); 229 } 230 } 231 } 232 } 233 234 235 241 protected List copyOfOrderedTargetCallers() 242 { 243 verify_(m_targets!=null,"copyOf- been verified"); 244 245 List l= m_targets; 246 List callers= AntXFixture.newList(l.size()); 247 String tn; 248 LocalTargetCaller caller; 249 250 for (int i=0,N=l.size();i<N;i++) { 251 tn = l.get(i).toString(); 252 caller = new LocalTargetCaller(this); 253 if (m_topLevel) { 254 caller.setTarget(tn); 255 } else { 256 caller.setStepName(tn); 257 } 258 transferOverlayParameters(caller); 259 callers.add(caller); 260 } 261 262 return callers; 263 } 264 265 266 267 private String m_targetNames; 268 private List m_targets; 269 private boolean m_topLevel=true;} 271 272 273 | Popular Tags |