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

Tue, 09 Oct 2012 19:10:00 -0700

author
jjg
date
Tue, 09 Oct 2012 19:10:00 -0700
changeset 1357
c75be5bc5283
parent 1051
b0909f992710
child 1359
25e14ad23cef
permissions
-rw-r--r--

8000663: clean up langtools imports
Reviewed-by: darcy

     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.tools.javac.code.Kinds;
    31 import com.sun.tools.javac.code.Scope;
    32 import com.sun.tools.javac.code.Symbol.*;
    33 import com.sun.tools.javac.tree.JCTree.*;
    34 import com.sun.tools.javac.util.List;
    35 import com.sun.tools.javac.util.Names;
    36 import com.sun.tools.javac.util.Position;
    38 /**
    39  * Represents an annotation type.
    40  *
    41  * @author Scott Seligman
    42  * @since 1.5
    43  */
    45 public class AnnotationTypeDocImpl
    46         extends ClassDocImpl implements AnnotationTypeDoc {
    48     public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym) {
    49         this(env, sym, null, null, null);
    50     }
    52     public AnnotationTypeDocImpl(DocEnv env, ClassSymbol sym,
    53                           String doc, JCClassDecl tree, Position.LineMap lineMap) {
    54         super(env, sym, doc, tree, lineMap);
    55     }
    57     /**
    58      * Returns true, as this is an annotation type.
    59      * (For legacy doclets, return false.)
    60      */
    61     public boolean isAnnotationType() {
    62         return !isInterface();
    63     }
    65     /**
    66      * Returns false.  Though technically an interface, an annotation
    67      * type is not considered an interface for this purpose.
    68      * (For legacy doclets, returns true.)
    69      */
    70     public boolean isInterface() {
    71         return env.legacyDoclet;
    72     }
    74     /**
    75      * Returns an empty array, as all methods are annotation type elements.
    76      * (For legacy doclets, returns the elements.)
    77      * @see #elements()
    78      */
    79     public MethodDoc[] methods(boolean filter) {
    80         return env.legacyDoclet
    81                 ? (MethodDoc[])elements()
    82                 : new MethodDoc[0];
    83     }
    85     /**
    86      * Returns the elements of this annotation type.
    87      * Returns an empty array if there are none.
    88      * Elements are always public, so no need to filter them.
    89      */
    90     public AnnotationTypeElementDoc[] elements() {
    91         Names names = tsym.name.table.names;
    92         List<AnnotationTypeElementDoc> elements = List.nil();
    93         for (Scope.Entry e = tsym.members().elems; e != null; e = e.sibling) {
    94             if (e.sym != null && e.sym.kind == Kinds.MTH) {
    95                 MethodSymbol s = (MethodSymbol)e.sym;
    96                 elements = elements.prepend(env.getAnnotationTypeElementDoc(s));
    97             }
    98         }
    99         return
   100             elements.toArray(new AnnotationTypeElementDoc[elements.length()]);
   101     }
   102 }

mercurial