org.cruxframework.crux.scanner
Class AnnotationDB

java.lang.Object
  extended by org.cruxframework.crux.scanner.AbstractScanner
      extended by org.cruxframework.crux.scanner.AnnotationDB
All Implemented Interfaces:
Serializable

public class AnnotationDB
extends AbstractScanner
implements Serializable

A class scanner that builds an index of classes by annotations and implemented interfaces. Based on Scannotation library from Bill Burke.

Author:
Bill Burke, Thiago da Rosa de Bustamante
See Also:
Serialized Form

Field Summary
protected  Map<String,Set<String>> annotationIndex
           
protected  Map<String,Set<String>> classIndex
           
protected  Map<String,Set<String>> classInterfaces
           
protected  Map<String,Set<String>> implementsIndex
           
protected  Map<String,Set<String>> interfacesIndex
           
protected  boolean scanFieldAnnotations
           
protected  boolean scanMethodAnnotations
           
protected  Set<URL> scannedURLs
           
protected  boolean scanParameterAnnotations
           
protected  Map<String,String> superClasses
           
 
Constructor Summary
AnnotationDB()
           
 
Method Summary
 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.
protected  Set<String> getInterfacesFromSuperClass(String className, Set<String> processedClasses)
           
 Map<String,Set<String>> getInterfacesIndex()
           
 Scanners.ScannerCallback getScannerCallback()
           
 Filter getScannerFilter()
           
 void outputAnnotationIndex(PrintWriter writer)
          Prints out annotationIndex
protected  void populate(javassist.bytecode.annotation.Annotation[] annotations, String className)
           
protected  void populateInterfaces(javassist.bytecode.ClassFile cf)
           
protected  void populateInterfaces(String[] interfaces, String className)
           
protected  void populateInterfacesFromSuperClass()
           
 void resetScanner()
           
 void scanArchives()
          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 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 setScanParameterAnnotations(boolean scanParameterAnnotations)
          Whether or not you want AnnotationDB to scan for parameter level annotations
 
Methods inherited from class org.cruxframework.crux.scanner.AbstractScanner
runScanner
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

annotationIndex

protected Map<String,Set<String>> annotationIndex

implementsIndex

protected Map<String,Set<String>> implementsIndex

classIndex

protected Map<String,Set<String>> classIndex

scannedURLs

protected Set<URL> scannedURLs

interfacesIndex

protected Map<String,Set<String>> interfacesIndex

superClasses

protected Map<String,String> superClasses

classInterfaces

protected Map<String,Set<String>> classInterfaces

scanMethodAnnotations

protected transient boolean scanMethodAnnotations

scanParameterAnnotations

protected transient boolean scanParameterAnnotations

scanFieldAnnotations

protected transient boolean scanFieldAnnotations
Constructor Detail

AnnotationDB

public AnnotationDB()
Method Detail

getAnnotationIndex

public Map<String,Set<String>> getAnnotationIndex()
returns a map keyed by the fully qualified string name of a annotation class. The Set returne is a list of classes that use that annotation somehow.


getClassIndex

public Map<String,Set<String>> getClassIndex()
returns a map keyed by the list of classes scanned. The value set returned is a list of annotations used by that class.


getInterfacesIndex

public Map<String,Set<String>> getInterfacesIndex()
Returns:

setScanMethodAnnotations

public void setScanMethodAnnotations(boolean scanMethodAnnotations)
Wheter or not you want AnnotationDB to scan for method level annotations

Parameters:
scanMethodAnnotations -

setScanParameterAnnotations

public void setScanParameterAnnotations(boolean scanParameterAnnotations)
Whether or not you want AnnotationDB to scan for parameter level annotations

Parameters:
scanParameterAnnotations -

setScanFieldAnnotations

public void setScanFieldAnnotations(boolean scanFieldAnnotations)
Whether or not you want AnnotationDB to scan for parameter level annotations

Parameters:
scanFieldAnnotations -

getScannerFilter

public Filter getScannerFilter()
Specified by:
getScannerFilter in class AbstractScanner

getScannerCallback

public Scanners.ScannerCallback getScannerCallback()
Specified by:
getScannerCallback in class AbstractScanner

scanArchives

public void scanArchives()
Scan a url that represents an "archive" this is a classpath directory or jar file

Parameters:
urls - variable list of URLs to scan as archives

resetScanner

public void resetScanner()
Specified by:
resetScanner in class AbstractScanner

scanClass

public void scanClass(InputStream bits)
               throws IOException
Parse a .class file for annotations

Parameters:
bits - input stream pointing to .class file bits
Throws:
IOException

populateInterfaces

protected void populateInterfaces(javassist.bytecode.ClassFile cf)

populateInterfaces

protected void populateInterfaces(String[] interfaces,
                                  String className)

populateInterfacesFromSuperClass

protected void populateInterfacesFromSuperClass()

getInterfacesFromSuperClass

protected Set<String> getInterfacesFromSuperClass(String className,
                                                  Set<String> processedClasses)

scanClass

protected void scanClass(javassist.bytecode.ClassFile cf)

scanMethods

protected void scanMethods(javassist.bytecode.ClassFile cf)
Scanns both the method and its parameters for annotations.

Parameters:
cf -

scanFields

protected void scanFields(javassist.bytecode.ClassFile cf)

populate

protected void populate(javassist.bytecode.annotation.Annotation[] annotations,
                        String className)

outputAnnotationIndex

public void outputAnnotationIndex(PrintWriter writer)
Prints out annotationIndex

Parameters:
writer -


Copyright © 2014. All rights reserved.