public class AnnotationDB extends Object implements Serializable
| Modifier and Type | Class and Description |
|---|---|
class |
AnnotationDB.CrossReferenceException |
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Set<String>> |
annotationIndex |
protected Map<String,Set<String>> |
classIndex |
protected boolean |
ignoreBadURLs |
protected String[] |
ignoredPackages |
protected Map<String,Set<String>> |
implementsIndex |
protected boolean |
scanClassAnnotations |
protected boolean |
scanFieldAnnotations |
protected boolean |
scanMethodAnnotations |
protected String[] |
scanPackages |
protected boolean |
scanParameterAnnotations |
| Constructor and Description |
|---|
AnnotationDB() |
| Modifier and Type | Method and Description |
|---|---|
void |
addIgnoredPackages(String... ignored) |
void |
crossReferenceImplementedInterfaces()
Sometimes you want to see if a particular class implements an interface with certain annotations
After you have loaded all your classpaths with the scanArchive() method, call this method to cross reference
a class's implemented interfaces.
|
void |
crossReferenceMetaAnnotations()
This method will cross reference annotations in the annotation index with any meta-annotations that they have
and create additional entries as needed.
|
Map<String,Set<String>> |
getAnnotationIndex()
returns a map keyed by the fully qualified string name of a annotation class.
|
Map<String,Set<String>> |
getClassIndex()
returns a map keyed by the list of classes scanned.
|
String[] |
getIgnoredPackages() |
String[] |
getScanPackages() |
void |
outputAnnotationIndex(PrintWriter writer)
Prints out annotationIndex
|
protected void |
populate(javassist.bytecode.annotation.Annotation[] annotations,
String className) |
void |
scanArchives(URL... urls)
Scan a url that represents an "archive" this is a classpath directory or jar file
|
protected void |
scanClass(javassist.bytecode.ClassFile cf) |
void |
scanClass(InputStream bits)
Parse a .class file for annotations
|
protected void |
scanFields(javassist.bytecode.ClassFile cf) |
protected void |
scanMethods(javassist.bytecode.ClassFile cf)
Scanns both the method and its parameters for annotations.
|
void |
setIgnoreBadURLs(boolean ignoreBadURLs)
Whether or not you want AnnotationDB to ignore bad URLs passed to scanArchives.
|
void |
setIgnoredPackages(String[] ignoredPackages)
Override/overwrite any ignored packages
|
void |
setScanClassAnnotations(boolean scanClassAnnotations)
Whether or not you want AnnotationDB to scan for class level annotations
|
void |
setScanFieldAnnotations(boolean scanFieldAnnotations)
Whether or not you want AnnotationDB to scan for parameter level annotations
|
void |
setScanMethodAnnotations(boolean scanMethodAnnotations)
Wheter or not you want AnnotationDB to scan for method level annotations
|
void |
setScanPackages(String[] scanPackages)
Set explicit packages to scan.
|
void |
setScanParameterAnnotations(boolean scanParameterAnnotations)
Whether or not you want AnnotationDB to scan for parameter level annotations
|
protected transient boolean scanClassAnnotations
protected transient boolean scanMethodAnnotations
protected transient boolean scanParameterAnnotations
protected transient boolean scanFieldAnnotations
protected transient String[] ignoredPackages
protected transient String[] scanPackages
protected transient boolean ignoreBadURLs
public String[] getScanPackages()
public void setScanPackages(String[] scanPackages)
scanPackages - packages to scan or nullpublic String[] getIgnoredPackages()
public void setIgnoredPackages(String[] ignoredPackages)
ignoredPackages - cannot be nullpublic void addIgnoredPackages(String... ignored)
public void crossReferenceMetaAnnotations()
throws AnnotationDB.CrossReferenceException
public void crossReferenceImplementedInterfaces()
throws AnnotationDB.CrossReferenceException
AnnotationDB.CrossReferenceException - an Exception thrown if referenced interfaces haven't been scannedpublic Map<String,Set<String>> getAnnotationIndex()
public Map<String,Set<String>> getClassIndex()
public void setScanClassAnnotations(boolean scanClassAnnotations)
scanClassAnnotations - public void setScanMethodAnnotations(boolean scanMethodAnnotations)
scanMethodAnnotations - public void setScanParameterAnnotations(boolean scanParameterAnnotations)
scanParameterAnnotations - public void setScanFieldAnnotations(boolean scanFieldAnnotations)
scanFieldAnnotations - public void setIgnoreBadURLs(boolean ignoreBadURLs)
ignoreBadURLs - public void scanArchives(URL... urls) throws IOException
urls - variable list of URLs to scan as archivesIOExceptionpublic void scanClass(InputStream bits) throws IOException
bits - input stream pointing to .class file bitsIOExceptionprotected void scanClass(javassist.bytecode.ClassFile cf)
protected void scanMethods(javassist.bytecode.ClassFile cf)
cf - protected void scanFields(javassist.bytecode.ClassFile cf)
protected void populate(javassist.bytecode.annotation.Annotation[] annotations,
String className)
public void outputAnnotationIndex(PrintWriter writer)
writer - Copyright © 2015. All Rights Reserved.