Thu, 13 Jan 2011 21:28:38 -0800
7010528: javadoc performance regression
Reviewed-by: jjg
duke@1 | 1 | /* |
ohair@798 | 2 | * Copyright (c) 2003, 2010, 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@233 | 28 | import java.io.*; |
bpatel@233 | 29 | |
bpatel@233 | 30 | import com.sun.javadoc.*; |
bpatel@766 | 31 | import com.sun.tools.doclets.formats.html.markup.*; |
duke@1 | 32 | import com.sun.tools.doclets.internal.toolkit.*; |
duke@1 | 33 | |
duke@1 | 34 | /** |
duke@1 | 35 | * Writes annotation type optional member documentation in HTML format. |
duke@1 | 36 | * |
duke@1 | 37 | * @author Jamie Ho |
bpatel@243 | 38 | * @author Bhavesh Patel (Modified) |
duke@1 | 39 | */ |
duke@1 | 40 | public class AnnotationTypeOptionalMemberWriterImpl extends |
duke@1 | 41 | AnnotationTypeRequiredMemberWriterImpl |
duke@1 | 42 | implements AnnotationTypeOptionalMemberWriter, MemberSummaryWriter { |
duke@1 | 43 | |
duke@1 | 44 | /** |
duke@1 | 45 | * Construct a new AnnotationTypeOptionalMemberWriterImpl. |
duke@1 | 46 | * |
duke@1 | 47 | * @param writer the writer that will write the output. |
duke@1 | 48 | * @param annotationType the AnnotationType that holds this member. |
duke@1 | 49 | */ |
duke@1 | 50 | public AnnotationTypeOptionalMemberWriterImpl(SubWriterHolderWriter writer, |
duke@1 | 51 | AnnotationTypeDoc annotationType) { |
duke@1 | 52 | super(writer, annotationType); |
duke@1 | 53 | } |
duke@1 | 54 | |
duke@1 | 55 | /** |
duke@1 | 56 | * {@inheritDoc} |
duke@1 | 57 | */ |
bpatel@766 | 58 | public Content getMemberSummaryHeader(ClassDoc classDoc, |
bpatel@766 | 59 | Content memberSummaryTree) { |
bpatel@766 | 60 | memberSummaryTree.addContent( |
bpatel@766 | 61 | HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY); |
bpatel@766 | 62 | Content memberTree = writer.getMemberTreeHeader(); |
bpatel@766 | 63 | writer.addSummaryHeader(this, classDoc, memberTree); |
bpatel@766 | 64 | return memberTree; |
duke@1 | 65 | } |
duke@1 | 66 | |
duke@1 | 67 | /** |
duke@1 | 68 | * {@inheritDoc} |
duke@1 | 69 | */ |
bpatel@766 | 70 | public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree) { |
bpatel@233 | 71 | if (((AnnotationTypeElementDoc) member).defaultValue() != null) { |
bpatel@766 | 72 | Content dt = HtmlTree.DT(writer.getResource("doclet.Default")); |
bpatel@766 | 73 | Content dl = HtmlTree.DL(dt); |
bpatel@766 | 74 | Content dd = HtmlTree.DD(new StringContent( |
bpatel@766 | 75 | ((AnnotationTypeElementDoc) member).defaultValue().toString())); |
bpatel@766 | 76 | dl.addContent(dd); |
bpatel@766 | 77 | annotationDocTree.addContent(dl); |
bpatel@233 | 78 | } |
duke@1 | 79 | } |
duke@1 | 80 | |
duke@1 | 81 | /** |
duke@1 | 82 | * {@inheritDoc} |
duke@1 | 83 | */ |
duke@1 | 84 | public void close() throws IOException { |
duke@1 | 85 | writer.close(); |
duke@1 | 86 | } |
duke@1 | 87 | |
duke@1 | 88 | /** |
duke@1 | 89 | * {@inheritDoc} |
duke@1 | 90 | */ |
bpatel@766 | 91 | public void addSummaryLabel(Content memberTree) { |
bpatel@766 | 92 | Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, |
bpatel@766 | 93 | writer.getResource("doclet.Annotation_Type_Optional_Member_Summary")); |
bpatel@766 | 94 | memberTree.addContent(label); |
bpatel@243 | 95 | } |
bpatel@243 | 96 | |
bpatel@243 | 97 | /** |
bpatel@243 | 98 | * {@inheritDoc} |
bpatel@243 | 99 | */ |
bpatel@766 | 100 | public String getTableSummary() { |
bpatel@766 | 101 | return configuration().getText("doclet.Member_Table_Summary", |
bpatel@243 | 102 | configuration().getText("doclet.Annotation_Type_Optional_Member_Summary"), |
bpatel@766 | 103 | configuration().getText("doclet.annotation_type_optional_members")); |
bpatel@243 | 104 | } |
bpatel@243 | 105 | |
bpatel@766 | 106 | /** |
bpatel@766 | 107 | * {@inheritDoc} |
bpatel@766 | 108 | */ |
bpatel@766 | 109 | public String getCaption() { |
bpatel@766 | 110 | return configuration().getText("doclet.Annotation_Type_Optional_Members"); |
bpatel@766 | 111 | } |
bpatel@766 | 112 | |
bpatel@766 | 113 | /** |
bpatel@766 | 114 | * {@inheritDoc} |
bpatel@766 | 115 | */ |
bpatel@766 | 116 | public String[] getSummaryTableHeader(ProgramElementDoc member) { |
bpatel@243 | 117 | String[] header = new String[] { |
bpatel@243 | 118 | writer.getModifierTypeHeader(), |
bpatel@243 | 119 | configuration().getText("doclet.0_and_1", |
bpatel@243 | 120 | configuration().getText("doclet.Annotation_Type_Optional_Member"), |
bpatel@243 | 121 | configuration().getText("doclet.Description")) |
bpatel@243 | 122 | }; |
bpatel@766 | 123 | return header; |
duke@1 | 124 | } |
duke@1 | 125 | |
duke@1 | 126 | /** |
duke@1 | 127 | * {@inheritDoc} |
duke@1 | 128 | */ |
bpatel@766 | 129 | public void addSummaryAnchor(ClassDoc cd, Content memberTree) { |
bpatel@766 | 130 | memberTree.addContent(writer.getMarkerAnchor( |
bpatel@766 | 131 | "annotation_type_optional_element_summary")); |
duke@1 | 132 | } |
duke@1 | 133 | |
duke@1 | 134 | /** |
duke@1 | 135 | * {@inheritDoc} |
duke@1 | 136 | */ |
bpatel@766 | 137 | protected Content getNavSummaryLink(ClassDoc cd, boolean link) { |
duke@1 | 138 | if (link) { |
bpatel@766 | 139 | return writer.getHyperLink("", "annotation_type_optional_element_summary", |
bpatel@766 | 140 | writer.getResource("doclet.navAnnotationTypeOptionalMember")); |
duke@1 | 141 | } else { |
bpatel@766 | 142 | return writer.getResource("doclet.navAnnotationTypeOptionalMember"); |
duke@1 | 143 | } |
duke@1 | 144 | } |
duke@1 | 145 | } |