Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.puppycrawl.tools.checkstyle.checks.blocks
Class LeftCurlyCheck  view LeftCurlyCheck download LeftCurlyCheck.java

java.lang.Object
  extended bycom.puppycrawl.tools.checkstyle.api.AutomaticBean
      extended bycom.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
          extended bycom.puppycrawl.tools.checkstyle.api.Check
              extended bycom.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck
                  extended bycom.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck
All Implemented Interfaces:
com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

public class LeftCurlyCheck
extends com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck

Checks the placement of left curly braces on types, methods and other the other blocks: LITERAL_CATCH 55 , LITERAL_DO 55 , LITERAL_ELSE 55 , LITERAL_FINALLY 55 , LITERAL_FOR 55 , LITERAL_IF 55 , LITERAL_SWITCH 55 , LITERAL_SYNCHRONIZED 55 , LITERAL_TRY 55 , LITERAL_WHILE 55 .

The policy to verify is specified using the LeftCurlyOption class and defaults to LeftCurlyOption.EOL 55 . Policies LeftCurlyOption.EOL 55 and LeftCurlyOption.NLOW 55 take into account property maxLineLength. The default value for maxLineLength is 80.

An example of how to configure the check is:

 <module name="LeftCurly"/>
 

An example of how to configure the check with policy LeftCurlyOption.NLOW 55 and maxLineLength 120 is:

 <module name="LeftCurly">
      <property name="option"
 value="nlow"/>     <property name="maxLineLength" value="120"/> <
 /module>
 

Version:
1.0

Field Summary
private static int DEFAULT_MAX_LINE_LENGTH
          default maximum line length
private  int mMaxLineLength
          TODO: replace this ugly hack
 
Fields inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.Check
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
 
Fields inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
 
Constructor Summary
LeftCurlyCheck()
          Creates a default instance and sets the policy to EOL.
 
Method Summary
 int[] getDefaultTokens()
          Returns the default token a check is interested in.
 void setMaxLineLength(int aMaxLineLength)
          Sets the maximum line length used in calculating the placement of the left curly brace.
private  void verifyBrace(com.puppycrawl.tools.checkstyle.api.DetailAST aBrace, com.puppycrawl.tools.checkstyle.api.DetailAST aStartToken)
          Verifies that a specified left curly brace is placed correctly according to policy.
 void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
          Called to process a token.
 
Methods inherited from class com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck
getAbstractOption, setOption
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.Check
beginTree, destroy, finishTree, getAcceptableTokens, getClassLoader, getFileContents, getLines, getRequiredTokens, getTabWidth, getTokenNames, init, leaveToken, log, log, setClassLoader, setFileContents, setMessages, setTabWidth, setTokens
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter
getMessageBundle, getSeverity, getSeverityLevel, log, log, log, log, log, log, setSeverity
 
Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean
configure, contextualize, finishLocalSetup, getConfiguration, setupChild
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_LINE_LENGTH

private static final int DEFAULT_MAX_LINE_LENGTH
default maximum line length

See Also:
Constant Field Values

mMaxLineLength

private int mMaxLineLength
TODO: replace this ugly hack

Constructor Detail

LeftCurlyCheck

public LeftCurlyCheck()
Creates a default instance and sets the policy to EOL.

Method Detail

setMaxLineLength

public void setMaxLineLength(int aMaxLineLength)
Sets the maximum line length used in calculating the placement of the left curly brace.


getDefaultTokens

public int[] getDefaultTokens()
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
Returns the default token a check is interested in. Only used if the configuration for a check does not define the tokens.


visitToken

public void visitToken(com.puppycrawl.tools.checkstyle.api.DetailAST aAST)
Description copied from class: com.puppycrawl.tools.checkstyle.api.Check
Called to process a token.


verifyBrace

private void verifyBrace(com.puppycrawl.tools.checkstyle.api.DetailAST aBrace,
                         com.puppycrawl.tools.checkstyle.api.DetailAST aStartToken)
Verifies that a specified left curly brace is placed correctly according to policy.