ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet IndexGen.java
Date Fri, 14 Feb 2003 16:30:55 GMT
ehatcher    2003/02/14 08:30:55

  Modified:    proposal/xdocs/src/org/apache/tools/ant/xdoclet
                        IndexGen.java
  Log:
  added sorting
  
  Revision  Changes    Path
  1.3       +16 -2     ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/IndexGen.java
  
  Index: IndexGen.java
  ===================================================================
  RCS file: /home/cvs/ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/IndexGen.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IndexGen.java	5 Feb 2003 08:42:48 -0000	1.2
  +++ IndexGen.java	14 Feb 2003 16:30:55 -0000	1.3
  @@ -60,6 +60,9 @@
   import java.io.File;
   import java.io.FileWriter;
   import java.io.IOException;
  +import java.util.TreeMap;
  +import java.util.Arrays;
  +import java.util.Iterator;
   
   /**
    * Quick and dirty index.html generator for proposal/xdocs
  @@ -74,6 +77,8 @@
       }
   
       public void execute() throws BuildException {
  +        TreeMap data = new TreeMap();
  +
           String[] categories = rootDir.list();
   
           StringBuffer sb = new StringBuffer();
  @@ -83,6 +88,7 @@
           int catCount = 0;
           int taskCount = 0;
   
  +        // grab all categories and tasks
           for (int i=0; i < categories.length; i++) {
               String category = categories[i];
               File catDir = new File(rootDir, category);
  @@ -91,13 +97,22 @@
                   continue;
               }
   
  +            String[] tasks = catDir.list();
  +            Arrays.sort(tasks);
  +
  +            data.put(category, tasks);
  +        }
  +
  +        Iterator iter = data.keySet().iterator();
  +        while (iter.hasNext()) {
               catCount++;
  +            String category = (String) iter.next();
   
               sb.append("<h2>" + category + "</h2>");
   
               sb.append("<ul>");
   
  -            String[] tasks = catDir.list();
  +            String[] tasks = (String[]) data.get(category);
   
               for (int j=0; j < tasks.length; j++) {
                   taskCount++;
  @@ -108,7 +123,6 @@
               }
   
               sb.append("</ul>");
  -
           }
   
           sb.append("</body></html>");
  
  
  

Mime
View raw message