author | bpatel |
Thu, 08 Jan 2009 16:26:59 -0800 | |
changeset 1787 | 1aa079321cd2 |
parent 10 | 06bc494ca11e |
child 1789 | 7ac8c0815000 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
2 |
* Copyright 1998-2004 Sun Microsystems, Inc. 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. Sun designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
|
23 |
* have any questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.tools.doclets.formats.html; |
|
27 |
||
28 |
import com.sun.tools.doclets.internal.toolkit.util.*; |
|
29 |
||
30 |
import com.sun.javadoc.*; |
|
31 |
import java.io.*; |
|
32 |
import java.util.*; |
|
33 |
||
34 |
/** |
|
35 |
* Abstract class to print the class hierarchy page for all the Classes. This |
|
36 |
* is sub-classed by {@link PackageTreeWriter} and {@link TreeWriter} to |
|
37 |
* generate the Package Tree and global Tree(for all the classes and packages) |
|
38 |
* pages. |
|
39 |
* |
|
40 |
* @author Atul M Dambalkar |
|
41 |
*/ |
|
42 |
public abstract class AbstractTreeWriter extends HtmlDocletWriter { |
|
43 |
||
44 |
/** |
|
45 |
* The class and interface tree built by using {@link ClassTree} |
|
46 |
*/ |
|
47 |
protected final ClassTree classtree; |
|
48 |
||
49 |
/** |
|
50 |
* Constructor initilises classtree variable. This constructor will be used |
|
51 |
* while generating global tree file "overview-tree.html". |
|
52 |
* |
|
53 |
* @param filename File to be generated. |
|
54 |
* @param classtree Tree built by {@link ClassTree}. |
|
55 |
* @throws IOException |
|
56 |
* @throws DocletAbortException |
|
57 |
*/ |
|
58 |
protected AbstractTreeWriter(ConfigurationImpl configuration, |
|
59 |
String filename, ClassTree classtree) |
|
60 |
throws IOException { |
|
61 |
super(configuration, filename); |
|
62 |
this.classtree = classtree; |
|
63 |
} |
|
64 |
||
65 |
/** |
|
66 |
* Create appropriate directory for the package and also initilise the |
|
67 |
* relative path from this generated file to the current or |
|
68 |
* the destination directory. This constructor will be used while |
|
69 |
* generating "package tree" file. |
|
70 |
* |
|
71 |
* @param path Directories in this path will be created if they are not |
|
72 |
* already there. |
|
73 |
* @param filename Name of the package tree file to be generated. |
|
74 |
* @param classtree The tree built using {@link ClassTree}. |
|
75 |
* for the package pkg. |
|
76 |
* @param pkg PackageDoc for which tree file will be generated. |
|
77 |
* @throws IOException |
|
78 |
* @throws DocletAbortException |
|
79 |
*/ |
|
80 |
protected AbstractTreeWriter(ConfigurationImpl configuration, |
|
81 |
String path, String filename, |
|
82 |
ClassTree classtree, PackageDoc pkg) |
|
83 |
throws IOException { |
|
84 |
super(configuration, |
|
85 |
path, filename, DirectoryManager.getRelativePath(pkg.name())); |
|
86 |
this.classtree = classtree; |
|
87 |
} |
|
88 |
||
89 |
/** |
|
90 |
* Generate each level of the class tree. For each sub-class or |
|
91 |
* sub-interface indents the next level information. |
|
92 |
* Recurses itself to generate subclasses info. |
|
93 |
* To iterate is human, to recurse is divine - L. Peter Deutsch. |
|
94 |
* |
|
95 |
* @param parent the superclass or superinterface of the list. |
|
96 |
* @param list list of the sub-classes at this level. |
|
97 |
* @param isEnum true if we are generating a tree for enums. |
|
98 |
*/ |
|
99 |
protected void generateLevelInfo(ClassDoc parent, List list, |
|
100 |
boolean isEnum) { |
|
101 |
if (list.size() > 0) { |
|
102 |
ul(); |
|
103 |
for (int i = 0; i < list.size(); i++) { |
|
104 |
ClassDoc local = (ClassDoc)list.get(i); |
|
105 |
printPartialInfo(local); |
|
106 |
printExtendsImplements(parent, local); |
|
107 |
generateLevelInfo(local, classtree.subs(local, isEnum), |
|
108 |
isEnum); // Recurse |
|
109 |
} |
|
110 |
ulEnd(); |
|
111 |
} |
|
112 |
} |
|
113 |
||
114 |
/** |
|
115 |
* Generate the heading for the tree depending upon tree type if it's a |
|
116 |
* Class Tree or Interface tree and also print the tree. |
|
117 |
* |
|
118 |
* @param list List of classes which are at the most base level, all the |
|
119 |
* other classes in this run will derive from these classes. |
|
120 |
* @param heading Heading for the tree. |
|
121 |
*/ |
|
122 |
protected void generateTree(List list, String heading) { |
|
123 |
if (list.size() > 0) { |
|
124 |
ClassDoc firstClassDoc = (ClassDoc)list.get(0); |
|
125 |
printTreeHeading(heading); |
|
126 |
generateLevelInfo(!firstClassDoc.isInterface()? firstClassDoc : null, |
|
127 |
list, |
|
128 |
list == classtree.baseEnums()); |
|
129 |
} |
|
130 |
} |
|
131 |
||
132 |
/** |
|
133 |
* Print the information regarding the classes which this class extends or |
|
134 |
* implements. |
|
135 |
* |
|
136 |
* @param cd The classdoc under consideration. |
|
137 |
*/ |
|
138 |
protected void printExtendsImplements(ClassDoc parent, ClassDoc cd) { |
|
139 |
ClassDoc[] interfaces = cd.interfaces(); |
|
140 |
if (interfaces.length > (cd.isInterface()? 1 : 0)) { |
|
141 |
Arrays.sort(interfaces); |
|
142 |
int counter = 0; |
|
143 |
for (int i = 0; i < interfaces.length; i++) { |
|
144 |
if (parent != interfaces[i]) { |
|
145 |
if (! (interfaces[i].isPublic() || |
|
146 |
Util.isLinkable(interfaces[i], configuration()))) { |
|
147 |
continue; |
|
148 |
} |
|
149 |
if (counter == 0) { |
|
150 |
if (cd.isInterface()) { |
|
151 |
print(" (" + configuration.getText("doclet.also") + " extends "); |
|
152 |
} else { |
|
153 |
print(" (implements "); |
|
154 |
} |
|
155 |
} else { |
|
156 |
print(", "); |
|
157 |
} |
|
158 |
printPreQualifiedClassLink(LinkInfoImpl.CONTEXT_TREE, |
|
159 |
interfaces[i]); |
|
160 |
counter++; |
|
161 |
} |
|
162 |
} |
|
163 |
if (counter > 0) { |
|
164 |
println(")"); |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
||
169 |
/** |
|
170 |
* Print information about the class kind, if it's a "class" or "interface". |
|
171 |
* |
|
172 |
* @param cd classdoc. |
|
173 |
*/ |
|
174 |
protected void printPartialInfo(ClassDoc cd) { |
|
175 |
li("circle"); |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
176 |
printPreQualifiedStrongClassLink(LinkInfoImpl.CONTEXT_TREE, cd); |
10 | 177 |
} |
178 |
||
179 |
/** |
|
180 |
* Print the heading for the tree. |
|
181 |
* |
|
182 |
* @param heading Heading for the tree. |
|
183 |
*/ |
|
184 |
protected void printTreeHeading(String heading) { |
|
185 |
h2(); |
|
186 |
println(configuration.getText(heading)); |
|
187 |
h2End(); |
|
188 |
} |
|
189 |
||
190 |
/** |
|
191 |
* Highlight "Tree" word in the navigation bar, since this is the tree page. |
|
192 |
*/ |
|
193 |
protected void navLinkTree() { |
|
194 |
navCellRevStart(); |
|
195 |
fontStyle("NavBarFont1Rev"); |
|
1787
1aa079321cd2
6786028: Javadoc HTML WCAG 2.0 accessibility issues in standard doclet - Bold tags should be strong
bpatel
parents:
10
diff
changeset
|
196 |
strongText("doclet.Tree"); |
10 | 197 |
fontEnd(); |
198 |
navCellEnd(); |
|
199 |
} |
|
200 |
} |