src/share/classes/com/sun/tools/doclets/formats/html/SingleIndexWriter.java

Tue, 25 May 2010 15:54:51 -0700

author
ohair
date
Tue, 25 May 2010 15:54:51 -0700
changeset 554
9d9f26857129
parent 1
9a66ca7c79fa
child 766
90af8d87741f
permissions
-rw-r--r--

6943119: Rebrand source copyright notices
Reviewed-by: darcy

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

mercurial