View Javadoc

    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 visit(ASTImportDeclaration node, Object data) {
    10          String 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  }