KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > rules > ExcessiveImports


1 /**
2  * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3  */

4 package net.sourceforge.pmd.rules;
5
6 import net.sourceforge.pmd.ast.ASTCompilationUnit;
7 import net.sourceforge.pmd.ast.ASTImportDeclaration;
8 import net.sourceforge.pmd.rules.design.ExcessiveNodeCountRule;
9 import net.sourceforge.pmd.util.NumericConstants;
10
11 /**
12  * ExcessiveImports attempts to count all unique imports a class
13  * contains. This rule will count a "import com.something.*;" as a single
14  * import. This is a unqiue situation and I'd like to create an audit type
15  * rule that captures those.
16  *
17  * @author aglover
18  * @since Feb 21, 2003
19  */

20 public class ExcessiveImports extends ExcessiveNodeCountRule {
21
22     public ExcessiveImports() {
23         super(ASTCompilationUnit.class);
24     }
25
26     /**
27      * Hook method to count imports. This is a user defined value.
28      *
29      * @param node
30      * @param data
31      * @return Object
32      */

33     public Object JavaDoc visit(ASTImportDeclaration node, Object JavaDoc data) {
34         return NumericConstants.ONE;
35     }
36 }
37
Popular Tags