org.exolab.javasource
Interface JAnnotatedElement

All Known Implementing Classes:
DescriptorJClass, JAnnotatedElementHelper, JAnnotationType, JClass, JClass.JInnerClass, JConstructor, JEnum, JEnumConstant, JField, JInterface, JMethod, JMethodSignature, JParameter, JStructure

public interface JAnnotatedElement

Interface defines methods for manipuling annotations held against various program code elements, such as classes, fields, methods etc. This interface is simalar to the java.lang.reflect.AnnotatedElement. Accept that it also allows modifications of associated annotations. It is implemented by the classes within this package that represent applicable code elements. Adding class annotations JClass lollipop = new JClass("Lollipop"); JAnnotationType endorsersType = new JAnnotationType("Endorsers"); JAnnotation endorsers = new JAnnotation(endorsersType); endorsers.setValue(new String[] { "\"Children\"", "\"Unscrupulous dentists\""}); lollipop.addAnnotation(endorsers); Outputs

Author:
Andrew Fawcett

Method Summary
 void addAnnotation(JAnnotation annotation)
          Adds a JAnnotation to this source element.
 JAnnotation getAnnotation(JAnnotationType annotationType)
          Retrieves a JAnnotation for the given JAnnotationType, returns null if no annotation has been set.
 JAnnotation[] getAnnotations()
          Returns a list of JAnnotation's already set on this source element
 boolean hasAnnotations()
          Returns true if annotations have been added to this source element
 boolean isAnnotationPresent(JAnnotationType annotationType)
          Returns true if a JAnnotation exists for the given JAnnotationType
 JAnnotation removeAnnotation(JAnnotationType annotationType)
          Removes the JAnnotation from this source element for the given JAnnotationType, throws a IllegalArgumentException if no JAnnotation has been added.
 

Method Detail

getAnnotation

JAnnotation getAnnotation(JAnnotationType annotationType)
Retrieves a JAnnotation for the given JAnnotationType, returns null if no annotation has been set.

Parameters:
annotationType -
Returns:
A JAnnotation for the given JAnnotationType

getAnnotations

JAnnotation[] getAnnotations()
Returns a list of JAnnotation's already set on this source element

Returns:
A list of all JAnnotations associated with this source element

isAnnotationPresent

boolean isAnnotationPresent(JAnnotationType annotationType)
Returns true if a JAnnotation exists for the given JAnnotationType

Parameters:
annotationType -
Returns:
True if a JAnnotation has been added for the given JAnnotationType

addAnnotation

void addAnnotation(JAnnotation annotation)
                   throws java.lang.IllegalArgumentException
Adds a JAnnotation to this source element. An IllegalArgumentException is thrown if one already exists for the associated JAnnotationType.

Parameters:
annotation -
Throws:
java.lang.IllegalArgumentException

removeAnnotation

JAnnotation removeAnnotation(JAnnotationType annotationType)
                             throws java.lang.IllegalArgumentException
Removes the JAnnotation from this source element for the given JAnnotationType, throws a IllegalArgumentException if no JAnnotation has been added.

Parameters:
annotationType -
Returns:
The JAnnotation that was associated with this source element
Throws:
java.lang.IllegalArgumentException

hasAnnotations

boolean hasAnnotations()
Returns true if annotations have been added to this source element

Returns:
Returns true if annotations have been added to this source element


Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com