1 5 package xdoclet; 6 7 import java.io.File ; 8 import java.io.Serializable ; 9 import java.util.ArrayList ; 10 import java.util.List ; 11 import java.util.Map ; 12 13 import org.apache.commons.logging.Log; 14 import xjavadoc.XJavaDoc; 15 16 import xdoclet.util.LogUtil; 17 18 31 public abstract class SubTask extends DocletSupport implements Serializable 32 { 33 private XJavaDoc _xJavaDoc; 34 35 38 private File destDir = null; 39 40 45 private File mergeDir = null; 46 47 private ArrayList configParams = new ArrayList (); 48 49 56 private String subTaskName; 57 58 63 public final String getSubTaskName() 64 { 65 if (subTaskName != null) { 66 return subTaskName; 67 } 68 69 return DocletTask.getSubTaskName(getClass()); 70 } 71 72 77 public List getConfigParams() 78 { 79 return configParams; 80 } 81 82 public Map getConfigParamsAsMap() 83 { 84 return DocletTask.getConfigParamsAsMap(getConfigParams()); 85 } 86 87 88 93 public File getDestDir() 94 { 95 return destDir; 96 } 97 98 103 public File getMergeDir() 104 { 105 return mergeDir; 106 } 107 108 113 public void setSubTaskName(String subTaskName) 114 { 115 this.subTaskName = subTaskName; 116 } 117 118 123 public void setDestDir(File destDir) 124 { 125 this.destDir = destDir; 126 } 127 128 133 public void setMergeDir(File mergeDir) 134 { 135 this.mergeDir = mergeDir; 136 } 137 138 143 public void addConfigParam(ConfigParameter configParam) 144 { 145 configParams.add(configParam); 146 } 147 148 153 public void copyAttributesFrom(TemplateSubTask src) 154 { 155 setDestDir(src.getDestDir()); 156 setMergeDir(src.getMergeDir()); 157 for (int i = 0; i < src.getConfigParams().size(); i++) { 158 addConfigParam((ConfigParameter) src.getConfigParams().get(i)); 159 } 160 setSubTaskName(src.getSubTaskName()); 161 } 162 163 170 public void init(XJavaDoc xJavaDoc) throws XDocletException 171 { 172 if (xJavaDoc == null) { 173 throw new XDocletException("xJavaDoc can't be null"); 174 } 175 _xJavaDoc = xJavaDoc; 176 177 Log log = LogUtil.getLog(SubTask.class, "init"); 178 179 log.debug("mergeDir = " + mergeDir); 180 181 if (destDir == null) { 182 log.debug("destDir inherited it from task"); 184 destDir = new File (getContext().getDestDir()); 185 } 186 187 log.debug("destDir = " + destDir); 188 189 if (mergeDir == null && getContext().getMergeDir() != null) { 190 log.debug("mergeDir inherited it from task"); 192 mergeDir = new File (getContext().getMergeDir()); 193 } 194 195 log.debug("mergeDir = " + mergeDir); 196 } 197 198 203 public abstract void execute() throws XDocletException; 204 205 210 public void validateOptions() throws XDocletException 211 { 212 } 213 214 219 protected DocletContext getContext() 220 { 221 return DocletContext.getInstance(); 222 } 223 224 protected XJavaDoc getXJavaDoc() 225 { 226 return _xJavaDoc; 227 } 228 } 229 | Popular Tags |