Datasheet

The start method takes a RootDoc as a parameter, which is automatically passed in by the javadoc
tool. The RootDoc provides the starting point to obtain access to all elements inside the source code, and
also information on the command line such as additional packages and classes.
The interfaces added to the doclet API for annotations are
AnnotationDesc, AnnotationDesc
.ElementValuePair
, AnnotationTypeDoc, AnnotationTypeElementDoc, and AnnotationValue.
Any element of Java source that can have annotations has an
annotations() method associated
with the doclet API’s counterpart to the source code element. These are
AnnotationTypeDoc,
AnnotationTypeElementDoc, ClassDoc, ConstructorDoc, ExecutableMemberDoc, FieldDoc,
MethodDoc, and MemberDoc. The annotations() method returns an array of AnnotationDesc.
AnnotationDesc
This class represents an annotation, which is an annotation type (AnnotationTypeDoc), and an array of
annotation type elements paired with their values.
AnnotationDesc defines the following methods.
Method Description
AnnotationTypeDoc Returns this annotation’s type.
annotationType()
AnnotationDesc Returns an array of an annotation’s elements and their values.
.ElementValuePair[] Only elements explicitly listed are returned. The elements that
elementValues() aren’t listed explicitly, which assume their default value, are
not returned because this method processes just what is listed.
If there are no elements, an empty array is returned.
AnnotationDesc.ElementValuePair
This represents an association between an annotation type’s element and its value. The following methods
are defined.
Method Description
AnnotationTypeElementDoc Returns the annotation type element.
element()
AnnotationValue value() Returns the annotation type element’s value.
AnnotationTypeDoc
This interface represents an annotation in the source code, just like ClassDoc represents a Class. Only
one method is defined.
Method Description
AnnotationTypeElementDoc[] Returns an array of the elements of this annotation type.
elements()
29
Chapter 1: Key Java Language Features and Libraries
05_777106 ch01.qxp 11/28/06 10:43 PM Page 29