org.codehaus.aspectwerkz.annotation
Class Annotations

java.lang.Object
  extended by org.codehaus.aspectwerkz.annotation.Annotations

public final class Annotations
extends Object

Utility class for annotation retrieval.
Note: Annotations are extracted out of ASMClassInfo
Note: caution when changing that to use reflection, since it might lead to load target class during aspect system startup.

Author:
Jonas BonŽr

Constructor Summary
Annotations()
           
 
Method Summary
static Annotation getAnnotation(Class annotation, Class klass)
          Return the annotation with a specific name for a specific class.
static Annotation getAnnotation(Class annotation, Constructor constructor)
          Return the annotation with a specific name for a specific constructor.
static Annotation getAnnotation(Class annotation, Field field)
          Return the annotation with a specific name for a specific field.
static Annotation getAnnotation(Class annotation, Method method)
          Return the annotation with a specific name for a specific method.
static Annotation getAnnotation(String annotationName, Class klass)
          Return the annotation with a specific name for a specific class.
static Annotation getAnnotation(String annotationName, Constructor constructor)
          Return the annotation with a specific name for a specific constructor.
static Annotation getAnnotation(String annotationName, Field field)
          Return the annotation with a specific name for a specific field.
static Annotation getAnnotation(String annotationName, Method method)
          Return the annotation with a specific name for a specific method.
static List getAnnotationInfos(Class klass)
          Return a list with the annotations for a specific class.
static List getAnnotationInfos(Constructor constructor)
          Return the annotations for a specific constructor.
static List getAnnotationInfos(Field field)
          Return the annotations for a specific field.
static List getAnnotationInfos(Method method)
          Return the annotations for a specific method.
static List getAnnotations(Class annotation, Class klass)
          Return a list with the annotations with a specific name for a specific class.
static List getAnnotations(Class annotation, Constructor constructor)
          Return a list with the annotations with a specific name for a specific constructor.
static List getAnnotations(Class annotation, Field field)
          Return a list with the annotations with a specific name for a specific field.
static List getAnnotations(Class annotation, Method method)
          Return a list with the annotations with a specific name for a specific method.
static List getAnnotations(String annotationName, Class klass)
          Return a list with the annotations with a specific name for a specific class.
static List getAnnotations(String annotationName, Constructor constructor)
          Return a list with the annotations with a specific name for a specific constructor.
static List getAnnotations(String annotationName, Field field)
          Return a list with the annotations with a specific name for a specific field.
static List getAnnotations(String annotationName, Method method)
          Return a list with the annotations with a specific name for a specific method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Annotations

public Annotations()
Method Detail

getAnnotation

public static Annotation getAnnotation(String annotationName,
                                       Class klass)
Return the annotation with a specific name for a specific class.

Parameters:
annotationName - the annotation name
klass - the java.lang.Class object to find the annotation on.
Returns:
the annotation or null

getAnnotation

public static Annotation getAnnotation(Class annotation,
                                       Class klass)
Return the annotation with a specific name for a specific class.

Parameters:
annotation - the annotation class
klass - the java.lang.Class object to find the annotation on.
Returns:
the annotation or null

getAnnotation

public static Annotation getAnnotation(String annotationName,
                                       Method method)
Return the annotation with a specific name for a specific method.

Parameters:
annotationName - the annotation name
method - the java.lang.refect.Method object to find the annotation on.
Returns:
the annotation or null

getAnnotation

public static Annotation getAnnotation(Class annotation,
                                       Method method)
Return the annotation with a specific name for a specific method.

Parameters:
annotation - the annotation class
method - the java.lang.refect.Method object to find the annotation on.
Returns:
the annotation or null

getAnnotation

public static Annotation getAnnotation(String annotationName,
                                       Constructor constructor)
Return the annotation with a specific name for a specific constructor.

Parameters:
annotationName - the annotation name
constructor - the java.lang.refect.Constructor object to find the annotation on.
Returns:
the annotation or null

getAnnotation

public static Annotation getAnnotation(Class annotation,
                                       Constructor constructor)
Return the annotation with a specific name for a specific constructor.

