duke@1: /* ohair@798: * Copyright (c) 1998, 2010, Oracle and/or its affiliates. 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 ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle 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: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: bpatel@766: import java.io.*; duke@1: import com.sun.tools.doclets.internal.toolkit.util.*; bpatel@766: import com.sun.tools.doclets.formats.html.markup.*; bpatel@766: import com.sun.tools.doclets.internal.toolkit.*; 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 bpatel@766: * @author Bhavesh Patel (Modified) 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 { bpatel@766: String title = configuration.getText("doclet.Window_Single_Index"); bpatel@766: Content body = getBody(true, getWindowTitle(title)); bpatel@766: addTop(body); bpatel@766: addNavLinks(true, body); bpatel@766: HtmlTree divTree = new HtmlTree(HtmlTag.DIV); bpatel@766: divTree.addStyle(HtmlStyle.contentContainer); bpatel@766: addLinksForIndexes(divTree); duke@1: for (int i = 0; i < indexbuilder.elements().length; i++) { duke@1: Character unicode = (Character)((indexbuilder.elements())[i]); bpatel@766: addContents(unicode, indexbuilder.getMemberList(unicode), divTree); duke@1: } bpatel@766: addLinksForIndexes(divTree); bpatel@766: body.addContent(divTree); bpatel@766: addNavLinks(false, body); bpatel@766: addBottom(body); bpatel@766: printHtmlDocument(null, true, body); duke@1: } duke@1: duke@1: /** bpatel@766: * Add links for all the Index Files per unicode character. bpatel@766: * bpatel@766: * @param contentTree the content tree to which the links for indexes will be added duke@1: */ bpatel@766: protected void addLinksForIndexes(Content contentTree) { duke@1: for (int i = 0; i < indexbuilder.elements().length; i++) { duke@1: String unicode = (indexbuilder.elements())[i].toString(); bpatel@766: contentTree.addContent( bpatel@766: getHyperLink("#_" + unicode + "_", new StringContent(unicode))); bpatel@766: contentTree.addContent(getSpace()); duke@1: } duke@1: } duke@1: }