duke@1: /* jjg@1359: * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. duke@1: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@1: * duke@1: * This code is free software; you can redistribute it and/or modify it duke@1: * under the terms of the GNU General Public License version 2 only, as ohair@554: * published by the Free Software Foundation. Oracle designates this duke@1: * particular file as subject to the "Classpath" exception as provided ohair@554: * by Oracle in the LICENSE file that accompanied this code. duke@1: * duke@1: * This code is distributed in the hope that it will be useful, but WITHOUT duke@1: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@1: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@1: * version 2 for more details (a copy is included in the LICENSE file that duke@1: * accompanied this code). duke@1: * duke@1: * You should have received a copy of the GNU General Public License version duke@1: * 2 along with this work; if not, write to the Free Software Foundation, duke@1: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@1: * ohair@554: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ohair@554: * or visit www.oracle.com if you need additional information or have any ohair@554: * questions. duke@1: */ duke@1: duke@1: package com.sun.tools.doclets.formats.html; duke@1: bpatel@233: import java.io.*; bpatel@233: bpatel@233: import com.sun.javadoc.*; bpatel@766: import com.sun.tools.doclets.formats.html.markup.*; duke@1: import com.sun.tools.doclets.internal.toolkit.*; duke@1: duke@1: /** duke@1: * Writes annotation type optional member documentation in HTML format. duke@1: * jjg@1359: *

This is NOT part of any supported API. jjg@1359: * If you write code that depends on this, you do so at your own risk. jjg@1359: * This code and its internal interfaces are subject to change or jjg@1359: * deletion without notice. jjg@1359: * duke@1: * @author Jamie Ho bpatel@243: * @author Bhavesh Patel (Modified) duke@1: */ duke@1: public class AnnotationTypeOptionalMemberWriterImpl extends duke@1: AnnotationTypeRequiredMemberWriterImpl duke@1: implements AnnotationTypeOptionalMemberWriter, MemberSummaryWriter { duke@1: duke@1: /** duke@1: * Construct a new AnnotationTypeOptionalMemberWriterImpl. duke@1: * duke@1: * @param writer the writer that will write the output. duke@1: * @param annotationType the AnnotationType that holds this member. duke@1: */ duke@1: public AnnotationTypeOptionalMemberWriterImpl(SubWriterHolderWriter writer, duke@1: AnnotationTypeDoc annotationType) { duke@1: super(writer, annotationType); duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public Content getMemberSummaryHeader(ClassDoc classDoc, bpatel@766: Content memberSummaryTree) { bpatel@766: memberSummaryTree.addContent( bpatel@766: HtmlConstants.START_OF_ANNOTATION_TYPE_OPTIONAL_MEMBER_SUMMARY); bpatel@766: Content memberTree = writer.getMemberTreeHeader(); bpatel@766: writer.addSummaryHeader(this, classDoc, memberTree); bpatel@766: return memberTree; duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addDefaultValueInfo(MemberDoc member, Content annotationDocTree) { bpatel@233: if (((AnnotationTypeElementDoc) member).defaultValue() != null) { bpatel@766: Content dt = HtmlTree.DT(writer.getResource("doclet.Default")); bpatel@766: Content dl = HtmlTree.DL(dt); bpatel@766: Content dd = HtmlTree.DD(new StringContent( bpatel@766: ((AnnotationTypeElementDoc) member).defaultValue().toString())); bpatel@766: dl.addContent(dd); bpatel@766: annotationDocTree.addContent(dl); bpatel@233: } duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ duke@1: public void close() throws IOException { duke@1: writer.close(); duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addSummaryLabel(Content memberTree) { bpatel@766: Content label = HtmlTree.HEADING(HtmlConstants.SUMMARY_HEADING, bpatel@766: writer.getResource("doclet.Annotation_Type_Optional_Member_Summary")); bpatel@766: memberTree.addContent(label); bpatel@243: } bpatel@243: bpatel@243: /** bpatel@243: * {@inheritDoc} bpatel@243: */ bpatel@766: public String getTableSummary() { jjg@1410: return configuration.getText("doclet.Member_Table_Summary", jjg@1410: configuration.getText("doclet.Annotation_Type_Optional_Member_Summary"), jjg@1410: configuration.getText("doclet.annotation_type_optional_members")); bpatel@243: } bpatel@243: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public String getCaption() { jjg@1410: return configuration.getText("doclet.Annotation_Type_Optional_Members"); bpatel@766: } bpatel@766: bpatel@766: /** bpatel@766: * {@inheritDoc} bpatel@766: */ bpatel@766: public String[] getSummaryTableHeader(ProgramElementDoc member) { bpatel@243: String[] header = new String[] { bpatel@243: writer.getModifierTypeHeader(), jjg@1410: configuration.getText("doclet.0_and_1", jjg@1410: configuration.getText("doclet.Annotation_Type_Optional_Member"), jjg@1410: configuration.getText("doclet.Description")) bpatel@243: }; bpatel@766: return header; duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: public void addSummaryAnchor(ClassDoc cd, Content memberTree) { bpatel@766: memberTree.addContent(writer.getMarkerAnchor( bpatel@766: "annotation_type_optional_element_summary")); duke@1: } duke@1: duke@1: /** duke@1: * {@inheritDoc} duke@1: */ bpatel@766: protected Content getNavSummaryLink(ClassDoc cd, boolean link) { duke@1: if (link) { jjg@1372: return writer.getHyperLink("annotation_type_optional_element_summary", bpatel@766: writer.getResource("doclet.navAnnotationTypeOptionalMember")); duke@1: } else { bpatel@766: return writer.getResource("doclet.navAnnotationTypeOptionalMember"); duke@1: } duke@1: } duke@1: }