com.opensymphony.xwork2.util
Class AnnotationUtils

java.lang.Object
  extended by com.opensymphony.xwork2.util.AnnotationUtils

public class AnnotationUtils
extends java.lang.Object

AnnotationUtils Various utility methods dealing with annotations

Version:
$Id: AnnotationUtils.java 894090 2009-12-27 18:18:29Z martinc $
Author:
Rainer Hermanns, Zsolt Szasz, zsolt at lorecraft dot com, Dan Oxlade, dan d0t oxlade at gmail d0t c0m

Constructor Summary
AnnotationUtils()
           
 
Method Summary
static void addAllFields(java.lang.Class annotationClass, java.lang.Class clazz, java.util.List<java.lang.reflect.Field> allFields)
          Adds all fields with the specified Annotation of class clazz and its superclasses to allFields
static void addAllInterfaces(java.lang.Class clazz, java.util.List<java.lang.Class> allInterfaces)
           
static void addAllMethods(java.lang.Class annotationClass, java.lang.Class clazz, java.util.List<java.lang.reflect.Method> allMethods)
          Adds all methods with the specified Annotation of class clazz and its superclasses to allFields
static java.lang.String[] find(java.lang.Class clazz, java.lang.String pckgname)
          Retrieves all classes within a packages.
static java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
          Deprecated. since 2.0.4 use getAnnotatedMethods
static void findRecursively(java.lang.Class clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.util.List<java.lang.reflect.Method> methods)
          Deprecated. since 2.0.4 use getAnnotatedMethods
static java.util.Collection<java.lang.reflect.Method> getAnnotatedMethods(java.lang.Class clazz, java.lang.Class<? extends java.lang.annotation.Annotation>... annotation)
          For the given Class get a collection of the the AnnotatedElements that match the given annotations or if no annotations are specified then return all of the annotated elements of the given Class.
static boolean isAnnotatedBy(java.lang.reflect.AnnotatedElement annotatedElement, java.lang.Class<? extends java.lang.annotation.Annotation>... annotation)
          Varargs version of AnnotatedElement.isAnnotationPresent()
static java.lang.String resolvePropertyName(java.lang.reflect.Method method)
          Returns the property name for a method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationUtils

public AnnotationUtils()
Method Detail

addAllFields

public static void addAllFields(java.lang.Class annotationClass,
                                java.lang.Class clazz,
                                java.util.List<java.lang.reflect.Field> allFields)
Adds all fields with the specified Annotation of class clazz and its superclasses to allFields

Parameters:
annotationClass -
clazz -
allFields -

addAllMethods

public static void addAllMethods(java.lang.Class annotationClass,
                                 java.lang.Class clazz,
                                 java.util.List<java.lang.reflect.Method> allMethods)
Adds all methods with the specified Annotation of class clazz and its superclasses to allFields

Parameters:
annotationClass -
clazz -
allMethods -

addAllInterfaces

public static void addAllInterfaces(java.lang.Class clazz,
                                    java.util.List<java.lang.Class> allInterfaces)
Parameters:
clazz -
allInterfaces -

getAnnotatedMethods

public static final java.util.Collection<java.lang.reflect.Method> getAnnotatedMethods(java.lang.Class clazz,
                                                                                       java.lang.Class<? extends java.lang.annotation.Annotation>... annotation)
For the given Class get a collection of the the AnnotatedElements that match the given annotations or if no annotations are specified then return all of the annotated elements of the given Class. Includes only the method level annotations.

Parameters:
clazz - The Class to inspect
annotation - the Annotations to find
Returns:
A Collection<AnnotatedElement> containing all of the method AnnotatedElements matching the specified Annotations

isAnnotatedBy

public static final boolean isAnnotatedBy(java.lang.reflect.AnnotatedElement annotatedElement,
                                          java.lang.Class<? extends java.lang.annotation.Annotation>... annotation)
Varargs version of AnnotatedElement.isAnnotationPresent()

See Also:
AnnotatedElement

findAnnotatedMethods

@Deprecated
public static java.util.List<java.lang.reflect.Method> findAnnotatedMethods(java.lang.Class clazz,
                                                                                       java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
Deprecated. since 2.0.4 use getAnnotatedMethods


findRecursively

@Deprecated
public static void findRecursively(java.lang.Class clazz,
                                              java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
                                              java.util.List<java.lang.reflect.Method> methods)
Deprecated. since 2.0.4 use getAnnotatedMethods


resolvePropertyName

public static java.lang.String resolvePropertyName(java.lang.reflect.Method method)
Returns the property name for a method. This method is independant from property fields.

Parameters:
method - The method to get the property name for.
Returns:
the property name for given method; null if non could be resolved.

find

public static java.lang.String[] find(java.lang.Class clazz,
                                      java.lang.String pckgname)
Retrieves all classes within a packages. TODO: this currently does not work with jars.

Parameters:
pckgname -
Returns:
Array of full qualified class names from this package.


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.