public class AnnotationReader
extends java.lang.Object
java.lang.annotation.RetentionPolicy.RUNTIME annotations from the class' bytecode.
Can be used with a custom implementation of the BytecodeProvider
interface.| Modifier and Type | Class and Description |
|---|---|
static class |
AnnotationReader.ClassKey
Contains info about the class being parsed.
|
static class |
AnnotationReader.MemberKey
Unique key for class members (methods, fields and constructors) to be used in hash maps etc.
|
| Modifier and Type | Method and Description |
|---|---|
Annotation |
getAnnotation(java.lang.String annotationName)
Returns the class annotation with the name specified.
|
Annotation |
getAnnotation(java.lang.String annotationName,
java.lang.reflect.Constructor constructor)
Returns the constructor annotation with the name specified for the constructor specified.
|
Annotation |
getAnnotation(java.lang.String annotationName,
java.lang.reflect.Field field)
Returns the field annotation with the name specified for the field specified.
|
Annotation |
getAnnotation(java.lang.String annotationName,
java.lang.reflect.Method method)
Returns the method annotation with the name specified for the method specified.
|
AnnotationElement.Annotation |
getAnnotationElement(java.lang.String annotationName)
Returns the class annotation element with the name specified.
|
AnnotationElement.Annotation[] |
getAnnotationElements()
Returns all the class annotations.
|
Annotation[] |
getAnnotations()
Returns all the class annotations.
|
Annotation[] |
getAnnotations(java.lang.reflect.Constructor constructor)
Returns all the constructor annotations.
|
Annotation[] |
getAnnotations(java.lang.reflect.Field field)
Returns all the field annotations.
|
Annotation[] |
getAnnotations(java.lang.reflect.Method method)
Returns all the method annotations.
|
static byte[] |
getBytecodeFor(java.lang.String className,
java.lang.ClassLoader loader)
Returns the bytecode for a class.
|
static BytecodeProvider |
getBytecodeProviderFor(java.lang.Class klass)
Returns the bytecode provider.
|
static BytecodeProvider |
getBytecodeProviderFor(java.lang.String className,
java.lang.ClassLoader loader)
Returns the bytecode provider.
|
Annotation |
getConstructorAnnotation(java.lang.String annotationName,
java.lang.String constructorDesc,
java.lang.ClassLoader loader)
Returns the constructor annotation with the name specified for the constructor specified.
|
AnnotationElement.Annotation |
getConstructorAnnotationElement(java.lang.String annotationName,
java.lang.String desc)
Returns the annotation with the name specified for the constructor specified.
|
AnnotationElement.Annotation[] |
getConstructorAnnotationElements(java.lang.String desc)
Returns all the constructor annotation elements.
|
static BytecodeProvider |
getDefaultBytecodeProvider()
Returns the bytecode provider.
|
Annotation |
getFieldAnnotation(java.lang.String annotationName,
java.lang.String fieldName,
java.lang.String fieldDesc,
java.lang.ClassLoader loader)
Returns the field annotation with the name specified for the field specified.
|
AnnotationElement.Annotation |
getFieldAnnotationElement(java.lang.String annotationName,
java.lang.String name,
java.lang.String desc)
Returns the annotation with the name specified for the field specified.
|
AnnotationElement.Annotation[] |
getFieldAnnotationElements(java.lang.String name,
java.lang.String desc)
Returns all the field annotation elements.
|
Annotation |
getMethodAnnotation(java.lang.String annotationName,
java.lang.String methodName,
java.lang.String methodDesc,
java.lang.ClassLoader loader)
Returns the method annotation with the name specified for the method specified.
|
AnnotationElement.Annotation |
getMethodAnnotationElement(java.lang.String annotationName,
java.lang.String name,
java.lang.String desc)
Returns the method annotation with the name specified for the method specified.
|
AnnotationElement.Annotation[] |
getMethodAnnotationElements(java.lang.String name,
java.lang.String desc)
Returns all the method annotation elements.
|
static AnnotationReader |
getReaderFor(AnnotationReader.ClassKey classKey)
Returns the annotation reader for the class specified.
|
static AnnotationReader |
getReaderFor(java.lang.Class klass)
Returns the annotation reader for the class specified.
|
static AnnotationReader |
getReaderFor(java.lang.String className,
java.lang.ClassLoader loader)
Returns the annotation reader for the class specified.
|
boolean |
isAnnotationPresent(java.lang.String annotationName)
Checks if an annotation is present at a specific class.
|
boolean |
isAnnotationPresent(java.lang.String annotationName,
java.lang.reflect.Constructor constructor)
Checks if an annotation is present at a specific constructor.
|
boolean |
isAnnotationPresent(java.lang.String annotationName,
java.lang.reflect.Field field)
Checks if an annotation is present at a specific field.
|
boolean |
isAnnotationPresent(java.lang.String annotationName,
java.lang.reflect.Method method)
Checks if an annotation is present at a specific method.
|
boolean |
isConstructorAnnotationPresent(java.lang.String annotationName,
java.lang.String desc)
Checks if an annotation is present at a specific constructor.
|
boolean |
isFieldAnnotationPresent(java.lang.String annotationName,
java.lang.String name,
java.lang.String desc)
Checks if an annotation is present at a specific field.
|
boolean |
isMethodAnnotationPresent(java.lang.String annotationName,
java.lang.String name,
java.lang.String desc)
Checks if an annotation is present at a specific method.
|
static void |
refresh(java.lang.Class klass)
Resets the annotation reader for the class specified and triggers a new parsing of the newly read bytecode.
|
static void |
refresh(java.lang.String className,
java.lang.ClassLoader loader)
Resets the annotation reader for the class specified and triggers a new parsing of the newly read bytecode.
|
static void |
refreshAll()
Resets *all* the annotation reader and triggers a new parsing of the newly read bytecode.
|
static void |
setBytecodeProviderFor(java.lang.Class klass,
BytecodeProvider bytecodeProvider)
Sets the bytecode provider.
|
static void |
setBytecodeProviderFor(java.lang.String className,
java.lang.ClassLoader loader,
BytecodeProvider bytecodeProvider)
Sets the bytecode provider.
|
static void |
setDefaultBytecodeProvider(BytecodeProvider bytecodeProvider)
Sets the bytecode provider.
|
static java.lang.String |
toJavaName(java.lang.String desc)
Converts the annotion class description to a Java class name.
|
public static void setDefaultBytecodeProvider(BytecodeProvider bytecodeProvider)
bytecodeProvider - public static BytecodeProvider getDefaultBytecodeProvider()
public static void setBytecodeProviderFor(java.lang.Class klass,
BytecodeProvider bytecodeProvider)
klass - bytecodeProvider - public static void setBytecodeProviderFor(java.lang.String className,
java.lang.ClassLoader loader,
BytecodeProvider bytecodeProvider)
className - loader - bytecodeProvider - public static BytecodeProvider getBytecodeProviderFor(java.lang.Class klass)
klass - public static BytecodeProvider getBytecodeProviderFor(java.lang.String className, java.lang.ClassLoader loader)
className - loader - public static byte[] getBytecodeFor(java.lang.String className,
java.lang.ClassLoader loader)
throws java.lang.Exception
className - loader - java.lang.Exceptionpublic static AnnotationReader getReaderFor(java.lang.Class klass)
klass - public static AnnotationReader getReaderFor(java.lang.String className, java.lang.ClassLoader loader)
className - loader - public static AnnotationReader getReaderFor(AnnotationReader.ClassKey classKey)
classKey - public static void refresh(java.lang.Class klass)
parse and is therefore all the is needed to invoke to get a fully updated reader.klass - public static void refresh(java.lang.String className,
java.lang.ClassLoader loader)
parse and is therefore all the is needed to invoke to get a fully updated reader.className - loader - public static void refreshAll()
parse and is therefore all the is needed to invoke to get a fully updated reader.public static java.lang.String toJavaName(java.lang.String desc)
desc - public boolean isAnnotationPresent(java.lang.String annotationName)
annotationName - the annotation namepublic Annotation getAnnotation(java.lang.String annotationName)
annotationName - public Annotation[] getAnnotations()
public boolean isAnnotationPresent(java.lang.String annotationName,
java.lang.reflect.Constructor constructor)
annotationName - the annotation nameconstructor - the java.lang.reflect.Constructor object to find the annotations on.public Annotation getAnnotation(java.lang.String annotationName, java.lang.reflect.Constructor constructor)
annotationName - the annotation nameconstructor - the java.lang.reflect.Constructor object to find the annotations on.public Annotation getConstructorAnnotation(java.lang.String annotationName, java.lang.String constructorDesc, java.lang.ClassLoader loader)
annotationName - constructorDesc - loader - public Annotation[] getAnnotations(java.lang.reflect.Constructor constructor)
constructor - the java.lang.reflect.Constructor object to find the annotations on.public boolean isAnnotationPresent(java.lang.String annotationName,
java.lang.reflect.Method method)
annotationName - the annotation namemethod - the java.lang.reflect.Method object to find the annotations on.public Annotation getAnnotation(java.lang.String annotationName, java.lang.reflect.Method method)
annotationName - the annotation namemethod - the java.lang.reflect.Method object to find the annotations on.public Annotation getMethodAnnotation(java.lang.String annotationName, java.lang.String methodName, java.lang.String methodDesc, java.lang.ClassLoader loader)
annotationName - methodName - methodDesc - loader - public Annotation[] getAnnotations(java.lang.reflect.Method method)
method - the java.lang.reflect.Method object to find the annotations on.public boolean isAnnotationPresent(java.lang.String annotationName,
java.lang.reflect.Field field)
annotationName - the annotation namefield - the java.lang.reflect.Field object to find the annotations on.public Annotation getAnnotation(java.lang.String annotationName, java.lang.reflect.Field field)
annotationName - the annotation namefield - the java.lang.reflect.Field object to find the annotations on.public Annotation getFieldAnnotation(java.lang.String annotationName, java.lang.String fieldName, java.lang.String fieldDesc, java.lang.ClassLoader loader)
annotationName - fieldName - fieldDesc - loader - public Annotation[] getAnnotations(java.lang.reflect.Field field)
field - the java.lang.reflect.Field object to find the annotations on.public AnnotationElement.Annotation getAnnotationElement(java.lang.String annotationName)
annotationName - public AnnotationElement.Annotation[] getAnnotationElements()
public boolean isConstructorAnnotationPresent(java.lang.String annotationName,
java.lang.String desc)
annotationName - the annotation namedesc - the constructor descpublic AnnotationElement.Annotation getConstructorAnnotationElement(java.lang.String annotationName, java.lang.String desc)
annotationName - the annotation namedesc - the constructor descpublic AnnotationElement.Annotation[] getConstructorAnnotationElements(java.lang.String desc)
desc - the constructor descpublic boolean isMethodAnnotationPresent(java.lang.String annotationName,
java.lang.String name,
java.lang.String desc)
annotationName - the annotation namename - the method namedesc - the method descpublic AnnotationElement.Annotation getMethodAnnotationElement(java.lang.String annotationName, java.lang.String name, java.lang.String desc)
annotationName - the annotation namename - the method namedesc - the method descpublic AnnotationElement.Annotation[] getMethodAnnotationElements(java.lang.String name, java.lang.String desc)
name - the method namedesc - the method descpublic boolean isFieldAnnotationPresent(java.lang.String annotationName,
java.lang.String name,
java.lang.String desc)
annotationName - the annotation namename - the field namedesc - the field descpublic AnnotationElement.Annotation getFieldAnnotationElement(java.lang.String annotationName, java.lang.String name, java.lang.String desc)
annotationName - the annotation namename - the field namedesc - the field descpublic AnnotationElement.Annotation[] getFieldAnnotationElements(java.lang.String name, java.lang.String desc)
name - the field namedesc - the field desc