KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > xdoclet > modules > doc > ModuleTagsHandler


1 /*
2  * Copyright (c) 2001, 2002 The XDoclet team
3  * All rights reserved.
4  */

5 package xdoclet.modules.doc;
6
7 import java.io.File JavaDoc;
8
9 import java.util.List JavaDoc;
10 import xdoclet.ConfigParameter;
11
12 import xdoclet.XDocletException;
13 import xdoclet.XDocletTagSupport;
14
15 /**
16  * This tag handler is kinda special. It loops over the module directories in the modules directory and is only used to
17  * generate links to XDoclet tag docs. Pretty dirty, but it gets the job done.
18  *
19  * @author Aslak Hellesoy
20  * @created 13. juni 2002
21  * @xdoclet.taghandler namespace="Module"
22  * @version $Revision: 1.3 $
23  */

24 public class ModuleTagsHandler extends XDocletTagSupport
25 {
26     private String JavaDoc currentModule;
27
28     private static boolean isModule(File JavaDoc file)
29     {
30         File JavaDoc module_build_xml = new File JavaDoc(file, "build.xml");
31
32         return (!file.getName().equalsIgnoreCase("build")) && (!file.getName().equalsIgnoreCase("cvs")) && module_build_xml.exists();
33     }
34
35     public String JavaDoc moduleName()
36     {
37         return currentModule;
38     }
39
40     /**
41      * Iterates over all modules
42      *
43      * @param template The body of the block tag
44      * @exception XDocletException Description of Exception
45      * @doc.tag type="block"
46      */

47     public void forAllModules(String JavaDoc template) throws XDocletException
48     {
49         List JavaDoc cps = getDocletContext().getActiveSubTask().getConfigParams();
50         ConfigParameter cp = (ConfigParameter) cps.get(0);
51         File JavaDoc moduleParentDir = new File JavaDoc(cp.getValue());
52         File JavaDoc[] moduleDirs = moduleParentDir.listFiles();
53
54         for (int i = 0; i < moduleDirs.length; i++) {
55             if (isModule(moduleDirs[i])) {
56                 currentModule = moduleDirs[i].getName();
57                 generate(template);
58             }
59         }
60     }
61 }
62
Popular Tags