org.exolab.javasource
Class JAnnotatedElementHelper

java.lang.Object
  extended by org.exolab.javasource.JAnnotatedElementHelper
All Implemented Interfaces:
JAnnotatedElement
Direct Known Subclasses:
AbstractJField, JConstructor, JEnumConstant, JMethodSignature, JParameter

public class JAnnotatedElementHelper
extends java.lang.Object
implements JAnnotatedElement

Implements JAnnotatedElement interface on behalf of other classes in this package that implement this interface.

Version:
$Revision: 8009 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
Author:
Andrew Fawcett

Constructor Summary
JAnnotatedElementHelper()
          Creates a JAnnodatedElementHelper.
 
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 this source element has any annotations.
 boolean isAnnotationPresent(JAnnotationType annotationType)
          Returns true if a JAnnotation exists for the given JAnnotationType.
 boolean printAnnotations(JSourceWriter jsw)
          Outputs the list of annotations maintained by this object.
 JAnnotation removeAnnotation(JAnnotationType annotationType)
          Removes the JAnnotation from this source element for the given JAnnotationType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JAnnotatedElementHelper

public JAnnotatedElementHelper()
Creates a JAnnodatedElementHelper.

Method Detail

getAnnotation

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

Specified by:
getAnnotation in interface JAnnotatedElement
Parameters:
annotationType - Annotation type to retrieve.
Returns:
A JAnnotation for the given JAnnotationType.

getAnnotations

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

Specified by:
getAnnotations in interface JAnnotatedElement
Returns:
A list of all JAnnotations associated with this source element.

isAnnotationPresent

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

Specified by:
isAnnotationPresent in interface JAnnotatedElement
Parameters:
annotationType - Annotation type to check for presence or absense.
Returns:
True if a JAnnotation has been added for the given JAnnotationType.

addAnnotation

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

Specified by:
addAnnotation in interface JAnnotatedElement
Parameters:
annotation - A JAnnotation to add to this source element.

removeAnnotation

public final JAnnotation removeAnnotation(JAnnotationType annotationType)
Removes the JAnnotation from this source element for the given JAnnotationType. An IllegalArgumentException is thrown if the provided JAnnotation isn't present.

Specified by:
removeAnnotation in interface JAnnotatedElement
Parameters:
annotationType - Annotation type to remove.
Returns:
The JAnnotation that was associated with this source element.

hasAnnotations

public final boolean hasAnnotations()
Returns true if this source element has any annotations.

Specified by:
hasAnnotations in interface JAnnotatedElement
Returns:
Returns true if this source element has any annotations.

printAnnotations

public final boolean printAnnotations(JSourceWriter jsw)
Outputs the list of annotations maintained by this object.

Parameters:
jsw - the JSourceWriter to print the annotations to
Returns:
true if at least one annotation was printed, false otherwise.


Copyright © 2011. All Rights Reserved.