diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractLeftCurlyCheck.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractLeftCurlyCheck.java index b9601a091..ea8dbfdb5 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractLeftCurlyCheck.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/AbstractLeftCurlyCheck.java @@ -22,7 +22,11 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST; import com.puppycrawl.tools.checkstyle.api.Utils; /** - * Abstract class for checks for Left Curly placement. + * Abstract class for checks that verify the placement of a left curly + * brace. It provides the support for setting the maximum line length and the + * policy to verify. The default policy is EOL. It also provides the method to + * verify the placement. + * * @author Oliver Burn * @version 1.0 */ @@ -33,7 +37,7 @@ public abstract class AbstractLeftCurlyCheck private int mMaxLineLength = 80; /** - * Sets the left curly otion to eol. + * Creates a default instance and sets the policy to EOL. */ public AbstractLeftCurlyCheck() { diff --git a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/LeftCurlyOption.java b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/LeftCurlyOption.java index 8f1c72196..fb8805b76 100644 --- a/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/LeftCurlyOption.java +++ b/src/checkstyle/com/puppycrawl/tools/checkstyle/checks/LeftCurlyOption.java @@ -22,25 +22,60 @@ import java.util.HashMap; import java.util.Map; /** - * Represents the options for placing the left curly brace '{'. + * Represents the options for placing the left curly brace '{'. * * @author Oliver Burn - * @version $Id: LeftCurlyOption.java,v 1.4 2002-11-14 15:59:49 rickgiles Exp $ + * @version $Id: LeftCurlyOption.java,v 1.5 2002-11-26 06:25:10 oburn Exp $ */ public final class LeftCurlyOption extends AbstractOption { /** maps from a string representation to an option */ private static final Map STR_TO_OPT = new HashMap(); - - /** represents placing the brace at the end of line **/ - public static final LeftCurlyOption EOL = new LeftCurlyOption("eol"); + /** - * represents placing on the end of the line if it fits on the first line, - * otherwise placing on a new line. + * Represents the policy for placing the brace at the end of line. For + * example: + *
+     * if (condition) {
+     *     ...
+     * 
+ **/ + public static final LeftCurlyOption EOL = new LeftCurlyOption("eol"); + + /** + * Represents the policy that if the brace will fit on the first line of + * the statement, taking into account maximum line length, then apply + * EOL rule. Otherwise apply the NL + * rule. NLOW is a mnemonic for "new line on wrap". + * + *

For the example above Checkstyle will enforce: + * + *

+     * if (condition) {
+     *     ...
+     * 
+ * + * But for a statement spanning multiple lines, Checkstyle will enforce: + * + *
+     * if (condition1 && condition2 &&
+     *     condition3 && condition4)
+     * {
+     *     ...
+     * 
**/ public static final LeftCurlyOption NLOW = new LeftCurlyOption("nlow"); - /** represents placing on a new line **/ + + /** + * Represents the policy that the brace must always be on a new line. For + * example: + *
+     * if (condition)
+     * {
+     *     ...
+     * 
+ */ public static final LeftCurlyOption NL = new LeftCurlyOption("nl"); /** @@ -51,7 +86,7 @@ public final class LeftCurlyOption { super(aStrRep); } - + /** @see com.puppycrawl.tools.checkstyle.checks.AbstractOption */ protected Map getStrToOpt() {