Source code: com/puppycrawl/tools/checkstyle/checks/BlockOption.java
1 ////////////////////////////////////////////////////////////////////////////////
2 // checkstyle: Checks Java source code for adherence to a set of rules.
3 // Copyright (C) 2001-2002 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;
20
21 import java.util.HashMap;
22 import java.util.Map;
23
24 /**
25 * Represents the policy for checking block statements.
26 * @see com.puppycrawl.tools.checkstyle.checks.EmptyBlockCheck
27 * @author Rick Giles
28 */
29 public final class BlockOption
30 extends AbstractOption
31 {
32 /** maps from a string representation to an option */
33 private static final Map STR_TO_OPT = new HashMap();
34
35 /**
36 * Represents the policy that there is some text in the block. For example:
37 *
38 * <pre>
39 * catch (Exception ex) {
40 * // This is a bad coding practice
41 * }
42 * </pre>
43 */
44 public static final BlockOption TEXT = new BlockOption("text");
45
46 /**
47 * Represents the policy that there is a statement in the block. For
48 * example:
49 *
50 * <pre>
51 * finally {
52 * lock.release();
53 * }
54 * </pre>
55 */
56 public static final BlockOption STMT = new BlockOption("statement");
57
58 /**
59 * Creates a new <code>BlockOption</code> instance.
60 *
61 * @param aStrRep the string representation
62 */
63 private BlockOption(String aStrRep)
64 {
65 super(aStrRep);
66 }
67
68 /** @see com.puppycrawl.tools.checkstyle.checks.AbstractOption */
69 protected Map getStrToOpt()
70 {
71 return STR_TO_OPT;
72 }
73 }