KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > tools > doclets > standard > SplitIndexWriter


1 /* -*- Mode: JDE; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2  *
3  * This file is part of the debugger and core tools for the AspectJ(tm)
4  * programming language; see http://aspectj.org
5  *
6  * The contents of this file are subject to the Mozilla Public License
7  * Version 1.1 (the "License"); you may not use this file except in
8  * compliance with the License. You may obtain a copy of the License at
9  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is AspectJ.
17  *
18  * The Initial Developer of the Original Code is Xerox Corporation. Portions
19  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
20  * All Rights Reserved.
21  */

22 package org.aspectj.tools.doclets.standard;
23
24 import com.sun.javadoc.ClassDoc;
25 import com.sun.javadoc.MemberDoc;
26 import com.sun.tools.doclets.DirectoryManager;
27 import com.sun.tools.doclets.DocletAbortException;
28 import com.sun.tools.doclets.IndexBuilder;
29
30 import java.io.IOException JavaDoc;
31
32 public class SplitIndexWriter
33     extends com.sun.tools.doclets.standard.SplitIndexWriter
34 {
35
36     protected class Del extends AbstractIndexWriter {
37         public Del(String JavaDoc s, IndexBuilder i) throws IOException JavaDoc {
38             super(s, i);
39         }
40         public void print(String JavaDoc s) {
41             SplitIndexWriter.this.print(s);
42         }
43     }
44     final protected Del del;
45     {
46         Standard.quiet();
47         Del d = null;
48         try {
49             d = new Del(filename, indexbuilder);
50         } catch (Exception JavaDoc e) {
51             Standard.configuration().standardmessage.
52                 error("doclet.exception_encountered",
53                       e+"", filename);
54         } finally {
55             del = d;
56             Standard.speak();
57         }
58     }
59     protected void printMemberDesc(MemberDoc member) {
60         del.printMemberDesc(member);
61     }
62     protected void printClassInfo(ClassDoc cd) {
63         del.printClassInfo(cd);
64     }
65
66     public SplitIndexWriter(String JavaDoc path, String JavaDoc filename,
67                             String JavaDoc relpath, IndexBuilder indexbuilder,
68                             int prev, int next) throws IOException JavaDoc {
69         super(path, filename, relpath,
70               indexbuilder, prev, next);
71     }
72
73     public static void generate(IndexBuilder indexbuilder)
74                                 throws DocletAbortException {
75         SplitIndexWriter sw = null;
76         String JavaDoc filename = "";
77         String JavaDoc path = DirectoryManager.getPath("index-files");
78         String JavaDoc relpath = DirectoryManager.getRelativePath("index-files");
79         try {
80             for (int i = 0; i < indexbuilder.elements().length; i++) {
81                 int j = i + 1;
82                 int prev = (j == 1)? -1: i;
83                 int next = (j == indexbuilder.elements().length)? -1: j + 1;
84                 filename = "index-" + j +".html";
85                 (sw = new SplitIndexWriter(path, filename, relpath,
86                                            indexbuilder, prev, next)).
87                     generateIndexFile((Character JavaDoc)
88                                       indexbuilder.elements()[i]);
89             }
90         } catch (IOException JavaDoc e) {
91             Standard.configuration().
92                 standardmessage.error("doclet.exception_encountered",
93                                       e+"", filename);
94             throw new DocletAbortException();
95         } finally {
96             if (sw != null) sw.close();
97         }
98     }
99 }
100
Popular Tags