01: package net.sourceforge.pmd.rules.imports;
02:
03: import net.sourceforge.pmd.AbstractRule;
04: import net.sourceforge.pmd.ast.ASTImportDeclaration;
05: import net.sourceforge.pmd.ast.SimpleNode;
06:
07: public class DontImportSun extends AbstractRule {
08:
09: public Object visit(ASTImportDeclaration node, Object data) {
10: String img = ((SimpleNode) node.jjtGetChild(0)).getImage();
11: if (img.startsWith("sun.")
12: && !img.startsWith("sun.misc.Signal")) {
13: addViolation(data, node);
14: }
15: return data;
16: }
17:
18: }
|