public interface IAnnotation extends IJavaElement, ISourceReference
Annotations are obtained using IAnnotatable.getAnnotation(String)
.
Note that annotations are not children of their declaring element.
To get a list of the annotations use IAnnotatable.getAnnotations()
.
ANNOTATION, CLASS_FILE, COMPILATION_UNIT, FIELD, IMPORT_CONTAINER, IMPORT_DECLARATION, INITIALIZER, JAVA_MODEL, JAVA_PROJECT, LOCAL_VARIABLE, METHOD, PACKAGE_DECLARATION, PACKAGE_FRAGMENT, PACKAGE_FRAGMENT_ROOT, TYPE, TYPE_PARAMETER
Modifier and Type | Method and Description |
---|---|
String |
getElementName()
Returns the name of this annotation.
|
IMemberValuePair[] |
getMemberValuePairs()
Returns the member-value pairs of this annotation.
|
int |
getOccurrenceCount()
Returns the position relative to the order this annotation is defined in the source.
|
exists, getAncestor, getAttachedJavadoc, getCorrespondingResource, getElementType, getHandleIdentifier, getJavaModel, getJavaProject, getOpenable, getParent, getPath, getPrimaryElement, getResource, getSchedulingRule, getUnderlyingResource, isReadOnly, isStructureKnown
getAdapter
exists, getNameRange, getSource, getSourceRange
String getElementName()
@MyAnnot
, the name
is "MyAnnot"), or a qualified name (e.g. for @x. y. MyAnnot
, the name is
"x.y.MyAnnot"). If this annotation is coming from a class file, this is always a fully
qualified name.
Note that the name has been trimmed from its whitespaces. To extract the name as it
appears in the source, use ISourceReference.getNameRange()
.
This is a handle-only method. The annotation may or may not be present.
getElementName
in interface IJavaElement
IMemberValuePair[] getMemberValuePairs() throws JavaModelException
"value"
.JavaModelException
- if this element does not exist or if an
exception occurs while accessing its corresponding resourceint getOccurrenceCount()
Two annotations ann1 and ann2 that are equal (e.g. 2 annotations with the same name on the same type) can be distinguished using their occurrence counts. If annotation ann1 appears first in the source, it will have an occurrence count of 1. If annotation ann2 appears right after annotation ann1, it will have an occurrence count of 2.
This is a handle-only method. The annotation may or may not be present.
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.