|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ContainerManagedMethodChecker | Line # 29 | 34.8% |
0.3478261
|
20.59 | 13 | 7 | 7 | 0.54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (2) | |||
| Result | |||
|
0.3478261
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testContainerBean
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testContainerBean
|
1 PASS | |
|
0.3478261
|
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testAbstractBean
com.puppycrawl.tools.checkstyle.checks.j2ee.EntityBeanCheckTest.testAbstractBean
|
1 PASS | |
| 1 | //////////////////////////////////////////////////////////////////////////////// | |
| 2 | // checkstyle: Checks Java source code for adherence to a set of rules. | |
| 3 | // Copyright (C) 2001-2005 Oliver Burn | |
| 4 | // | |
| 5 | // This library is free software; you can redistribute it and/or | |
| 6 | // modify it under the terms of the GNU Lesser General Public | |
| 7 | // License as published by the Free Software Foundation; either | |
| 8 | // version 2.1 of the License, or (at your option) any later version. | |
| 9 | // | |
| 10 | // This library is distributed in the hope that it will be useful, | |
| 11 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 13 | // Lesser General Public License for more details. | |
| 14 | // | |
| 15 | // You should have received a copy of the GNU Lesser General Public | |
| 16 | // License along with this library; if not, write to the Free Software | |
| 17 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 18 | //////////////////////////////////////////////////////////////////////////////// | |
| 19 | 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 | /** | |
| 25 | * Checks methods of entity beans with container-managed persistence. | |
| 26 | * Reference: Enterprise JavaBeansTM Specification,Version 2.0, Chapter 10 | |
| 27 | * @author Rick Giles | |
| 28 | */ | |
| 29 | public class ContainerManagedMethodChecker | |
| 30 | extends EntityBeanMethodChecker | |
| 31 | { | |
| 32 | /** | |
| 33 | * Constructs a ContainerManagedMethodChecker for a entity bean check. | |
| 34 | * @param aCheck the entity bean check. | |
| 35 | */ | |
| 36 | 2 |
public ContainerManagedMethodChecker(EntityBeanCheck aCheck) |
| 37 | { | |
| 38 | 2 | super(aCheck); |
| 39 | } | |
| 40 | ||
| 41 | /** | |
| 42 | * {@inheritDoc} | |
| 43 | */ | |
| 44 | 9 |
public void checkMethod(DetailAST aMethodAST) |
| 45 | { | |
| 46 | 9 | super.checkMethod(aMethodAST); |
| 47 | ||
| 48 | 9 | final DetailAST nameAST = aMethodAST.findFirstToken(TokenTypes.IDENT); |
| 49 | 9 | final String name = nameAST.getText(); |
| 50 | ||
| 51 | 9 | if (name.startsWith("ejbSelect")) { |
| 52 | 0 | checkSelectMethod(aMethodAST); |
| 53 | } | |
| 54 | } | |
| 55 | ||
| 56 | /** | |
| 57 | * Checks whether an ejbSelect<METHOD>(...) method of an | |
| 58 | * entity bean satisfies requirements. | |
| 59 | * @param aMethodAST the AST for the method definition. | |
| 60 | */ | |
| 61 | 0 |
protected void checkSelectMethod(DetailAST aMethodAST) |
| 62 | { | |
| 63 | // must be declared as public | |
| 64 | 0 | if (!Utils.isPublic(aMethodAST)) { |
| 65 | 0 | log(aMethodAST, "nonpublic.bean", new Object[] {"Method"}); |
| 66 | } | |
| 67 | // The method must be declared as abstract. | |
| 68 | 0 | if (!Utils.isAbstract(aMethodAST)) { |
| 69 | 0 | log(aMethodAST, "nonabstract.bean", new Object[] {"Method"}); |
| 70 | } | |
| 71 | // The throws clause must define the javax.ejb.FinderException. | |
| 72 | 0 | checkThrows(aMethodAST, "javax.ejb.FinderException"); |
| 73 | } | |
| 74 | ||
| 75 | /** | |
| 76 | * Checks whether an ejbCreate<METHOD>(...) method of an | |
| 77 | * entity bean satisfies requirements. | |
| 78 | * @param aMethodAST the AST for the method definition. | |
| 79 | */ | |
| 80 | 0 |
protected void checkCreateMethod(DetailAST aMethodAST) |
| 81 | { | |
| 82 | 0 | super.checkCreateMethod(aMethodAST); |
| 83 | ||
| 84 | // The throws clause must define the javax.ejb.CreateException. | |
| 85 | 0 | checkThrows(aMethodAST, "javax.ejb.CreateException"); |
| 86 | } | |
| 87 | } | |
|
|||||||||||||