Wed, 10 Oct 2012 16:48:21 -0700
8000665: fix "internal API" comments on javadoc files
Reviewed-by: darcy
1 /*
2 * Copyright (c) 1998, 2012, 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 java.io.*;
29 import java.util.*;
31 import com.sun.javadoc.*;
32 import com.sun.tools.doclets.formats.html.markup.*;
33 import com.sun.tools.doclets.internal.toolkit.*;
34 import com.sun.tools.doclets.internal.toolkit.util.*;
36 /**
37 * Generate the file with list of all the classes in this run. This page will be
38 * used in the left-hand bottom frame, when "All Classes" link is clicked in
39 * the left-hand top frame. The name of the generated file is
40 * "allclasses-frame.html".
41 *
42 * <p><b>This is NOT part of any supported API.
43 * If you write code that depends on this, you do so at your own risk.
44 * This code and its internal interfaces are subject to change or
45 * deletion without notice.</b>
46 *
47 * @author Atul M Dambalkar
48 * @author Doug Kramer
49 * @author Bhavesh Patel (Modified)
50 */
51 public class AllClassesFrameWriter extends HtmlDocletWriter {
53 /**
54 * The name of the output file with frames
55 */
56 public static final String OUTPUT_FILE_NAME_FRAMES = "allclasses-frame.html";
58 /**
59 * The name of the output file without frames
60 */
61 public static final String OUTPUT_FILE_NAME_NOFRAMES = "allclasses-noframe.html";
63 /**
64 * Index of all the classes.
65 */
66 protected IndexBuilder indexbuilder;
68 /**
69 * BR tag to be used within a document tree.
70 */
71 final HtmlTree BR = new HtmlTree(HtmlTag.BR);
73 /**
74 * Construct AllClassesFrameWriter object. Also initilises the indexbuilder
75 * variable in this class.
76 * @throws IOException
77 * @throws DocletAbortException
78 */
79 public AllClassesFrameWriter(ConfigurationImpl configuration,
80 String filename, IndexBuilder indexbuilder)
81 throws IOException {
82 super(configuration, filename);
83 this.indexbuilder = indexbuilder;
84 }
86 /**
87 * Create AllClassesFrameWriter object. Then use it to generate the
88 * "allclasses-frame.html" file. Generate the file in the current or the
89 * destination directory.
90 *
91 * @param indexbuilder IndexBuilder object for all classes index.
92 * @throws DocletAbortException
93 */
94 public static void generate(ConfigurationImpl configuration,
95 IndexBuilder indexbuilder) {
96 AllClassesFrameWriter allclassgen;
97 String filename = OUTPUT_FILE_NAME_FRAMES;
98 try {
99 allclassgen = new AllClassesFrameWriter(configuration,
100 filename, indexbuilder);
101 allclassgen.buildAllClassesFile(true);
102 allclassgen.close();
103 filename = OUTPUT_FILE_NAME_NOFRAMES;
104 allclassgen = new AllClassesFrameWriter(configuration,
105 filename, indexbuilder);
106 allclassgen.buildAllClassesFile(false);
107 allclassgen.close();
108 } catch (IOException exc) {
109 configuration.standardmessage.
110 error("doclet.exception_encountered",
111 exc.toString(), filename);
112 throw new DocletAbortException();
113 }
114 }
116 /**
117 * Print all the classes in the file.
118 * @param wantFrames True if we want frames.
119 */
120 protected void buildAllClassesFile(boolean wantFrames) throws IOException {
121 String label = configuration.getText("doclet.All_Classes");
122 Content body = getBody(false, getWindowTitle(label));
123 Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
124 HtmlStyle.bar, allclassesLabel);
125 body.addContent(heading);
126 Content ul = new HtmlTree(HtmlTag.UL);
127 // Generate the class links and add it to the tdFont tree.
128 addAllClasses(ul, wantFrames);
129 Content div = HtmlTree.DIV(HtmlStyle.indexContainer, ul);
130 body.addContent(div);
131 printHtmlDocument(null, false, body);
132 }
134 /**
135 * Use the sorted index of all the classes and add all the classes to the
136 * content list.
137 *
138 * @param content HtmlTree content to which all classes information will be added
139 * @param wantFrames True if we want frames.
140 */
141 protected void addAllClasses(Content content, boolean wantFrames) {
142 for (int i = 0; i < indexbuilder.elements().length; i++) {
143 Character unicode = (Character)((indexbuilder.elements())[i]);
144 addContents(indexbuilder.getMemberList(unicode), wantFrames, content);
145 }
146 }
148 /**
149 * Given a list of classes, generate links for each class or interface.
150 * If the class kind is interface, print it in the italics font. Also all
151 * links should target the right-hand frame. If clicked on any class name
152 * in this page, appropriate class page should get opened in the right-hand
153 * frame.
154 *
155 * @param classlist Sorted list of classes.
156 * @param wantFrames True if we want frames.
157 * @param content HtmlTree content to which the links will be added
158 */
159 protected void addContents(List<Doc> classlist, boolean wantFrames,
160 Content content) {
161 for (int i = 0; i < classlist.size(); i++) {
162 ClassDoc cd = (ClassDoc)classlist.get(i);
163 if (!Util.isCoreClass(cd)) {
164 continue;
165 }
166 String label = italicsClassName(cd, false);
167 Content linkContent;
168 if(wantFrames){
169 linkContent = new RawHtml(getLink(new LinkInfoImpl(
170 LinkInfoImpl.ALL_CLASSES_FRAME, cd, label, "classFrame")));
171 } else {
172 linkContent = new RawHtml(getLink(new LinkInfoImpl(cd, label)));
173 }
174 Content li = HtmlTree.LI(linkContent);
175 content.addContent(li);
176 }
177 }
178 }