Thu, 13 Jan 2011 21:28:38 -0800
7010528: javadoc performance regression
Reviewed-by: jjg
duke@1 | 1 | /* |
ohair@798 | 2 | * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. |
duke@1 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@1 | 4 | * |
duke@1 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@1 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ohair@554 | 7 | * published by the Free Software Foundation. Oracle designates this |
duke@1 | 8 | * particular file as subject to the "Classpath" exception as provided |
ohair@554 | 9 | * by Oracle in the LICENSE file that accompanied this code. |
duke@1 | 10 | * |
duke@1 | 11 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@1 | 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@1 | 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@1 | 14 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@1 | 15 | * accompanied this code). |
duke@1 | 16 | * |
duke@1 | 17 | * You should have received a copy of the GNU General Public License version |
duke@1 | 18 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@1 | 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@1 | 20 | * |
ohair@554 | 21 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
ohair@554 | 22 | * or visit www.oracle.com if you need additional information or have any |
ohair@554 | 23 | * questions. |
duke@1 | 24 | */ |
duke@1 | 25 | |
duke@1 | 26 | package com.sun.tools.doclets.formats.html; |
duke@1 | 27 | |
bpatel@766 | 28 | import java.io.*; |
duke@1 | 29 | import com.sun.tools.doclets.internal.toolkit.util.*; |
bpatel@766 | 30 | import com.sun.tools.doclets.formats.html.markup.*; |
bpatel@766 | 31 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 32 | |
duke@1 | 33 | /** |
duke@1 | 34 | * Generate only one index file for all the Member Names with Indexing in |
duke@1 | 35 | * Unicode Order. The name of the generated file is "index-all.html" and it is |
duke@1 | 36 | * generated in current or the destination directory. |
duke@1 | 37 | * |
duke@1 | 38 | * @see java.lang.Character |
duke@1 | 39 | * @author Atul M Dambalkar |
bpatel@766 | 40 | * @author Bhavesh Patel (Modified) |
duke@1 | 41 | */ |
duke@1 | 42 | public class SingleIndexWriter extends AbstractIndexWriter { |
duke@1 | 43 | |
duke@1 | 44 | /** |
duke@1 | 45 | * Construct the SingleIndexWriter with filename "index-all.html" and the |
duke@1 | 46 | * {@link IndexBuilder} |
duke@1 | 47 | * |
duke@1 | 48 | * @param filename Name of the index file to be generated. |
duke@1 | 49 | * @param indexbuilder Unicode based Index from {@link IndexBuilder} |
duke@1 | 50 | */ |
duke@1 | 51 | public SingleIndexWriter(ConfigurationImpl configuration, |
duke@1 | 52 | String filename, |
duke@1 | 53 | IndexBuilder indexbuilder) throws IOException { |
duke@1 | 54 | super(configuration, filename, indexbuilder); |
duke@1 | 55 | relativepathNoSlash = "."; |
duke@1 | 56 | relativePath = "./"; |
duke@1 | 57 | } |
duke@1 | 58 | |
duke@1 | 59 | /** |
duke@1 | 60 | * Generate single index file, for all Unicode characters. |
duke@1 | 61 | * |
duke@1 | 62 | * @param indexbuilder IndexBuilder built by {@link IndexBuilder} |
duke@1 | 63 | * @throws DocletAbortException |
duke@1 | 64 | */ |
duke@1 | 65 | public static void generate(ConfigurationImpl configuration, |
duke@1 | 66 | IndexBuilder indexbuilder) { |
duke@1 | 67 | SingleIndexWriter indexgen; |
duke@1 | 68 | String filename = "index-all.html"; |
duke@1 | 69 | try { |
duke@1 | 70 | indexgen = new SingleIndexWriter(configuration, |
duke@1 | 71 | filename, indexbuilder); |
duke@1 | 72 | indexgen.generateIndexFile(); |
duke@1 | 73 | indexgen.close(); |
duke@1 | 74 | } catch (IOException exc) { |
duke@1 | 75 | configuration.standardmessage.error( |
duke@1 | 76 | "doclet.exception_encountered", |
duke@1 | 77 | exc.toString(), filename); |
duke@1 | 78 | throw new DocletAbortException(); |
duke@1 | 79 | } |
duke@1 | 80 | } |
duke@1 | 81 | |
duke@1 | 82 | /** |
duke@1 | 83 | * Generate the contents of each index file, with Header, Footer, |
duke@1 | 84 | * Member Field, Method and Constructor Description. |
duke@1 | 85 | */ |
duke@1 | 86 | protected void generateIndexFile() throws IOException { |
bpatel@766 | 87 | String title = configuration.getText("doclet.Window_Single_Index"); |
bpatel@766 | 88 | Content body = getBody(true, getWindowTitle(title)); |
bpatel@766 | 89 | addTop(body); |
bpatel@766 | 90 | addNavLinks(true, body); |
bpatel@766 | 91 | HtmlTree divTree = new HtmlTree(HtmlTag.DIV); |
bpatel@766 | 92 | divTree.addStyle(HtmlStyle.contentContainer); |
bpatel@766 | 93 | addLinksForIndexes(divTree); |
duke@1 | 94 | for (int i = 0; i < indexbuilder.elements().length; i++) { |
duke@1 | 95 | Character unicode = (Character)((indexbuilder.elements())[i]); |
bpatel@766 | 96 | addContents(unicode, indexbuilder.getMemberList(unicode), divTree); |
duke@1 | 97 | } |
bpatel@766 | 98 | addLinksForIndexes(divTree); |
bpatel@766 | 99 | body.addContent(divTree); |
bpatel@766 | 100 | addNavLinks(false, body); |
bpatel@766 | 101 | addBottom(body); |
bpatel@766 | 102 | printHtmlDocument(null, true, body); |
duke@1 | 103 | } |
duke@1 | 104 | |
duke@1 | 105 | /** |
bpatel@766 | 106 | * Add links for all the Index Files per unicode character. |
bpatel@766 | 107 | * |
bpatel@766 | 108 | * @param contentTree the content tree to which the links for indexes will be added |
duke@1 | 109 | */ |
bpatel@766 | 110 | protected void addLinksForIndexes(Content contentTree) { |
duke@1 | 111 | for (int i = 0; i < indexbuilder.elements().length; i++) { |
duke@1 | 112 | String unicode = (indexbuilder.elements())[i].toString(); |
bpatel@766 | 113 | contentTree.addContent( |
bpatel@766 | 114 | getHyperLink("#_" + unicode + "_", new StringContent(unicode))); |
bpatel@766 | 115 | contentTree.addContent(getSpace()); |
duke@1 | 116 | } |
duke@1 | 117 | } |
duke@1 | 118 | } |