Thu, 10 Jun 2010 17:09:56 -0700
6960407: Potential rebranding issues in openjdk/langtools repository sources
Reviewed-by: darcy
duke@1 | 1 | /* |
ohair@554 | 2 | * Copyright (c) 1998, 2005, 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 | |
duke@1 | 28 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 29 | |
duke@1 | 30 | import java.io.*; |
duke@1 | 31 | |
duke@1 | 32 | /** |
duke@1 | 33 | * Generate Separate Index Files for all the member names with Indexing in |
duke@1 | 34 | * Unicode Order. This will create "index-files" directory in the current or |
duke@1 | 35 | * destination directory and will generate separate file for each unicode index. |
duke@1 | 36 | * |
duke@1 | 37 | * @see java.lang.Character |
duke@1 | 38 | * @author Atul M Dambalkar |
duke@1 | 39 | */ |
duke@1 | 40 | public class SplitIndexWriter extends AbstractIndexWriter { |
duke@1 | 41 | |
duke@1 | 42 | /** |
duke@1 | 43 | * Previous unicode character index in the built index. |
duke@1 | 44 | */ |
duke@1 | 45 | protected int prev; |
duke@1 | 46 | |
duke@1 | 47 | /** |
duke@1 | 48 | * Next unicode character in the built index. |
duke@1 | 49 | */ |
duke@1 | 50 | protected int next; |
duke@1 | 51 | |
duke@1 | 52 | /** |
duke@1 | 53 | * Construct the SplitIndexWriter. Uses path to this file and relative path |
duke@1 | 54 | * from this file. |
duke@1 | 55 | * |
duke@1 | 56 | * @param path Path to the file which is getting generated. |
duke@1 | 57 | * @param filename Name of the file which is getting genrated. |
duke@1 | 58 | * @param relpath Relative path from this file to the current directory. |
duke@1 | 59 | * @param indexbuilder Unicode based Index from {@link IndexBuilder} |
duke@1 | 60 | */ |
duke@1 | 61 | public SplitIndexWriter(ConfigurationImpl configuration, |
duke@1 | 62 | String path, String filename, |
duke@1 | 63 | String relpath, IndexBuilder indexbuilder, |
duke@1 | 64 | int prev, int next) throws IOException { |
duke@1 | 65 | super(configuration, path, filename, relpath, indexbuilder); |
duke@1 | 66 | this.prev = prev; |
duke@1 | 67 | this.next = next; |
duke@1 | 68 | } |
duke@1 | 69 | |
duke@1 | 70 | /** |
duke@1 | 71 | * Generate separate index files, for each Unicode character, listing all |
duke@1 | 72 | * the members starting with the particular unicode character. |
duke@1 | 73 | * |
duke@1 | 74 | * @param indexbuilder IndexBuilder built by {@link IndexBuilder} |
duke@1 | 75 | * @throws DocletAbortException |
duke@1 | 76 | */ |
duke@1 | 77 | public static void generate(ConfigurationImpl configuration, |
duke@1 | 78 | IndexBuilder indexbuilder) { |
duke@1 | 79 | SplitIndexWriter indexgen; |
duke@1 | 80 | String filename = ""; |
duke@1 | 81 | String path = DirectoryManager.getPath("index-files"); |
duke@1 | 82 | String relpath = DirectoryManager.getRelativePath("index-files"); |
duke@1 | 83 | try { |
duke@1 | 84 | for (int i = 0; i < indexbuilder.elements().length; i++) { |
duke@1 | 85 | int j = i + 1; |
duke@1 | 86 | int prev = (j == 1)? -1: i; |
duke@1 | 87 | int next = (j == indexbuilder.elements().length)? -1: j + 1; |
duke@1 | 88 | filename = "index-" + j +".html"; |
duke@1 | 89 | indexgen = new SplitIndexWriter(configuration, |
duke@1 | 90 | path, filename, relpath, |
duke@1 | 91 | indexbuilder, prev, next); |
duke@1 | 92 | indexgen.generateIndexFile((Character)indexbuilder. |
duke@1 | 93 | elements()[i]); |
duke@1 | 94 | indexgen.close(); |
duke@1 | 95 | } |
duke@1 | 96 | } catch (IOException exc) { |
duke@1 | 97 | configuration.standardmessage.error( |
duke@1 | 98 | "doclet.exception_encountered", |
duke@1 | 99 | exc.toString(), filename); |
duke@1 | 100 | throw new DocletAbortException(); |
duke@1 | 101 | } |
duke@1 | 102 | } |
duke@1 | 103 | |
duke@1 | 104 | /** |
duke@1 | 105 | * Generate the contents of each index file, with Header, Footer, |
duke@1 | 106 | * Member Field, Method and Constructor Description. |
duke@1 | 107 | * |
duke@1 | 108 | * @param unicode Unicode character referring to the character for the |
duke@1 | 109 | * index. |
duke@1 | 110 | */ |
duke@1 | 111 | protected void generateIndexFile(Character unicode) throws IOException { |
duke@1 | 112 | printHtmlHeader(configuration.getText("doclet.Window_Split_Index", |
duke@1 | 113 | unicode.toString()), null, true); |
duke@1 | 114 | printTop(); |
duke@1 | 115 | navLinks(true); |
duke@1 | 116 | printLinksForIndexes(); |
duke@1 | 117 | |
duke@1 | 118 | hr(); |
duke@1 | 119 | |
duke@1 | 120 | generateContents(unicode, indexbuilder.getMemberList(unicode)); |
duke@1 | 121 | |
duke@1 | 122 | navLinks(false); |
duke@1 | 123 | printLinksForIndexes(); |
duke@1 | 124 | |
duke@1 | 125 | printBottom(); |
duke@1 | 126 | printBodyHtmlEnd(); |
duke@1 | 127 | } |
duke@1 | 128 | |
duke@1 | 129 | /** |
duke@1 | 130 | * Print Links for all the Index Files per unicode character. |
duke@1 | 131 | */ |
duke@1 | 132 | protected void printLinksForIndexes() { |
duke@1 | 133 | for (int i = 0; i < indexbuilder.elements().length; i++) { |
duke@1 | 134 | int j = i + 1; |
duke@1 | 135 | printHyperLink("index-" + j + ".html", |
duke@1 | 136 | indexbuilder.elements()[i].toString()); |
duke@1 | 137 | print(' '); |
duke@1 | 138 | } |
duke@1 | 139 | } |
duke@1 | 140 | |
duke@1 | 141 | /** |
duke@1 | 142 | * Print the previous unicode character index link. |
duke@1 | 143 | */ |
duke@1 | 144 | protected void navLinkPrevious() { |
duke@1 | 145 | if (prev == -1) { |
duke@1 | 146 | printText("doclet.Prev_Letter"); |
duke@1 | 147 | } else { |
duke@1 | 148 | printHyperLink("index-" + prev + ".html", "", |
duke@1 | 149 | configuration.getText("doclet.Prev_Letter"), true); |
duke@1 | 150 | } |
duke@1 | 151 | } |
duke@1 | 152 | |
duke@1 | 153 | /** |
duke@1 | 154 | * Print the next unicode character index link. |
duke@1 | 155 | */ |
duke@1 | 156 | protected void navLinkNext() { |
duke@1 | 157 | if (next == -1) { |
duke@1 | 158 | printText("doclet.Next_Letter"); |
duke@1 | 159 | } else { |
duke@1 | 160 | printHyperLink("index-" + next + ".html","", |
duke@1 | 161 | configuration.getText("doclet.Next_Letter"), true); |
duke@1 | 162 | } |
duke@1 | 163 | } |
duke@1 | 164 | } |