KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > puppycrawl > tools > checkstyle > checks > blocks > LeftCurlyOption


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.blocks;
20
21 import com.puppycrawl.tools.checkstyle.checks.AbstractOption;
22 import java.util.HashMap JavaDoc;
23 import java.util.Map JavaDoc;
24
25 /**
26  * Represents the options for placing the left curly brace <code>'{'</code>.
27  *
28  * @author Oliver Burn
29  * @version 1
30  */

31 public final class LeftCurlyOption
32     extends AbstractOption
33 {
34     /** maps from a string representation to an option */
35     private static final Map JavaDoc STR_TO_OPT = new HashMap JavaDoc();
36
37     /**
38      * Represents the policy for placing the brace at the end of line. For
39      * example:
40      * <pre>
41      * if (condition) {
42      * ...
43      * </pre>
44      **/

45     public static final LeftCurlyOption EOL = new LeftCurlyOption("eol");
46
47     /**
48      * Represents the policy that if the brace will fit on the first line of
49      * the statement, taking into account maximum line length, then apply
50      * <code>EOL</code> rule. Otherwise apply the <code>NL</code>
51      * rule. <code>NLOW</code> is a mnemonic for "new line on wrap".
52      *
53      * <p> For the example above Checkstyle will enforce:
54      *
55      * <pre>
56      * if (condition) {
57      * ...
58      * </pre>
59      *
60      * But for a statement spanning multiple lines, Checkstyle will enforce:
61      *
62      * <pre>
63      * if (condition1 && condition2 &&
64      * condition3 && condition4)
65      * {
66      * ...
67      * </pre>
68      **/

69     public static final LeftCurlyOption NLOW = new LeftCurlyOption("nlow");
70
71     /**
72      * Represents the policy that the brace must always be on a new line. For
73      * example:
74      * <pre>
75      * if (condition)
76      * {
77      * ...
78      * </pre>
79      */

80     public static final LeftCurlyOption NL = new LeftCurlyOption("nl");
81
82     /**
83      * Creates a new <code>LeftCurlyOption</code> instance.
84      * @param aStrRep the string representation
85      */

86     private LeftCurlyOption(String JavaDoc aStrRep)
87     {
88         super(aStrRep);
89     }
90
91     /** {@inheritDoc} */
92     protected Map JavaDoc getStrToOpt()
93     {
94         return STR_TO_OPT;
95     }
96 }
97
Popular Tags