public final void analyze ( final File classesDir ) { final FileProcessor fileProcessor = new FileProcessor ( new FileHandler ( ) { @ Override public final FileHandlerResult handleFile ( final File classFile ) { if ( ! classFile . getName ( ) . endsWith ( ".class" ) ) { return FileHandlerResult . CONTINUE ; } try { final ClassInfo classInfo = new ClassInfo ( classFile ) ; final Package < DependsOn > allowedPkg = dependencies . findAllowedByName ( classInfo . getPackageName ( ) ) ; if ( allowedPkg == null ) { final Package < NotDependsOn > forbiddenPkg = dependencies . findForbiddenByName ( classInfo . getPackageName ( ) ) ; if ( forbiddenPkg == null ) { dependencyErrors . addAll ( checkAlwaysForbiddenSection ( dependencies , classInfo ) ) ; } else { dependencyErrors . addAll ( checkForbiddenSection ( dependencies , forbiddenPkg , classInfo ) ) ; } } else { dependencyErrors . addAll ( checkAllowedSection ( dependencies , allowedPkg , classInfo ) ) ; } } catch ( final IOException ex ) { throw new RuntimeException ( "Error handling file: " + classFile , ex ) ; } return FileHandlerResult . CONTINUE ; } } ) ; dependencyErrors . clear ( ) ; fileProcessor . process ( classesDir ) ; }
Analyze the dependencies for all classes in the directory and it s sub directories .