duke@1: /* duke@1: * Copyright 1998-2005 Sun Microsystems, Inc. All Rights Reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as duke@1: * published by the Free Software Foundation. Sun designates this duke@1: * particular file as subject to the "Classpath" exception as provided duke@1: * by Sun in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * duke@1: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@1: * CA 95054 USA or visit www.sun.com if you need additional information or duke@1: * have any questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; duke@1: duke@1: import java.io.*; duke@1: duke@1: /** duke@1: * Generate only one index file for all the Member Names with Indexing in duke@1: * Unicode Order. The name of the generated file is "index-all.html" and it is duke@1: * generated in current or the destination directory. duke@1: * duke@1: * @see java.lang.Character duke@1: * @author Atul M Dambalkar duke@1: */ duke@1: public class SingleIndexWriter extends AbstractIndexWriter { duke@1: duke@1: /** duke@1: * Construct the SingleIndexWriter with filename "index-all.html" and the duke@1: * {@link IndexBuilder} duke@1: * duke@1: * @param filename Name of the index file to be generated. duke@1: * @param indexbuilder Unicode based Index from {@link IndexBuilder} duke@1: */ duke@1: public SingleIndexWriter(ConfigurationImpl configuration, duke@1: String filename, duke@1: IndexBuilder indexbuilder) throws IOException { duke@1: super(configuration, filename, indexbuilder); duke@1: relativepathNoSlash = "."; duke@1: relativePath = "./"; duke@1: } duke@1: duke@1: /** duke@1: * Generate single index file, for all Unicode characters. duke@1: * duke@1: * @param indexbuilder IndexBuilder built by {@link IndexBuilder} duke@1: * @throws DocletAbortException duke@1: */ duke@1: public static void generate(ConfigurationImpl configuration, duke@1: IndexBuilder indexbuilder) { duke@1: SingleIndexWriter indexgen; duke@1: String filename = "index-all.html"; duke@1: try { duke@1: indexgen = new SingleIndexWriter(configuration, duke@1: filename, indexbuilder); duke@1: indexgen.generateIndexFile(); duke@1: indexgen.close(); duke@1: } catch (IOException exc) { duke@1: configuration.standardmessage.error( duke@1: "doclet.exception_encountered", duke@1: exc.toString(), filename); duke@1: throw new DocletAbortException(); duke@1: } duke@1: } duke@1: duke@1: /** duke@1: * Generate the contents of each index file, with Header, Footer, duke@1: * Member Field, Method and Constructor Description. duke@1: */ duke@1: protected void generateIndexFile() throws IOException { duke@1: printHtmlHeader(configuration.getText("doclet.Window_Single_Index"), duke@1: null, true); duke@1: printTop(); duke@1: navLinks(true); duke@1: printLinksForIndexes(); duke@1: duke@1: hr(); duke@1: duke@1: for (int i = 0; i < indexbuilder.elements().length; i++) { duke@1: Character unicode = (Character)((indexbuilder.elements())[i]); duke@1: generateContents(unicode, indexbuilder.getMemberList(unicode)); duke@1: } duke@1: duke@1: printLinksForIndexes(); duke@1: navLinks(false); duke@1: duke@1: printBottom(); duke@1: printBodyHtmlEnd(); duke@1: } duke@1: duke@1: /** duke@1: * Print Links for all the Index Files per unicode character. duke@1: */ duke@1: protected void printLinksForIndexes() { duke@1: for (int i = 0; i < indexbuilder.elements().length; i++) { duke@1: String unicode = (indexbuilder.elements())[i].toString(); duke@1: printHyperLink("#_" + unicode + "_", unicode); duke@1: print(' '); duke@1: } duke@1: } duke@1: }