/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Pizzadoc * by Enno Runne * * Copyright (C) 1997 Enno Runne. All rights reserved. * Permission is hereby granted to modify and use this software for research * and teaching purposes. Modification for commercial purposes requires * prior written permission by the author. * The software, or modifications thereof, may be redistributed only * if this copyright notice stays attached. *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ package pizza.pizzadoc; import java.io.File; import java.io.FileOutputStream; import java.io.PrintStream; import java.io.IOException; import pizza.lang.List; import pizza.util.Vector; import pizza.contrib.SortedVector; import pizza.v39.*; /** * Generates the all names index page. * @see DocSwitches.pizzadoc_index * @author Enno Runne * @since v38 */ class DocIndex implements /*imports*/ DocConstants { /** The used filename. */ static final String filename = DocHTML.indexFileName; /** * The Vector with all ASTs that will be shown in the index. */ private static SortedVector v = new SortedVector(DocAST.allocAST, null, compare); /** * Compares the names of two ASTs. */ private static int compare(AST e1, AST e2) { String s1 = "", s2 = ""; if (e1 != null) s1 = DocSymbol.toN_NoLink(e1.symbol()); if (e2 != null) s2 = DocSymbol.toN_NoLink(e2.symbol()); return s1.toLowerCase().compareTo(s2.toLowerCase()); } /** * Adds the def to the index Vector. * @see DocSwitches.pizzadoc_index */ static void add(AST def) { if (!DocSwitches.pizzadoc_index) return; v.insert(def); } /** * Prints the index to p. */ static void print(PrintStream p) { char old = '\t'; for (int i=0; i < v.size(); i++) { Symbol sym = v.elementAt(i).symbol(); String s = DocSymbol.toN_NoLink(sym).toUpperCase(); if (s.charAt(0) != old) { old = s.charAt(0); p.println("
"); p.println("A"); p.println("B"); p.println("C"); p.println("D"); p.println("E"); p.println("F"); p.println("G"); p.println("H"); p.println("I"); p.println("J"); p.println("K"); p.println("L"); p.println("M"); p.println("N"); p.println("O"); p.println("P"); p.println("Q"); p.println("R"); p.println("S"); p.println("T"); p.println("U"); p.println("V"); p.println("W"); p.println("X"); p.println("Y"); p.println("Y"); p.println("
"); p.println("

"+old+"

"); } p.println(DocSymbol.toN(sym)+" "+DocAST.info(v.elementAt(i))); p.println("

"); } } /** * Generates the index page. */ static void print() { if (!DocSwitches.pizzadoc_index) return; System.out.println("generating "+filename); try { File fi = Doc.getFile(filename); PrintStream f = new PrintStream(new FileOutputStream(fi)); DocHTML.printHeader(f, "Classes, Fields and Methods", List.cons(DocHTML.allPackages, DocHTML.classHierarchy) ); f.println("

Classes, Fields and Methods

"); print(f); DocHTML.printFoot(f, List.cons(DocHTML.pizzaHome, DocHTML.classHierarchy), filename); f.close(); } catch (IOException e) { Doc.reportIOException(e); } } }