package com.oreilly.javaxp.xdoclet.perf;
import xdoclet.TemplateSubTask;
import xdoclet.XDocletException;
/**
* @ant.element
* name="junitperf"
* parent="xdoclet.DocletTask"
*
* @author Brian M. Coyner
* @version $Id: JUnitPerfDocletSubTask.java,v 1.9 2002/11/23 03:54:55 jepc Exp $
*/
public class JUnitPerfDocletSubTask extends TemplateSubTask {
public static final String DEFAULT_TEMPLATE =
"/com/oreilly/javaxp/xdoclet/perf/junitperf.xdt";
public static final String DEFAULT_JUNIT_PERF_PATTERN =
"TestPerf{0}.java";
/**
* Constructs this subtask with a default 'destinationFile' and
* default template file.
*/
public JUnitPerfDocletSubTask() {
setDestinationFile(DEFAULT_JUNIT_PERF_PATTERN);
setTemplateURL(getClass().getResource(DEFAULT_TEMPLATE));
}
/**
* Used by {@link JUnitPerfTagHandler} to generate the new class name.
* Before returning the '.java. extension is stripped off.
*
* @return the JUnitPerf file pattern with the '.java' extension removed.
*/
public String getJUnitPerfPattern() {
return getDestinationFile().
substring(0, getDestinationFile().indexOf(".java"));
}
/**
* Overridden to validate the 'destinationFile' attribute. This attribute
* must include a '{0}', which serves as a place holder for the JUnit
* test name.
*/
public void validateOptions() throws XDocletException {
super.validateOptions();
if (getDestinationFile().indexOf("{0}") == -1) {
throw new XDocletException(
"The '" + getSubTaskName() +
"' Ant Doclet Subtask attribute 'destinationFile' " +
"must contain the substring '{0}', which serves as a " +
"place holder JUnit Test name.");
}
}
}
|