User: rinkrank
Date: 02/04/08 17:07:16
Modified: core/src/xdoclet DocletTask.java
Log:
-Dynamic loading of optional modules is partially working (subtasks work.
registering tag handlers doesn't)
-Translator no longer throws XDocletException
Revision Changes Path
1.33 +247 -231 xdoclet/core/src/xdoclet/DocletTask.java
Index: DocletTask.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/DocletTask.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -w -r1.32 -r1.33
--- DocletTask.java 4 Apr 2002 01:03:07 -0000 1.32
+++ DocletTask.java 9 Apr 2002 00:07:16 -0000 1.33
@@ -34,9 +34,28 @@
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Aslak Helles�y</a>
* @created June 19, 2001
- * @version $Revision: 1.32 $
+ * @version $Revision: 1.33 $
*/
-public class DocletTask extends XJavadocTask {
+public class DocletTask extends XJavadocTask
+{
+ // ant will replace the tag with the version propperty specified in build.xml
+ /**
+ * @todo-javadoc Describe the field
+ */
+ public final static String XDOCLET_VERSION = "@VERSION@";
+
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private final static String fileName = "xdoclet." + System.getProperty(
"user.name" ) + ".ser";
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private final static File DEFAULT_TMP_FILE = new File( System.getProperty(
"java.io.tmpdir" ), fileName );
+ /**
+ * @todo-javadoc Describe the field
+ */
+ private static File _tmpFile = DEFAULT_TMP_FILE;
/**
* @todo-javadoc Describe the field
*/
@@ -69,44 +88,86 @@
* @todo-javadoc Describe the field
*/
private ArrayList configParams = new ArrayList();
- // ant will replace the tag with the version propperty specified in build.xml
+
/**
- * @todo-javadoc Describe the field
+ * Describe what the DocletTask constructor does
+ *
+ * @todo-javadoc Write javadocs for constructor
*/
- public final static String XDOCLET_VERSION = "@VERSION@";
+ public DocletTask()
+ {
+ setClassname( "xdoclet.XDocletMain" );
+ // fork is default
+ setFork( true );
+ }
/**
- * @todo-javadoc Describe the field
+ * Gets the ConfigParams attribute of the DocletTask object
+ *
+ * @return The ConfigParams value
*/
- private final static String fileName = "xdoclet." +
System.getProperty("user.name") + ".ser";
+ public ArrayList getConfigParams()
+ {
+ return configParams;
+ }
+
/**
- * @todo-javadoc Describe the field
+ * Gets the MergeDir attribute of the DocletTask object
+ *
+ * @return The MergeDir value
*/
- private final static File DEFAULT_TMP_FILE = new
File(System.getProperty("java.io.tmpdir"), fileName);
+ public File getMergeDir()
+ {
+ return mergeDir;
+ }
+
/**
- * @todo-javadoc Describe the field
+ * Gets the ExcludedTags attribute of the DocletTask object
+ *
+ * @return The ExcludedTags value
*/
- private static File _tmpFile = DEFAULT_TMP_FILE;
+ public String getExcludedTags()
+ {
+ return excludedTags;
+ }
+ /**
+ * Gets the Templates attribute of the DocletTask object
+ *
+ * @return The Templates value
+ */
+ public ArrayList getTemplates()
+ {
+ return templates;
+ }
/**
- * Describe what the DocletTask constructor does
+ * Gets the DestDir attribute of the DocletTask object
*
- * @todo-javadoc Write javadocs for constructor
+ * @return The DestDir value
*/
- public DocletTask() {
- setClassname("xdoclet.XDocletMain");
- // fork is default
- setFork(true);
+ public File getDestDir()
+ {
+ return destDir;
}
+ /**
+ * Gets the Force attribute of the DocletTask object
+ *
+ * @return The Force value
+ */
+ public boolean isForce()
+ {
+ return force;
+ }
/**
* Sets the Sourcepath attribute of the DocletTask object
*
* @param path The new Sourcepath value
*/
- public void setSourcepath(Path path) {
+ public void setSourcepath( Path path )
+ {
System.out.println("sourcepath is deprecated. the preferred way to
design sources is via nested <fileset>");
String dir = path.toString();
@@ -116,137 +177,76 @@
fileSet.setIncludes("**/*.java");
}
-
/**
* Sets the PackageNames attribute of the DocletTask object
*
* @param src The new PackageNames value
*/
- public void setPackageNames(String src) {
+ public void setPackageNames( String src )
+ {
throw new BuildException("packageNames is obsolete since xjavadoc was
introduced. Use a fileset instead");
}
-
/**
* Sets the ExcludePackageNames attribute of the DocletTask object
*
* @param src The new ExcludePackageNames value
*/
- public void setExcludePackageNames(String src) {
+ public void setExcludePackageNames( String src )
+ {
throw new BuildException("excludePackageNames is obsolete since
xjavadoc was introduced. Use a fileset instead");
}
-
/**
* Sets the ExcludedTags attribute of the DocletTask object
*
* @param tags The new ExcludedTags value
*/
- public void setExcludedTags(String tags) {
+ public void setExcludedTags( String tags )
+ {
excludedTags = tags;
}
-
/**
* Sets the DestDir attribute of the DocletTask object
*
* @param dir The new DestDir value
*/
- public void setDestDir(File dir) {
+ public void setDestDir( File dir )
+ {
destDir = dir;
}
-
/**
* Sets the MergeDir attribute of the DocletTask object
*
* @param dir The new MergeDir value
*/
- public void setMergeDir(File dir) {
+ public void setMergeDir( File dir )
+ {
mergeDir = dir;
}
-
/**
* Sets the Force attribute of the DocletTask object
*
* @param force The new Force value
*/
- public void setForce(boolean force) {
+ public void setForce( boolean force )
+ {
this.force = force;
}
-
/**
* Sets the Xdoclettempfile attribute of the DocletTask object
*
* @param tmpFile The new Xdoclettempfile value
*/
- public void setXdoclettempfile(File tmpFile) {
+ public void setXdoclettempfile( File tmpFile )
+ {
_tmpFile = tmpFile;
}
-
- /**
- * Gets the ConfigParams attribute of the DocletTask object
- *
- * @return The ConfigParams value
- */
- public ArrayList getConfigParams() {
- return configParams;
- }
-
-
- /**
- * Gets the MergeDir attribute of the DocletTask object
- *
- * @return The MergeDir value
- */
- public File getMergeDir() {
- return mergeDir;
- }
-
-
- /**
- * Gets the ExcludedTags attribute of the DocletTask object
- *
- * @return The ExcludedTags value
- */
- public String getExcludedTags() {
- return excludedTags;
- }
-
-
- /**
- * Gets the Templates attribute of the DocletTask object
- *
- * @return The Templates value
- */
- public ArrayList getTemplates() {
- return templates;
- }
-
-
- /**
- * Gets the DestDir attribute of the DocletTask object
- *
- * @return The DestDir value
- */
- public File getDestDir() {
- return destDir;
- }
-
-
- /**
- * Gets the Force attribute of the DocletTask object
- *
- * @return The Force value
- */
- public boolean isForce() {
- return force;
- }
-
-
/**
* Describe the method
*
@@ -254,11 +254,11 @@
* @todo-javadoc Describe the method
* @todo-javadoc Describe the method parameter
*/
- public void addTemplate(TemplateSubTask subtask) {
+ public void addTemplate( TemplateSubTask subtask )
+ {
templates.add(subtask);
}
-
/**
* Describe the method
*
@@ -266,11 +266,11 @@
* @todo-javadoc Describe the method
* @todo-javadoc Describe the method parameter
*/
- public void addXmlTemplate(XmlSubTask subtask) {
+ public void addXmlTemplate( XmlSubTask subtask )
+ {
templates.add(subtask);
}
-
/**
* Describe the method
*
@@ -278,11 +278,11 @@
* @todo-javadoc Describe the method
* @todo-javadoc Describe the method parameter
*/
- public void addConfigParam(ConfigParameter config_param) {
+ public void addConfigParam( ConfigParameter config_param )
+ {
configParams.add(config_param);
}
-
/**
* Describe what the method does
*
@@ -290,38 +290,40 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- public void execute() throws BuildException {
- try {
+ public void execute() throws BuildException
+ {
+ try
+ {
// save the context and pass its filename as an arg to the main
save(getContext(), _tmpFile);
createArg().setValue(_tmpFile.getAbsolutePath());
super.execute();
- } catch (IOException e) {
+ }
+ catch( IOException e )
+ {
e.printStackTrace();
throw new BuildException(e);
}
}
-
/**
* Gets the SubTasks attribute of the DocletTask object
*
* @return The SubTasks value
*/
- protected List getSubTasks() {
+ protected List getSubTasks()
+ {
ArrayList true_subtasks = new ArrayList();
- for (int i = 0; i < templates.size(); i++) {
+ for( int i = 0; i < templates.size(); i++ )
+ {
TemplateSubTask holder = (TemplateSubTask)templates.get(i);
SubTask subtask = getSubTaskFromPlaceHolder(holder);
- if (subtask == null) {
- try {
+ if( subtask == null )
+ {
System.out.println(Translator.getString("couldnt_instantiate_subtask", new
String[]{holder.getSubTaskClassName()}));
- } catch (XDocletException xe) {
- System.out.println(xe.getMessage());
- }
continue;
}
@@ -331,7 +333,6 @@
return true_subtasks;
}
-
/**
* Gets the SubTaskFromPlaceHolder attribute of the DocletTask object
*
@@ -339,13 +340,16 @@
* @return The SubTaskFromPlaceHolder value
* @todo-javadoc Write javadocs for method parameter
*/
- protected SubTask getSubTaskFromPlaceHolder(TemplateSubTask holder) {
+ protected SubTask getSubTaskFromPlaceHolder( TemplateSubTask holder )
+ {
//no subtask class specified
- if (holder.getSubTaskClassName() == null) {
+ if( holder.getSubTaskClassName() == null )
+ {
return holder;
}
- try {
+ try
+ {
Class subtask_class =
Class.forName(holder.getSubTaskClassName());
TemplateSubTask subtask =
(TemplateSubTask)subtask_class.newInstance();
@@ -353,24 +357,31 @@
subtask.copyAttributesFrom(holder);
return subtask;
- } catch (ClassNotFoundException e) {
+ }
+ catch( ClassNotFoundException e )
+ {
return null;
- } catch (InstantiationException e) {
+ }
+ catch( InstantiationException e )
+ {
return null;
- } catch (IllegalAccessException e) {
+ }
+ catch( IllegalAccessException e )
+ {
return null;
}
}
-
/**
* Returns the singleton context object and creates it if not already created
* and registers it as the single instance.
*
* @return the singleton context object
*/
- protected DocletContext getContext() {
- if (context != null) {
+ protected DocletContext getContext()
+ {
+ if( context != null )
+ {
return context;
}
@@ -393,7 +404,6 @@
return context;
}
-
/**
* Gets the ConfigParams attribute of the DocletTask object
*
@@ -401,17 +411,20 @@
* @return The ConfigParams value
* @todo-javadoc Write javadocs for method parameter
*/
- protected HashMap getConfigParams(List subtasks) {
+ protected HashMap getConfigParams( List subtasks )
+ {
HashMap configs = new HashMap();
//config params of task
ConfigParamIntrospector.fillConfigParamsFor(this, configs);
//config params of substask
- for (int i = 0; i < subtasks.size(); i++) {
+ for( int i = 0; i < subtasks.size(); i++ )
+ {
SubTask sub_task = (SubTask)subtasks.get(i);
- if (sub_task != null) {
+ if( sub_task != null )
+ {
ConfigParamIntrospector.fillConfigParamsFor(sub_task,
configs);
//user defined params of SubTask
@@ -425,7 +438,6 @@
return configs;
}
-
/**
* Describe what the method does
*
@@ -433,20 +445,17 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- protected void validateOptions() throws BuildException {
+ protected void validateOptions() throws BuildException
+ {
super.validateOptions();
- try {
- if (destDir == null) {
+ if( destDir == null )
+ {
throw new
BuildException(Translator.getString("attribute_not_present_error", new
String[]{"destDir"}), location);
}
- } catch (XDocletException xe) {
- throw new BuildException(xe);
- }
validateSubTasks();
}
-
/**
* Describe what the method does
*
@@ -454,24 +463,29 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- protected void validateSubTasks() throws BuildException {
+ protected void validateSubTasks() throws BuildException
+ {
DocletContext context = getContext();
SubTask[] subtasks = context.getSubTasks();
- for (int i = 0; i < subtasks.length; i++) {
+ for( int i = 0; i < subtasks.length; i++ )
+ {
SubTask subtask = subtasks[i];
- if (subtask != null) {
- try {
+ if( subtask != null )
+ {
+ try
+ {
subtask.validateOptions();
- } catch (XDocletException ex) {
+ }
+ catch( XDocletException ex )
+ {
new BuildException(subtask.getSubTaskName() +
": " + ex.getMessage(), location);
}
}
}
}
-
/**
* Describe what the method does
*
@@ -483,9 +497,11 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for method parameter
*/
- private void fillWithUserDefinedConfigParams(HashMap configs, ArrayList
config_params, String prefix) {
+ private void fillWithUserDefinedConfigParams( HashMap configs, ArrayList
config_params, String prefix )
+ {
//config params declared with <configParam name="nnn" value="val"/>
- for (int i = 0; i < config_params.size(); i++) {
+ for( int i = 0; i < config_params.size(); i++ )
+ {
ConfigParameter config_param =
(ConfigParameter)config_params.get(i);
configs.put((prefix + config_param.getName()).toLowerCase(),
config_param.getValue());
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel
Sponsored by http://www.ThinkGeek.com/