1 package com.puppycrawl.tools.checkstyle.checks.j2ee; 20 21 import com.puppycrawl.tools.checkstyle.api.DetailAST; 22 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 23 24 29 public class MessageBeanMethodChecker 30 extends BeanMethodChecker 31 { 32 36 public MessageBeanMethodChecker(MessageBeanCheck aCheck) 37 { 38 super(aCheck); 39 } 40 41 42 private boolean mHasEjbCreate; 43 44 47 public void checkMethods(DetailAST aAST) 48 { 49 mHasEjbCreate = false; 50 51 super.checkMethods(aAST); 52 53 if (!mHasEjbCreate) { 54 final DetailAST nameAST = aAST.findFirstToken(TokenTypes.IDENT); 55 final String name = nameAST.getText(); 56 final String arg = "Message bean '" + name + "'"; 57 log(aAST, "missingmethod.bean", 58 new Object [] {arg, "ejbCreate()"}); 59 } 60 } 61 62 65 protected void checkCreateMethod(DetailAST aMethodAST) 66 { 67 final DetailAST nameAST = aMethodAST.findFirstToken(TokenTypes.IDENT); 68 final String name = nameAST.getText(); 69 if (name.equals("ejbCreate")) { 70 super.checkCreateMethod(aMethodAST); 71 mHasEjbCreate = true; 72 73 if (!Utils.isVoid(aMethodAST)) { 75 logName(aMethodAST, "nonvoidmethod.bean", new Object [] {}); 76 } 77 78 final DetailAST paramAST = 80 aMethodAST.findFirstToken(TokenTypes.PARAMETERS); 81 final int paramCount = paramAST.getChildCount(); 82 if (paramCount != 0) { 83 logName(aMethodAST, "paramcount.bean", new Object [] {"0"}); 84 } 85 } 86 } 87 } 88 | Popular Tags |