Browse Source

added sorting

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274070 13f79535-47bb-0310-9956-ffa450edef68
master
Erik Hatcher 22 years ago
parent
commit
58b3f9e697
1 changed files with 16 additions and 2 deletions
  1. +16
    -2
      proposal/xdocs/src/org/apache/tools/ant/xdoclet/IndexGen.java

+ 16
- 2
proposal/xdocs/src/org/apache/tools/ant/xdoclet/IndexGen.java View File

@@ -60,6 +60,9 @@ import org.apache.tools.ant.BuildException;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; 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 * Quick and dirty index.html generator for proposal/xdocs
@@ -74,6 +77,8 @@ public class IndexGen extends Task {
} }


public void execute() throws BuildException { public void execute() throws BuildException {
TreeMap data = new TreeMap();

String[] categories = rootDir.list(); String[] categories = rootDir.list();


StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
@@ -83,6 +88,7 @@ public class IndexGen extends Task {
int catCount = 0; int catCount = 0;
int taskCount = 0; int taskCount = 0;


// grab all categories and tasks
for (int i=0; i < categories.length; i++) { for (int i=0; i < categories.length; i++) {
String category = categories[i]; String category = categories[i];
File catDir = new File(rootDir, category); File catDir = new File(rootDir, category);
@@ -91,13 +97,22 @@ public class IndexGen extends Task {
continue; continue;
} }


String[] tasks = catDir.list();
Arrays.sort(tasks);

data.put(category, tasks);
}

Iterator iter = data.keySet().iterator();
while (iter.hasNext()) {
catCount++; catCount++;
String category = (String) iter.next();


sb.append("<h2>" + category + "</h2>"); sb.append("<h2>" + category + "</h2>");


sb.append("<ul>"); sb.append("<ul>");


String[] tasks = catDir.list();
String[] tasks = (String[]) data.get(category);


for (int j=0; j < tasks.length; j++) { for (int j=0; j < tasks.length; j++) {
taskCount++; taskCount++;
@@ -108,7 +123,6 @@ public class IndexGen extends Task {
} }


sb.append("</ul>"); sb.append("</ul>");

} }


sb.append("</body></html>"); sb.append("</body></html>");


Loading…
Cancel
Save