JavaTM 2 Platform
Standard Ed. 6

java.lang.annotation
枚举 ElementType

java.lang.Object
  继承者 java.lang.Enum<ElementType>
      继承者 java.lang.annotation.ElementType
所有已实现的接口:
Serializable, Comparable<ElementType>

public enum ElementType
extends Enum<ElementType>

程序元素类型。此枚举类型的常量提供了 Java 程序中声明的元素的简单分类。

这些常量与 Target 元注释类型一起使用,以指定在什么情况下使用注释类型是合法的。

从以下版本开始:
1.5

枚举常量摘要
ANNOTATION_TYPE
          注释类型声明
CONSTRUCTOR
          构造方法声明
FIELD
          字段声明(包括枚举常量)
LOCAL_VARIABLE
          局部变量声明
METHOD
          方法声明
PACKAGE
          包声明
PARAMETER
          参数声明
TYPE
          类、接口(包括注释类型)或枚举声明
 
方法摘要
static ElementType valueOf(String name)
          返回带有指定名称的该类型的枚举常量。
static ElementType[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
从类 java.lang.Enum 继承的方法
clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
从类 java.lang.Object 继承的方法
getClass, notify, notifyAll, wait, wait, wait
 

枚举常量详细信息

TYPE

public static final ElementType TYPE
类、接口(包括注释类型)或枚举声明


FIELD

public static final ElementType FIELD
字段声明(包括枚举常量)


METHOD

public static final ElementType METHOD
方法声明


PARAMETER

public static final ElementType PARAMETER
参数声明


CONSTRUCTOR

public static final ElementType CONSTRUCTOR
构造方法声明


LOCAL_VARIABLE

public static final ElementType LOCAL_VARIABLE
局部变量声明


ANNOTATION_TYPE

public static final ElementType ANNOTATION_TYPE
注释类型声明


PACKAGE

public static final ElementType PACKAGE
包声明

方法详细信息

values

public static final ElementType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for(ElementType c : ElementType.values())
        System.out.println(c);

返回:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static ElementType valueOf(String name)
返回带有指定名称的该类型的枚举常量。 字符串必须与用于声明该类型的枚举常量的 标识符完全匹配。(不允许有多余 的空格。)

参数:
指定要返回的枚举常量的名称。 -
返回:
返回带有指定名称的枚举常量
抛出:
如果该枚举类型没有带有指定名称的常量, - 则抛出 IllegalArgumentException

JavaTM 2 Platform
Standard Ed. 6

提交错误或意见

版权所有 2008 Sun Microsystems, Inc. 保留所有权利。请遵守GNU General Public License, version 2 only