src/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java

Fri, 18 Jun 2010 21:13:56 -0700

author
jjg
date
Fri, 18 Jun 2010 21:13:56 -0700
changeset 589
4177f5bdd189
parent 554
9d9f26857129
child 766
90af8d87741f
permissions
-rw-r--r--

6961178: Allow doclet.xml to contain XML attributes
Reviewed-by: bpatel

     1 /*
     2  * Copyright (c) 2003, 2008, 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.internal.toolkit.builders;
    29 import com.sun.tools.doclets.internal.toolkit.util.*;
    30 import com.sun.tools.doclets.internal.toolkit.*;
    31 import com.sun.javadoc.*;
    32 import java.util.*;
    34 /**
    35  * Builds documentation for optional annotation type members.
    36  *
    37  * This code is not part of an API.
    38  * It is implementation that is subject to change.
    39  * Do not use it as an API
    40  *
    41  * @author Jamie Ho
    42  * @since 1.5
    43  */
    44 public class AnnotationTypeOptionalMemberBuilder extends
    45     AnnotationTypeRequiredMemberBuilder {
    48     /**
    49      * Construct a new AnnotationTypeMemberBuilder.
    50      *
    51      * @param configuration the current configuration of the
    52      *                      doclet.
    53      */
    54     private AnnotationTypeOptionalMemberBuilder(Configuration configuration) {
    55         super(configuration);
    56     }
    59     /**
    60      * Construct a new AnnotationTypeMemberBuilder.
    61      *
    62      * @param configuration the current configuration of the doclet.
    63      * @param classDoc the class whoses members are being documented.
    64      * @param writer the doclet specific writer.
    65      */
    66     public static AnnotationTypeOptionalMemberBuilder getInstance(
    67             Configuration configuration, ClassDoc classDoc,
    68             AnnotationTypeOptionalMemberWriter writer) {
    69         AnnotationTypeOptionalMemberBuilder builder =
    70             new AnnotationTypeOptionalMemberBuilder(configuration);
    71         builder.classDoc = classDoc;
    72         builder.writer = writer;
    73         builder.visibleMemberMap = new VisibleMemberMap(classDoc,
    74             VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated);
    75         builder.members = new ArrayList<ProgramElementDoc>(
    76             builder.visibleMemberMap.getMembersFor(classDoc));
    77         if (configuration.getMemberComparator() != null) {
    78             Collections.sort(builder.members,
    79                 configuration.getMemberComparator());
    80         }
    81         return builder;
    82     }
    84     /**
    85      * {@inheritDoc}
    86      */
    87     @Override
    88     public String getName() {
    89         return "AnnotationTypeOptionalMemberDetails";
    90     }
    92     /**
    93      * Build the member documentation.
    94      *
    95      * @param elements the XML elements that specify how to construct this
    96      *                documentation.
    97      */
    98     public void buildAnnotationTypeOptionalMember(XMLNode node) {
    99         if (writer == null) {
   100             return;
   101         }
   102         for (currentMemberIndex = 0; currentMemberIndex < members.size();
   103             currentMemberIndex++) {
   104             buildChildren(node);
   105         }
   106     }
   108     /**
   109      * Document the default value for this optional member.
   110      */
   111     public void buildDefaultValueInfo(XMLNode node) {
   112         ((AnnotationTypeOptionalMemberWriter) writer).writeDefaultValueInfo(
   113             (MemberDoc) members.get(currentMemberIndex));
   114     }
   116     /**
   117      * {@inheritDoc}
   118      */
   119     @Override
   120     public AnnotationTypeRequiredMemberWriter getWriter() {
   121         return writer;
   122     }
   123 }

mercurial