Wed, 10 Oct 2012 16:48:21 -0700
8000665: fix "internal API" comments on javadoc files
Reviewed-by: darcy
duke@1 | 1 | /* |
jjg@1357 | 2 | * Copyright (c) 1998, 2012, 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.*; |
jjg@1357 | 29 | |
bpatel@766 | 30 | import com.sun.tools.doclets.formats.html.markup.*; |
bpatel@766 | 31 | import com.sun.tools.doclets.internal.toolkit.*; |
jjg@1357 | 32 | import com.sun.tools.doclets.internal.toolkit.util.*; |
duke@1 | 33 | |
duke@1 | 34 | /** |
duke@1 | 35 | * Generate Separate Index Files for all the member names with Indexing in |
duke@1 | 36 | * Unicode Order. This will create "index-files" directory in the current or |
duke@1 | 37 | * destination directory and will generate separate file for each unicode index. |
duke@1 | 38 | * |
jjg@1359 | 39 | * <p><b>This is NOT part of any supported API. |
jjg@1359 | 40 | * If you write code that depends on this, you do so at your own risk. |
jjg@1359 | 41 | * This code and its internal interfaces are subject to change or |
jjg@1359 | 42 | * deletion without notice.</b> |
jjg@1359 | 43 | * |
duke@1 | 44 | * @see java.lang.Character |
duke@1 | 45 | * @author Atul M Dambalkar |
bpatel@766 | 46 | * @author Bhavesh Patel (Modified) |
duke@1 | 47 | */ |
duke@1 | 48 | public class SplitIndexWriter extends AbstractIndexWriter { |
duke@1 | 49 | |
duke@1 | 50 | /** |
duke@1 | 51 | * Previous unicode character index in the built index. |
duke@1 | 52 | */ |
duke@1 | 53 | protected int prev; |
duke@1 | 54 | |
duke@1 | 55 | /** |
duke@1 | 56 | * Next unicode character in the built index. |
duke@1 | 57 | */ |
duke@1 | 58 | protected int next; |
duke@1 | 59 | |
duke@1 | 60 | /** |
duke@1 | 61 | * Construct the SplitIndexWriter. Uses path to this file and relative path |
duke@1 | 62 | * from this file. |
duke@1 | 63 | * |
duke@1 | 64 | * @param path Path to the file which is getting generated. |
duke@1 | 65 | * @param filename Name of the file which is getting genrated. |
duke@1 | 66 | * @param relpath Relative path from this file to the current directory. |
duke@1 | 67 | * @param indexbuilder Unicode based Index from {@link IndexBuilder} |
duke@1 | 68 | */ |
duke@1 | 69 | public SplitIndexWriter(ConfigurationImpl configuration, |
duke@1 | 70 | String path, String filename, |
duke@1 | 71 | String relpath, IndexBuilder indexbuilder, |
duke@1 | 72 | int prev, int next) throws IOException { |
duke@1 | 73 | super(configuration, path, filename, relpath, indexbuilder); |
duke@1 | 74 | this.prev = prev; |
duke@1 | 75 | this.next = next; |
duke@1 | 76 | } |
duke@1 | 77 | |
duke@1 | 78 | /** |
duke@1 | 79 | * Generate separate index files, for each Unicode character, listing all |
duke@1 | 80 | * the members starting with the particular unicode character. |
duke@1 | 81 | * |
duke@1 | 82 | * @param indexbuilder IndexBuilder built by {@link IndexBuilder} |
duke@1 | 83 | * @throws DocletAbortException |
duke@1 | 84 | */ |
duke@1 | 85 | public static void generate(ConfigurationImpl configuration, |
duke@1 | 86 | IndexBuilder indexbuilder) { |
duke@1 | 87 | SplitIndexWriter indexgen; |
duke@1 | 88 | String filename = ""; |
duke@1 | 89 | String path = DirectoryManager.getPath("index-files"); |
duke@1 | 90 | String relpath = DirectoryManager.getRelativePath("index-files"); |
duke@1 | 91 | try { |
duke@1 | 92 | for (int i = 0; i < indexbuilder.elements().length; i++) { |
duke@1 | 93 | int j = i + 1; |
duke@1 | 94 | int prev = (j == 1)? -1: i; |
duke@1 | 95 | int next = (j == indexbuilder.elements().length)? -1: j + 1; |
duke@1 | 96 | filename = "index-" + j +".html"; |
duke@1 | 97 | indexgen = new SplitIndexWriter(configuration, |
duke@1 | 98 | path, filename, relpath, |
duke@1 | 99 | indexbuilder, prev, next); |
duke@1 | 100 | indexgen.generateIndexFile((Character)indexbuilder. |
duke@1 | 101 | elements()[i]); |
duke@1 | 102 | indexgen.close(); |
duke@1 | 103 | } |
duke@1 | 104 | } catch (IOException exc) { |
duke@1 | 105 | configuration.standardmessage.error( |
duke@1 | 106 | "doclet.exception_encountered", |
duke@1 | 107 | exc.toString(), filename); |
duke@1 | 108 | throw new DocletAbortException(); |
duke@1 | 109 | } |
duke@1 | 110 | } |
duke@1 | 111 | |
duke@1 | 112 | /** |
duke@1 | 113 | * Generate the contents of each index file, with Header, Footer, |
duke@1 | 114 | * Member Field, Method and Constructor Description. |
duke@1 | 115 | * |
duke@1 | 116 | * @param unicode Unicode character referring to the character for the |
duke@1 | 117 | * index. |
duke@1 | 118 | */ |
duke@1 | 119 | protected void generateIndexFile(Character unicode) throws IOException { |
bpatel@766 | 120 | String title = configuration.getText("doclet.Window_Split_Index", |
bpatel@766 | 121 | unicode.toString()); |
bpatel@766 | 122 | Content body = getBody(true, getWindowTitle(title)); |
bpatel@766 | 123 | addTop(body); |
bpatel@766 | 124 | addNavLinks(true, body); |
bpatel@766 | 125 | HtmlTree divTree = new HtmlTree(HtmlTag.DIV); |
bpatel@766 | 126 | divTree.addStyle(HtmlStyle.contentContainer); |
bpatel@766 | 127 | addLinksForIndexes(divTree); |
bpatel@766 | 128 | addContents(unicode, indexbuilder.getMemberList(unicode), divTree); |
bpatel@766 | 129 | addLinksForIndexes(divTree); |
bpatel@766 | 130 | body.addContent(divTree); |
bpatel@766 | 131 | addNavLinks(false, body); |
bpatel@766 | 132 | addBottom(body); |
bpatel@766 | 133 | printHtmlDocument(null, true, body); |
duke@1 | 134 | } |
duke@1 | 135 | |
duke@1 | 136 | /** |
bpatel@766 | 137 | * Add links for all the Index Files per unicode character. |
bpatel@766 | 138 | * |
bpatel@766 | 139 | * @param contentTree the content tree to which the links for indexes will be added |
duke@1 | 140 | */ |
bpatel@766 | 141 | protected void addLinksForIndexes(Content contentTree) { |
bpatel@766 | 142 | Object[] unicodeChars = indexbuilder.elements(); |
bpatel@766 | 143 | for (int i = 0; i < unicodeChars.length; i++) { |
duke@1 | 144 | int j = i + 1; |
bpatel@766 | 145 | contentTree.addContent(getHyperLink("index-" + j + ".html", |
bpatel@766 | 146 | new StringContent(unicodeChars[i].toString()))); |
bpatel@766 | 147 | contentTree.addContent(getSpace()); |
duke@1 | 148 | } |
duke@1 | 149 | } |
duke@1 | 150 | |
duke@1 | 151 | /** |
bpatel@766 | 152 | * Get link to the previous unicode character. |
bpatel@766 | 153 | * |
bpatel@766 | 154 | * @return a content tree for the link |
duke@1 | 155 | */ |
bpatel@766 | 156 | public Content getNavLinkPrevious() { |
bpatel@766 | 157 | Content prevletterLabel = getResource("doclet.Prev_Letter"); |
duke@1 | 158 | if (prev == -1) { |
bpatel@766 | 159 | return HtmlTree.LI(prevletterLabel); |
bpatel@766 | 160 | } |
bpatel@766 | 161 | else { |
bpatel@766 | 162 | Content prevLink = getHyperLink("index-" + prev + ".html", "", |
bpatel@766 | 163 | prevletterLabel); |
bpatel@766 | 164 | return HtmlTree.LI(prevLink); |
duke@1 | 165 | } |
duke@1 | 166 | } |
duke@1 | 167 | |
duke@1 | 168 | /** |
bpatel@766 | 169 | * Get link to the next unicode character. |
bpatel@766 | 170 | * |
bpatel@766 | 171 | * @return a content tree for the link |
duke@1 | 172 | */ |
bpatel@766 | 173 | public Content getNavLinkNext() { |
bpatel@766 | 174 | Content nextletterLabel = getResource("doclet.Next_Letter"); |
duke@1 | 175 | if (next == -1) { |
bpatel@766 | 176 | return HtmlTree.LI(nextletterLabel); |
bpatel@766 | 177 | } |
bpatel@766 | 178 | else { |
bpatel@766 | 179 | Content nextLink = getHyperLink("index-" + next + ".html","", |
bpatel@766 | 180 | nextletterLabel); |
bpatel@766 | 181 | return HtmlTree.LI(nextLink); |
duke@1 | 182 | } |
duke@1 | 183 | } |
duke@1 | 184 | } |