src/share/classes/com/sun/tools/javadoc/AnnotationTypeDocImpl.java

Mon, 25 Mar 2013 16:55:14 -0700

author
mfang
date
Mon, 25 Mar 2013 16:55:14 -0700
changeset 1658
fdf30b225e1c
parent 1443
cfde9737131e
child 1755
ddb4a2bfcd82
permissions
-rw-r--r--

8010521: jdk8 l10n resource file translation update 2
Reviewed-by: naoto, yhuang

     1 /*
     2  * Copyright (c) 2003, 2012, 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.javadoc;
    28 import com.sun.javadoc.*;
    30 import com.sun.source.util.TreePath;
    31 import com.sun.tools.javac.code.Kinds;
    32 import com.sun.tools.javac.code.Scope;
    33 import com.sun.tools.javac.code.Symbol.*;
    34 import com.sun.tools.javac.tree.JCTree.*;
    35 import com.sun.tools.javac.util.List;
    36 import com.sun.tools.javac.util.Names;
    38 /**
    39  * Represents an annotation type.
    40  *
    41  *  <p><b>This is NOT part of any supported API.
    42  *  If you write code that depends on this, you do so at your own risk.
    43  *  This code and its internal interfaces are subject to change or
    44  *  deletion without notice.</b>
    45  *
    46  * @author Scott Seligman
    47  * @since 1.5
    48  */
    50 public class AnnotationTypeDocImpl
    51         extends ClassDocImpl implements AnnotationTypeDoc {
    53     public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) {
    54         this(env, sym, null);
    55     }
    57     public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym, TreePath treePath) {
    58         super(env, sym, treePath);
    59     }
    61     /**
    62      * Returns true, as this is an annotation type.
    63      * (For legacy doclets, return false.)
    64      */
    65     public boolean isAnnotationType() {
    66         return !isInterface();
    67     }
    69     /**
    70      * Returns false.  Though technically an interface, an annotation
    71      * type is not considered an interface for this purpose.
    72      * (For legacy doclets, returns true.)
    73      */
    74     public boolean isInterface() {
    75         return env.legacyDoclet;
    76     }
    78     /**
    79      * Returns an empty array, as all methods are annotation type elements.
    80      * (For legacy doclets, returns the elements.)
    81      * @see #elements()
    82      */
    83     public MethodDoc[] methods(boolean filter) {
    84         return env.legacyDoclet
    85                 ? (MethodDoc[])elements()
    86                 : new MethodDoc[0];
    87     }
    89     /**
    90      * Returns the elements of this annotation type.
    91      * Returns an empty array if there are none.
    92      * Elements are always public, so no need to filter them.
    93      */
    94     public AnnotationTypeElementDoc[] elements() {
    95         Names names = tsym.name.table.names;
    96         List<AnnotationTypeElementDoc> elements = List.nil();
    97         for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
    98             if (e.sym != null && e.sym.kind == Kinds.MTH) {
    99                 MethodSymbol s = (MethodSymbol)e.sym;
   100                 elements = elements.prepend(env.getAnnotationTypeElementDoc(s));
   101             }
   102         }
   103         return
   104             elements.toArray(new AnnotationTypeElementDoc[elements.length()]);
   105     }
   106 }

mercurial