View Javadoc
1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.java.rule.naming;
5   
6   import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration;
7   import net.sourceforge.pmd.lang.java.ast.ASTMethodDeclarator;
8   import net.sourceforge.pmd.lang.java.ast.ASTVariableDeclaratorId;
9   import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule;
10  
11  public class AvoidDollarSignsRule extends AbstractJavaRule {
12  
13      public Object visit(ASTClassOrInterfaceDeclaration node, Object data) {
14          if (node.getImage().indexOf('$') != -1) {
15              addViolation(data, node);
16              return data;
17          }
18          return super.visit(node, data);
19      }
20  
21      public Object visit(ASTVariableDeclaratorId node, Object data) {
22          if (node.getImage().indexOf('$') != -1) {
23              addViolation(data, node);
24              return data;
25          }
26          return super.visit(node, data);
27      }
28  
29      public Object visit(ASTMethodDeclarator node, Object data) {
30          if (node.getImage().indexOf('$') != -1) {
31              addViolation(data, node);
32              return data;
33          }
34          return super.visit(node, data);
35      }
36  
37  }