KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > pmd > rules > imports > DontImportSun


1 package net.sourceforge.pmd.rules.imports;
2
3 import net.sourceforge.pmd.AbstractRule;
4 import net.sourceforge.pmd.ast.ASTImportDeclaration;
5 import net.sourceforge.pmd.ast.SimpleNode;
6
7 public class DontImportSun extends AbstractRule {
8
9     public Object JavaDoc visit(ASTImportDeclaration node, Object JavaDoc data) {
10         String JavaDoc img = ((SimpleNode) node.jjtGetChild(0)).getImage();
11         if (img.startsWith("sun.") && !img.startsWith("sun.misc.Signal")) {
12             addViolation(data, node);
13         }
14         return data;
15     }
16
17 }
18
Popular Tags