Parameters:
annotation - the annotation class
constructor - the java.lang.refect.Constructor object to find the annotation on.
Returns:
the annotation or null

getAnnotation

public static Annotation getAnnotation(String annotationName,
                                       Field field)
Return the annotation with a specific name for a specific field.

Parameters:
annotationName - the annotation name
field - the java.lang.reflect.Field object to find the annotation on.
Returns:
the annotation or null

getAnnotation

public static Annotation getAnnotation(Class annotation,
                                       Field field)
Return the annotation with a specific name for a specific field.

Parameters:
annotation - the annotation class
field - the java.lang.reflect.Field object to find the annotation on.
Returns:
the annotation or null

getAnnotations

public static List getAnnotations(String annotationName,
                                  Class klass)
Return a list with the annotations with a specific name for a specific class.

Parameters:
annotationName - the annotation name
klass - the java.lang.Class object to find the annotation on.
Returns:
the annotations in a list (can be empty)

getAnnotations

public static List getAnnotations(Class annotation,
                                  Class klass)
Return a list with the annotations with a specific name for a specific class.

Parameters:
annotation - the annotation class
klass - the java.lang.Class object to find the annotation on.
Returns:
the annotations in a list (can be empty)

getAnnotations

public static List getAnnotations(String annotationName,
                                  Method method)
Return a list with the annotations with a specific name for a specific method.

Parameters:
annotationName - the annotation name
method - the java.lang.refect.Method object to find the annotation on.
Returns:
the annotations in a list (can be empty)

getAnnotations

public static List getAnnotations(Class annotation,
                                  Method method)
Return a list with the annotations with a specific name for a specific method.

Parameters:
annotation - the annotation class
method - the java.lang.refect.Method object to find the annotation on.
Returns:
the annotations in a list (can be empty)

getAnnotations

public static List getAnnotations(String annotationName,
                                  Constructor constructor)
Return a list with the annotations with a specific name for a specific constructor.

Parameters:
annotationName - the annotation name
constructor - the java.lang.refect.Constructor object to find the annotation on.
Returns:
the annotations in a list (can be empty)

getAnnotations

public static List getAnnotations(Class annotation,
                                  Constructor constructor)
Return a list with the annotations with a specific name for a specific constructor.

Parameters:
annotation - the annotation class
constructor - the java.lang.refect.Constructor object to find the annotation on.
Returns:
the annotations in a list (can be empty)

getAnnotations

public static List getAnnotations(String annotationName,
                                  Field field)
Return a list with the annotations with a specific name for a specific field.

Parameters:
annotationName - the annotation name
field - the java.lang.reflect.Field object to find the annotation on.
Returns:
the annotations in a list (can be empty)

getAnnotations

public static List getAnnotations(Class annotation,
                                  Field field)
Return a list with the annotations with a specific name for a specific field.

Parameters:
annotation - the annotation class
field - the java.lang.reflect.Field object to find the annotation on.
Returns:
the annotations in a list (can be empty)

getAnnotationInfos

public static List getAnnotationInfos(Class klass)
Return a list with the annotations for a specific class.

Each annotation is wrapped in AnnotationInfoinstance.

Parameters:
klass - the java.lang.Class object to find the annotation on.
Returns:
a list with the annotations

getAnnotationInfos

public static List getAnnotationInfos(Method method)
Return the annotations for a specific method.

Each annotation is wrapped in AnnotationInfoinstance.

Parameters:
method - the java.lang.refect.Method object to find the annotation on.
Returns:
a list with the annotations

getAnnotationInfos

public static List getAnnotationInfos(Constructor constructor)
Return the annotations for a specific constructor.

Each annotation is wrapped in AnnotationInfoinstance.

Parameters:
constructor - the java.lang.reflect.Constructor object to find the annotation on.
Returns:
a list with the annotations

getAnnotationInfos

public static List getAnnotationInfos(Field field)
Return the annotations for a specific field.

Each annotation is wrapped in AnnotationInfoinstance.

Parameters:
field - the java.lang.reflect.Field object to find the annotation on.
Returns:
a list with the annotations


Copyright © 2002-2005 Jonas Bonér, Alexandre Vasseur. All Rights Reserved.