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

Thu, 02 Oct 2008 19:58:40 -0700

author
xdono
date
Thu, 02 Oct 2008 19:58:40 -0700
changeset 117
24a47c3062fe
parent 74
5a9172b251dd
child 184
905e151a185a
permissions
-rw-r--r--

6754988: Update copyright year
Summary: Update for files that have been modified starting July 2008
Reviewed-by: ohair, tbell

     1 /*
     2  * Copyright 2003-2008 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  */
    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.*;
    33 import java.lang.reflect.*;
    35 /**
    36  * Builds documentation for optional annotation type members.
    37  *
    38  * This code is not part of an API.
    39  * It is implementation that is subject to change.
    40  * Do not use it as an API
    41  *
    42  * @author Jamie Ho
    43  * @since 1.5
    44  */
    45 public class AnnotationTypeOptionalMemberBuilder extends
    46     AnnotationTypeRequiredMemberBuilder {
    49     /**
    50      * Construct a new AnnotationTypeMemberBuilder.
    51      *
    52      * @param configuration the current configuration of the
    53      *                      doclet.
    54      */
    55     private AnnotationTypeOptionalMemberBuilder(Configuration configuration) {
    56         super(configuration);
    57     }
    60     /**
    61      * Construct a new AnnotationTypeMemberBuilder.
    62      *
    63      * @param configuration the current configuration of the doclet.
    64      * @param classDoc the class whoses members are being documented.
    65      * @param writer the doclet specific writer.
    66      */
    67     public static AnnotationTypeOptionalMemberBuilder getInstance(
    68             Configuration configuration, ClassDoc classDoc,
    69             AnnotationTypeOptionalMemberWriter writer) {
    70         AnnotationTypeOptionalMemberBuilder builder =
    71             new AnnotationTypeOptionalMemberBuilder(configuration);
    72         builder.classDoc = classDoc;
    73         builder.writer = writer;
    74         builder.visibleMemberMap = new VisibleMemberMap(classDoc,
    75             VisibleMemberMap.ANNOTATION_TYPE_MEMBER_OPTIONAL, configuration.nodeprecated);
    76         builder.members = new ArrayList<ProgramElementDoc>(
    77             builder.visibleMemberMap.getMembersFor(classDoc));
    78         if (configuration.getMemberComparator() != null) {
    79             Collections.sort(builder.members,
    80                 configuration.getMemberComparator());
    81         }
    82         return builder;
    83     }
    85     /**
    86      * {@inheritDoc}
    87      */
    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(List elements) {
    99         if (writer == null) {
   100             return;
   101         }
   102         for (currentMemberIndex = 0; currentMemberIndex < members.size();
   103             currentMemberIndex++) {
   104             build(elements);
   105         }
   106     }
   108     /**
   109      * {@inheritDoc}
   110      */
   111     public void invokeMethod(String methodName, Class[] paramClasses,
   112             Object[] params)
   113     throws Exception {
   114         if (DEBUG) {
   115             configuration.root.printError("DEBUG: " + this.getClass().getName()
   116                 + "." + methodName);
   117         }
   118         Method method = this.getClass().getMethod(methodName, paramClasses);
   119         method.invoke(this, params);
   120     }
   122     /**
   123      * Document the default value for this optional member.
   124      */
   125     public void buildDefaultValueInfo() {
   126         ((AnnotationTypeOptionalMemberWriter) writer).writeDefaultValueInfo(
   127             (MemberDoc) members.get(currentMemberIndex));
   128     }
   130     /**
   131      * {@inheritDoc}
   132      */
   133     public AnnotationTypeRequiredMemberWriter getWriter() {
   134         return writer;
   135     }
   136 }

mercurial