Home  

|

  Company  

|

  Services  

|

  Downloads  

|

  Standards  

|

  Contact Us 

|

  Site Map 

 

Jacobe is a configurable code beautifier for the JavaTM programming language (edition 1.4). It is possible to let Jacobe print your Java code according to the widely used layout rules of Sun Microsystems or customize it to your own standards.

The documentation of Jacobe is only on-line available, hence it is advised to bookmark this page. If there is something you cannot find in the documentation, please let us know: support@tiobe.com.


Rules Overview

See section Rules for a detailed explanation of the available rules.

idrule namesunparskind
1indent 4HOR
2keywordspaceopenparen 1HOR
3spaceinfixopspace 1HOR
4spacesep 0HOR
5spaceassignspace 1HOR
6sepspace 1HOR
7spacedotspace 0HOR
8prefixopspace 0HOR
9spacepostfixop 0HOR
10openparenspacestatspacecloseparen 0HOR
11castspace 1HOR
12methodnamespace 0HOR
13horspaceslineterm  HOR
14lineterm  0VERT
15methodblanklines 1VERT
16linetermblockopenbrace 0VERT
17linetermclassopenbrace 0VERT
18linetermblockclosebrace 1VERT
19statlineterm 1VERT
20declblanklinesstat 1VERT
21blanklinescomment 1VERT
22decllineterm 1VERT
23sectionblanklines 2VERT
24classblanklines 2VERT
25openbraceclasslineterm 1VERT
26colonlineterm 1VERT
27blanklinescase 1VERT
28closebracelineterm 1VERT
29openparenspacegroupspacecloseparen 0HOR
30openparenspacemethodspacecloseparen 0HOR
31openparenspacecastspacecloseparen 0HOR
32linetermarrayinitopenbrace  0VERT
33indenttab  1HOR
34methodcallspaceopenparen 0HOR
35openbracelinetermclosebrace 0VERT
36openparenspacecloseparen 0HOR
37closebracelinetermelse 0VERT
38linetermclassclosebrace 1VERT
39linetermcatch 0VERT
40linetermarrayinitclosebrace  0VERT
41spaceopenbrace 1HOR
42linetermdotlineterm 0VERT
43openbracespaceclosebrace 0HOR
44linetermsep 0VERT
45openbraceblocklineterm 1VERT
46openbracearrayinitlineterm  0VERT
47semicolonlinetermelse  1VERT
48linetermextends 0VERT
49linetermimplements  0VERT
50linetermthrows  0VERT
51opencommentspace 1HOR
52linetermmethodopenbrace 0VERT
53linetermmethodclosebrace 1VERT
54openbracemethodlineterm 1VERT
55classspacename 1HOR
56typespacename  1HOR
57spaceelse 1HOR
58spacecatch 1HOR
59spaceextends 1HOR
60extendsspace 1HOR
61modifierslineterm 0VERT
62modifiersspace 1HOR
63indentcase 0HOR
86wrap 80VERT
87wrapinfixoplineterm  1VERT
88wraplineterminfixop 1VERT
90returntypelineterm 1HOR
92indentcontinuation 2HOR
93closebracelinetermdowhile 0VERT
99wrapcommalineterm 1VERT
100lineterminfixop 0VERT
101infixoplineterm 0VERT
103linetermopenbracket 0VERT
104prefixoplineterm 0VERT
105linetermpostfixop 0VERT
106indentbraces 0HOR
107openbracketspacedimspaceclosebracket  0HOR
108openbracketspaceindexspaceclosebracket  0HOR
109openbracketspaceclosebracket 0HOR
110arrayinitclosebracelineterm  0VERT
111openbracespacearrayinitspaceclosebrace  0HOR
112insertbraces  
113wraplinetermcomma  1VERT
114linetermcomma 0VERT
115commalineterm 0VERT
116openparenlineterm 0VERT
117linetermcloseparen 0VERT
118assoplineterm 0VERT


Contents

  Availability
  Synopsis
  Glossary of Terms
  Rules
    Overview
    Indentation
      Line Length
      Wrapping Lines
    Comments
    Declarations and Statements
      Declarations
      Simple Statements
      Compound Statements
      If Statements
      Do-While Statements
      Switch Statements
      Try-Catch Statements
    White Space
      Blank Lines
      Spaces


Availability

Jacobe accepts Java code conforming to the Java 2 (Edition 1.4) syntax. This is the Java version as defined by Sun Microsystems. Jacobe is available for the following operating systems: Windows 95/98/ME/NT/2K/XP as a command shell application and Linux kernel versions 2.1 and higher.


Synopsis

jacobe <option>... <input>...

Here, <input> could be a file name, a directory name (meaning: beautify recursively), a wildcard or the symbol "-" (meaning: read from standard input). For instance, the call jacobe <file>.java pretty prints the Java file <file>.java according to the default configuration, i.e., the configuration described by the provided configuration file sun.cfg. The result is written to the file <file>.java.jacobe. An example of a more complex call is jacobe src/*.java src/com/.

The possible values for <option> are listed in the table below. Note that spaces act as separators and should therefore not be used in options.

--<id>[=<int>]activate rule with name <id> (see section Rules for all available rules). For instance, jacobe --spacesep Foo.java. If a rule requires an argument, the operator = is used. For example, jacobe --indent=2 Foo.java. If a rule is not passed to Jacobe, it is deactivated.
-cfg=<cfg_file>read the options that should be applied from <cfg_file>. For instance, jacobe -cfg=mycfg.cfg Foo.java. The format of the configuration file is the same as specifying command line arguments to the Jacobe executable. In addition, it is allowed to use blank lines and single-line comments "//" in the configuration file. Specify at most one rule option per line. If no -- and -cfg options are specified, the default configuration file, sun.cfg, is applied. The default configuration file follows the Sun Java coding standards. This configuration file is distributed with Jacobe. The configuration file is first searched for relative to the current directory. If it has not been found the directory of the jacobe executable is inspected and finally the PATH environment variable is used.
-helpdisplay a brief overview of all rules.
-nobackupsuppress saving the original input file (only useful with -overwrite).
-overwriteoverwrite the original input file and write the original to <file>.java.jacobe.
-quietsuppress all warnings and informationals.
-stdoutwrite output to the standard output stream. In case input is read from standard input, this option is set by default.
-versiondisplay version information.



Glossary of Terms

In order to get an unambigious picture of the meaning of the rules defined in the next section, it is important to have a precize definition of the terms used. The table below gives an overview of these terms.

termdefinition
assignment operatorsee the definition of AssignmentOperator in the Java definition
blank linetwo consecutive line terminators
spaceASCII character 32
carriage returnASCII character 13
form feedASCII character 12
horizontal spacespace or tab
infix operatorsee the definition of Infixop in the Java definition
line feedASCII character 10
line terminatorcarriage return (Mac), line feed (Unix) or carriage return line feed (Windows)
prefix operatorsee the definition of PrefixOp in the Java definition
postfix operatorsee the definition of PostfixOp in the Java definition
tabASCII character 9



Rules

This section gives a detailed overview of all rules supported by the current version of Jacobe.

Overview

Rules are specified in the following way.

1indent 4HOR

In the first two columns the rule number and rule identification is given. The symbol is used to indicate that a rule is part of the default Sun configuration (either explicitly or implicitly). Rules that can be configured by the user are denoted with a sign. If the user does not specify an argument for such a rule the indicated default value will be used. The last column indicates whether it concerns a horizontal or vertical rule. Horizontal rules add or remove spaces and/or tabs, whereas vertical rules add or remove line terminators.

This particular example denotes rule 1 called "indent" which is a parametrized rule that is part of the Sun configuration. The default value of this horizontal rule is 4.

The rules of Jacobe are described in full detail in the following subsections. The subsections follow the sections of the coding conventions document of Sun Microsystems.


Indentation


1indent 4HOR

Description: Use a fixed number of spaces for indentation. An indentation starts at the beginning of a nested statement and ends at the end of the nested statement, provided that the nested statement starts at a new line.

For instance, --indent=4 transforms

public class Status {
// calculate failure status
  boolean failure() {
    return !status;
into
public class Status {
    // calculate failure status
    boolean failure() {
        return !status;

Switching on both indent (rule 1) and indenttab (rule 33) at the same time will result in undefined behaviour.



33indenttab 1HOR

Description: Use a fixed number of tabs for indentation. An indentation starts at the beginning of a nested statement and ends at the end of the nested statement, provided that the nested statement starts at a new line.

For instance, assuming that your tab is set to 4 spaces, --indenttab=1 transforms

public class Status {
// calculate failure status
  boolean failure() {
    return !status;
into
public class Status {
    // calculate failure status
    boolean failure() {
        return !status;

Switching on both indent (rule 1) and indenttab (rule 33) at the same time will result in undefined behaviour.


Line Length


86wrap 80VERT

Description: There is a fixed maximum number of characters per line. In case a line exceeds the maximum line length a line terminator is inserted at a line break point closest to the maximum column position. Line break points are defined by switching on specific line wrapping rules such as wraplineterminfixop (rule 88). After a line terminator has been inserted, the next line is indented the number of indentation levels specified by rule indentcontinuation (rule 92).

See specific line breaking rules (starting with wrap) for examples of line wrapping.

IMPORTANT NOTE. This is the first Jacobe version that supports line wrapping. Its current implementation is limited. Only wrapping of expressions in conditions and statements is supported. For instance, wrapping of parameter lists is not yet available.


Wrapping Lines


87wrapinfixoplineterm  1VERT

Description: Break a specific number of times after an operator in case a line exceeds the maximum line length. The maximum line length is specified by rule wrap (rule 86).

For instance, --wrapinfixoplineterm=1 --wrap=60 --indent --indentcontinuation transforms

int delta = height - fontMetrics.getAscent() - fontMetrics.getDescent();
into
int delta = height - fontMetrics.getAscent() -
        fontMetrics.getDescent(); 

This rule is especially powerful if used in combination with lineterminfixop (rule 100) and infixoplineterm (rule 101). For instance, --wrapinfixoplineterm=1 --wrap=60 --indent --indentcontinuation --lineterminfixop=0 --infixoplineterm=0 transforms

if (e.getKeyCode() == KeyEvent.VK_UP
        || e.getKeyCode() == KeyEvent.VK_DOWN) {
into
if (e.getKeyCode() == KeyEvent.VK_UP ||
        e.getKeyCode() == KeyEvent.VK_DOWN) {

Note that switching on simultaneously both this rule and wraplineterminfixop (rule 88) will result in undefined behaviour.



88wraplineterminfixop 1VERT

Description: Break a specific number of times before an operator in case a line exceeds the maximum line length. The maximum line length is specified by rule wrap (rule 86).

For instance, --wraplineterminfixop=1 --wrap=60 --indent --indentcontinuation transforms

int delta = height - fontMetrics.getAscent() - fontMetrics.getDescent();
into
int delta = height - fontMetrics.getAscent()
        - fontMetrics.getDescent(); 

This rule is especially powerful if used in combination with lineterminfixop (rule 100) and infixoplineterm (rule 101). For instance, --wraplineterminfixop=1 --wrap=60 --indent --indentcontinuation --lineterminfixop=0 --infixoplineterm=0 transforms

if (e.getKeyCode() == KeyEvent.VK_UP ||
        e.getKeyCode() == KeyEvent.VK_DOWN) {
into
if (e.getKeyCode() == KeyEvent.VK_UP
        || e.getKeyCode() == KeyEvent.VK_DOWN) {

Note that switching on simultaneously both this rule and wrapinfixoplineterm (rule 87) will result in undefined behaviour.



92indentcontinuation 2HOR

Description: Indent a specific number of indentation levels after a line of code has been wrapped.

For instance, --indentcontinuation=2 --indent=4 --wrap=60 --wraplineterminfixop=1 transforms

if ((currentIndex < length) && (rawdata.charAt(currentIndex) == '=')) {
into
if ((currentIndex < length)
        && (rawdata.charAt(currentIndex) == '=')) { 


99wrapcommalineterm 1VERT

Description: Break a specific number of times after a comma in the argument list of a method or constructor invocation in case a line exceeds the maximum line length. The maximum line length is specified by rule wrap (rule 86).

For instance, --wrapcommalineterm=1 --indent=4 --wrap=80 --indentcontinuation=2 transforms

vaporWare.sell("Product off the shelf", orderQuantity, customerCode, productCode, orderNumber);
into
vaporWare.sell("Product off the shelf", orderQuantity, customerCode,
        productCode, orderNumber);


113wraplinetermcomma  1VERT

Description: Break a specific number of times before a comma in the argument list of a method or constructor invocation in case a line exceeds the maximum line length. The maximum line length is specified by rule wrap (rule 86).

For instance, --wraplinetermcomma=1 --indent=4 --wrap=80 --indentcontinuation=2 transforms

vaporWare.sell("Product off the shelf", orderQuantity, customerCode, productCode, orderNumber);
into
vaporWare.sell("Product off the shelf", orderQuantity, customerCode
        , productCode, orderNumber);

Comments


51opencommentspace 1HOR

Description: There should be a specified number of spaces after an opening comment. This rule holds for all available kinds of Java comments. For instance, --opencommentspace=1 transforms

/*  this should be fixed very soon */
int x; //x coordinate in pixels
into
/* this should be fixed very soon */
int x; // x coordinate in pixels

Declarations and Statements


26colonlineterm 1VERT

Description: There should be a specified number of line terminators after a colon (':'). For instance, --colonlineterm=1 --indent transforms

switch ( x ) {
case 1: return x + 1;
into
switch ( x ) {
case 1:
    return x + 1;

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



41spaceopenbrace 1HOR

Description: There should be a specified number of spaces before an opening brace ('{'). For instance, --spaceopenbrace=1 transforms

class Status{
into
class Status {


28closebracelineterm 1VERT

Description: There should be a specified number of line terminators after a close brace ('}'). For instance, --closebracelineterm=1 --indent transforms

while (x > 0) {
  x--;
} y = x;
into
while (x > 0) {
  x--;
}
y = x;

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



43openbracespaceclosebrace 0HOR

Description: There should be a specified number of spaces between an empty pair of opening and close braces ('{' and '}'). For instance, --openbracespaceclosebrace=0 transforms

for (int i = 0; i < 10; i++) { }
into
for (int i = 0; i < 10; i++) {}


35openbracelinetermclosebrace 0VERT

Description: There should be a specified number of line terminators between an empty opening brace ('{') and closing brace ('}'). For instance, --openbracelinetermclosebrace=0 transforms

catch (Exception e) {
    }
into
catch (Exception e) { }

The best results are obtained if this rule is applied in combination with openbracespaceclosebrace (rule 43). The result of applying --openbracelinetermclosebrace=0 --openbracespaceclosebrace=0 to the previous example is

catch (Exception e) {}

Observe that this rule overrules the following rules that also deal with opening and closing braces: linetermblockclosebrace (rule 18), openbraceclasslineterm (rule 25), linetermclassclosebrace (rule 38), linetermarrayinitclosebrace (rule 40), openbraceblocklineterm (rule 45) and openbracearrayinitlineterm (rule 46).



36openparenspacecloseparen 0HOR

Description: There should be a specified number of spaces between an empty opening parenthesis ('(') and closing parenthesis (')'). For instance, --openparenspacecloseparen=0 transforms

x = getStatus( );
into
x = getStatus();

Observe that this rule overrules the following rules that also deal with opening and closing parentheses: openparenspacestatspacecloseparen (rule 10), openparenspacegroupspacecloseparen (rule 29), openparenspacemethodspacecloseparen (rule 30) and openparenspacecastspacecloseparen (rule 31).



103linetermopenbracket 0VERT

Description: There should be a specified number of line terminators before an opening bracket ('['). For instance, --linetermopenbracket=0 transforms

public LineMetrics getLineMetrics(char
        [] chars) {
into
public LineMetrics getLineMetrics(char [] chars) {


106indentbraces 0VERT

Description: There should be a specified number of additional indentation levels before an opening brace ('{'), and the additional indentation holds for the duration of the block. For instance, --indentbraces=1 transforms

public LineMetrics getLineMetrics(char[] chars)
{
    ...
}
into
public LineMetrics getLineMetrics(char[] chars)
    {
         ...
    }

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) and linetermblockopenbrace=1 (rule 16) at the same time.



107openbracketspacedimspaceclosebracket  0HOR

Description: There should be a specified number of spaces after an opening bracket ('[') and before a closing bracket (']') of an array dimension. For instance, --openbracketspacedimspaceclosebracket=1 transforms

String[] str = new String[10];
into
String[] str = new String[ 10 ];


108openbracketspaceindexspaceclosebracket  0HOR

Description: There should be a specified number of spaces after an opening bracket ('[') and before a closing bracket (']') of an array index. For instance, --openbracketspaceindexspaceclosebracket=1 transforms

return str[i];
into
return str[ i ];


109openbracketspaceclosebracket 0HOR

Description: There should be a specified number of spaces after an opening bracket ('[') and before a closing bracket (']') of an empty array dimension. For instance, --openbracketspaceclosebracket=1 transforms

String[] str2 = new String[] {"foo", "bar",};
into
String[ ] str2 = new String[ ] {"foo", "bar",};

Declarations

22decllineterm 1VERT

Description: Each declaration should be followed by a specified number of line terminators. For instance, --decllineterm=1 transforms

int x; int y;
into
int x;
int y;

Note that this rule does not take into account multiple declarators on the same line (e.g., int x, y;). The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



61modifierslineterm 0VERT

Description: There should be a specified number of line terminators after a list of modifiers ("public", "final", "synchronized", etc.). For instance, --modifierslineterm=0 transforms

public
class ImageFormatException {
into
public class ImageFormatException {

This rule only applies to line terminators at the end of a list of modifiers, not to individual modifiers. If the value of this rule is unequal to zero, the best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



62modifiersspace 1HOR

Description: There should be a specified number of spaces after a list of modifiers ("public", "final", "synchronized", etc.). For instance, --modifiersspace=1 transforms

private    Color control = UIManager.getColor("control");
into
private Color control = UIManager.getColor("control");

This rule only applies to line spaces at the end of a list of modifiers, not to individual modifiers.



56typespacename  1HOR

Description: There should be a specified number of spaces between a type and its name in a declaration. For instance, --typespacename=1 transforms

int   x;
void  method() {}
into
int x;
void method() {}


55classspacename 1HOR

Description: There should be a specified number of spaces between the "class" keyword of a class declaration and its name. For instance, --classspacename=1 transforms

class   Status {}
into
class Status {}


17linetermclassopenbrace 0VERT

Description: Use a specified number of line terminators before an open brace ('{') of a class or interface declaration. For instance, --linetermclassopenbrace=0 transforms

class Status
{
into
class Status {

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



25openbraceclasslineterm 1VERT

Description: There should be a specified number of line terminators after an open brace ('{') of a class or interface declarations. For instance,--openbraceclasslineterm=1 --indent transforms

public class Status { int val;
}
into
public class Status {
    int val;
}

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



38linetermclassclosebrace 1VERT

Description: There should be a specified number of line terminators before a close brace ('}') of a class or interface declaration. For instance, --linetermclassclosebrace=1 transforms

class Status {
    int x;
    int y; }
into
class Status {
    int x;
    int y;
}


59spaceextends 1HOR

Description: There should be a specified number of spaces before an "extends" keyword of a class or interface declaration. For instance, --spaceextends=1 transforms

public class JFrame   extends Frame {
into
public class JFrame extends Frame {


60extendsspace 1HOR

Description: There should be a specified number of spaces after an "extends" keyword of a class or interface declaration. For instance, --extendsspace=1 transforms

public class JFrame extends   Frame {
into
public class JFrame extends Frame {


48linetermextends 0VERT

Description: There should be a specified number of line terminators before an "extends" keyword of a class or interface declaration. For instance, --linetermextends=0 transforms

class SpecialStatus
extends Status {
    int z;
}
into
class SpecialStatus extends Status {
    int z;
}


49linetermimplements  0VERT

Description: There should be a specified number of line terminators before an "implements" keyword of a class declaration. For instance, --linetermimplements=1 --indent transforms

class Status implements Runnable {
}
into
class Status
    implements Runnable {
}


50linetermthrows  0VERT

Description: There should be a specified number of line terminators before a "throws" keyword of a constructor or method declaration. For instance, --linetermthrows=1 --indent transforms

public Remote lookup(String name) throws java.rmi.RemoteException;
into
public Remote lookup(String name)
    throws java.rmi.RemoteException;


52linetermmethodopenbrace 0VERT

Description: There should be a specified number of line terminators before an open brace of a constructor or method declaration. For instance, --linetermmethodopenbrace=0 --indent transforms

public int getStatus()
{
    return status;
}
into
public int getStatus() {
    return status;
}


54openbracemethodlineterm 1VERT

Description: There should be a specified number of line terminators after an open brace of a constructor or method declaration. For instance, --linetermmethodopenbrace=1 --indent transforms

public int getStatus() { return status; }
into
public int getStatus() {
    return status; }


53linetermmethodclosebrace 1VERT

Description: There should be a specified number of line terminators before an open brace of a constructor or method declaration. For instance, --linetermmethodclosebrace=1 --indent transforms

public int getStatus() { return status; }
into
public int getStatus() { return status;
}


32linetermarrayinitopenbrace  0VERT

Description: The are should be a specified number of line terminators before the opening brace ('{') of an array initialization. For instance, --linetermarrayinitopenbrace=0 transforms

int[] array =
    { 1, 2, 3 };
into
int[] array = { 1, 2, 3 };

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



46openbracearrayinitlineterm  0VERT

Description: There should be a specified number of line terminators after an open brace ('{') of an array initialization. For instance,--openbracearrayinitlineterm=0 --indent transforms

int[] array = {
    1, 2, 3 };
into
int[] array = { 1, 2, 3 };

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



40linetermarrayinitclosebrace  0VERT

Description: There should be a specified number of line terminators before the closing brace ('}') of an array initialization. For instance, --linetermarrayinitclosebrace=0 transforms

int[] array = { 1, 2, 3
    };
into
int[] array = { 1, 2, 3 };

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



110arrayinitclosebracelineterm  0VERT

Description: There should be a specified number of line terminators after the closing brace ('}') of an array initialization. For instance, --arrayinitclosebracelineterm=0 transforms

processArray(new Object[] {obj1, obj2, obj3}
    );
into
processArray(new Object[] {obj1, obj2, obj3});


111openbracespacearrayinitspaceclosebrace  0HOR

Description: There should be a specified number of spaces after the opening brace ('{') and before the closing brace ('}') of an array initialization. For instance, --openbracespacearrayinitspaceclosebrace=0 transforms

int[] array = { 1, 2, 3 };
into
int[] array = {1, 2, 3};


90returntypelineterm 0VERT

Description: There should be a specified number of line terminators after the return type of a method declaration. For instance, --returntypelineterm=0 transforms

public int
        getStatus()
into
public int getStatus()

Simple Statements

19statlineterm 1VERT

Description: Each statement should end with a specified number of line terminators. For instance, --statlineterm=1 --indent transforms

x = z; y = z;
into
x = z;
y = z;

The statements of a for loop are not affected by this rule. The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.


34methodcallspaceopenparen 0HOR

Description: There should be a specified number of spaces between a method name and its following opening parenthesis in a method call. For instance, --methodcallspaceopenparen=0 transforms

x = length (y);
into
x = length(y);


42linetermdotlineterm 0VERT

Description: There should be a specified number of line terminators at either side of a dot symbol ('.'). For instance, --linetermdotlineterm=0 transforms

x.value = y
    .value;
into
x.value = y .value;

The best results are obtained if this rule is applied in combination with spacedotspace (rule 7). The result of applying --linetermdotlineterm=0 --spacedotspace=0 to the previous example is

x.value = y.value;


44linetermsep 0VERT

Description: There should be a specified number of line terminators before a comma (',') or semicolon (';'). For instance, --linetermsep=0 transforms

status = 0
    ;
into
status = 0 ;

The best results are obtained if this rule is applied in combination with spacesep (rule 4). The result of applying --linetermsep=0 --spacesep=0 to the previous example is

status = 0;


100lineterminfixop 0VERT

Description: There should be a specified number of line terminators before an infix operator. For instance, --lineterminfixop=0 transforms

return square.length
    * square.width;
into
return square.length * square.width;


101infixoplineterm 0VERT

Description: There should be a specified number of line terminators after an infix operator. For instance, --infixoplineterm=0 transforms

return square.length *
    square.width;
into
return square.length * square.width;


104prefixoplineterm 0VERT

Description: There should be a specified number of line terminators after a prefix operator. For instance, --prefixoplineterm=0 transforms

if (!
    (obj instanceof FilePermission)) {
into
if (! (obj instanceof FilePermission)) {


105linetermpostfixop 0VERT

Description: There should be a specified number of line terminators before a postfix operator. For instance, --linetermpostfixop=0 transforms

for ( i = 0 ; i < currentSelection ; i
    ++ ) {
into
for ( i = 0 ; i < currentSelection ; i ++ ) {


114linetermcomma 0VERT

Description: There should be a specified number of line terminators before a comma in the argument list of a method or constructor invocation. For instance, --linetermcomma=0 transforms

vaporWare.sell("Product off the shelf", orderQuantity, customerCode
        , productCode, orderNumber);
into
vaporWare.sell("Product off the shelf", orderQuantity, customerCode, productCode, orderNumber);


115commalineterm 0VERT

Description: There should be a specified number of line terminators after a comma in the argument list of a method or constructor invocation. For instance, --commalineterm=0 transforms

vaporWare.sell("Product off the shelf", orderQuantity, customerCode,
        productCode, orderNumber);
into
vaporWare.sell("Product off the shelf", orderQuantity, customerCode, productCode, orderNumber);


116openparenlineterm 0VERT

Description: There should be a specified number of line terminators after the opening parenthesis of a method or constructor invocation. For instance, --openparenlineterm=0 transforms

vaporWare.sell(
        "Product off the shelf", orderQuantity, customerCode, productCode, orderNumber);
into
vaporWare.sell("Product off the shelf", orderQuantity, customerCode, productCode, orderNumber);


117linetermcloseparen 0VERT

Description: There should be a specified number of line terminators before the closing parenthesis of a method or constructor invocation. For instance, --linetermcloseparen=0 transforms

vaporWare.sell("Product off the shelf", orderQuantity, customerCode, productCode, orderNumber
        );
into
vaporWare.sell("Product off the shelf", orderQuantity, customerCode, productCode, orderNumber);


118assoplineterm 0VERT

Description: There should be a specified number of line terminators after the assignment operator in an assignment statement. For instance, --assoplineterm=0 transforms

delta =
        height - fontMetrics.getAscent() - fontMetrics.getDescent();
into
delta = height - fontMetrics.getAscent() - fontMetrics.getDescent();

Compound Statements

16linetermblockopenbrace 0VERT

Description: Use a specified number of line terminators before an open brace ('{') of a block statement. For instance, --linetermblockopenbrace=0 transforms

if (x == y)
{
into
if ( x == y ) {

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



45openbraceblocklineterm 1VERT

Description: There should be a specified number of line terminators after an open brace ('{') of a block statement. For instance,--openbraceblocklineterm=1 --indent transforms

while (x > 0) { x--;
}
into
while (x > 0) {
    x--;
}

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



18linetermblockclosebrace 1VERT

Description: There should be a specified number of line terminators before a close brace ('}') of a block statement. For instance, --linetermblockclosebrace=1 transforms

while (x > 0) {
    x--; }
into
while (x > 0) {
    x--;
}

The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



112insertbraces  

Description: A control statement such as if, for, while should be followed by a block statement (a statement surrounded by braces ({ ... })). For instance, --insertbraces transforms

while (x > 0)
    x--;
into
while (x > 0) {
    x--;
}

The best results are obtained by applying some of the following rules at the same time.


If Statements

57spaceelse 1HOR

Description: There should be a specified number of spaces before an else keyword. For instance, --spaceelse=1 transforms

if (x > 0) {
}else {
}
into
if (x > 0) {
} else {
}


37closebracelinetermelse 0VERT

Description: There should be a specified number of line terminators before an else keyword that is preceded by a block statement. For instance, --closebracelinetermelse=0 transforms

if (x > 0) {
}
else {
}
into
if (x > 0) {
} else {
}

Observe that this rule overrules rule closebracelineterm (rule 28).



47semicolonlinetermelse  1VERT

Description: There should be a specified number of line terminators before an else keyword that is not preceded by a block statement. For instance, --semicolonlinetermelse=1 transforms

if (x > 0) x = 0; else x = 1;
into
if (x > 0) x = 0;
else x = 1;

Do-While Statements

93closebracelinetermdowhile 0VERT

Description: There should be a fixed number of line terminators after the closing brace of a do while loop. For instance, --closebracelinetermdowhile=0 transforms

do {
    x++;
}
while (x < 10);
into
do {
    x++;
} while (x < 10);

Switch Statements

27blanklinescase 1VERT

Description: There should be a fixed number of blank lines before a case block in a switch statement (except for the first one). For instance, --blanklinescase=1 --indent transforms

switch ( x ) {
case 1:
    return x + 1;
case 2:
    return 5;
}
into
switch ( x ) {
case 1:
    return x + 1;

case 2:
    return 5;
}

No blank lines will be introduced before empty cases. Observe that this rule might interact with rule blanklinescomment (rule 21) in case comments are involved.The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



63indentcase 0HOR

Description: a case block is indented a fixed number of indentation levels. For instance, --indentcase=0 --indent transforms

switch ( x ) {
case 1:
    return x + 1;

case 2:
    return 5;
into
switch ( x ) {
    case 1:
        return x + 1;

    case 2:
        return 5;

Observe that this rule overrules indent (rule 1) and indenttab (rule 33).


Try-Catch Statements

58spacecatch 1HOR

Description: There should be a specified number of spaces before a catch or finally keyword. For instance, --spacecatch=1 transforms

try {
    input = readStream(reader);
}   catch (ReadException e) {
}
into
try {
    input = readStream(reader);
} catch (ReadException e) {
}


39linetermcatch 0VERT

Description: There should be a specified number of line terminators before a catch or finally keyword. For instance, --linetermcatch=0 transforms

try {
    input = readStream(reader);
}
catch (ReadException e) {
}
into
try {
    input = readStream(reader);
} catch (ReadException e) {
}

Observe that this rule overrules rule closebracelineterm (rule 28).


White Space


14lineterm  0HOR

Description: Use a specific line terminator. This rule is parameterizable by the user: mode 1, replace each line terminator by carriage return (Macintosh style); mode 2, replace each line terminator by line feed (Unix style); mode 3, replace each line terminator by carriage return line feed (Windows style). The default mode, mode 0 is the mode for the platform you are using.


Blank Lines

15methodblanklines 1VERT

Description: There should be a fixed number of blank lines after a method declaration in a class (except for the last one). For instance, --methodblanklines=1 transforms

public void setValue(int i) {
    val = i;
}



public int getValue() {
{
    return val;
}
into
public void setValue(int i) {
    val = i;
}

public int getValue() {
    return val;
}

Observe that this rule might interact with rule blanklinescomment (rule 21) in case comments are involved.



20declblanklinesstat 1VERT

Description: There should be a fixed number of blank lines between declarations and statements. For instance, --declblanklinesstat=1 --indent transforms

public int factor(int i) {
    int j = length(i);
    return (j + 1) * (j - 1);
}
into
public int factor(int i) {
    int j = length(i);

    return (j + 1) * (j - 1);
}

Observe that this rule might interact with rule blanklinescomment (rule 21) in case comments are involved. The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



21blanklinescomment 1VERT

Description: There should be a fixed number of blank lines before block comments (between '/*' and '*/') that start at the beginning of a line. For instance --blanklinescomment=1 --indent transforms

public int factor(int i) {
    /* introduce var j for sharing */
    int j = length(i);
into
public int factor(int i) {

    /* introduce var j for sharing */
    int j = length(i);

Observe that this rule might conflict with rules methodblanklines (rule 15), sectionblanklines (rule 23), classblanklines (rule 24) and blanklinescase (rule 27). The best results are obtained by applying rule indent (rule 1) or indenttab (rule 33) at the same time.



23sectionblanklines 2VERT

Description: There should be a fixed number of blank lines after package and import sections. For instance, --sectionblanklines=2 transforms

import java.util.Vector;

public class Status {
into
import java.util.Vector;


public class Status {

Observe that this rule might interact with rule blanklinescomment (rule 21) in case comments are involved.



24classblanklines 2VERT

Description: There should be a fixed number of blank lines after a class declaration (excluding the last one). For instance, --classblanklines=2 transforms

public class Status {
}

class SpecialStatus extends Status {
}
into
public class Status {
}


class SpecialStatus extends Status {
}

This rule also holds for inner classes. Observe that this rule might interact with rule blanklinescomment (rule 21) in case comments are involved.


Spaces

2keywordspaceopenparen 1HOR

Description: There should be a specified number of spaces between a Java keyword and a subsequent opening parenthesis '('. For instance, --keywordspaceopenparen=1 transforms

while(x > 0)
into
while (x > 0)


12methodnamespace 0HOR

Description: There should be a specified number of spaces between a method name and its formal parameter list in a method definition. For instance, --methodnamespace=0 transforms

public int length (int x, int y)
into
public int length(int x, int y)


4spacesep 0HOR

Description: There should be a specified number of spaces before a comma (',') or semicolon (';'). For instance, --spacesep=0 transforms

x = y ;
into
x = y;


6sepspace 1HOR

Description: There should be a specified number of spaces after a comma (',') or semicolon(';'). For instance, --sepspace=1 transforms

public int length(int x,int y)
into
public int length(int x, int y)


5spaceassignspace 1HOR

Description: There should be a specified number of spaces at each side of a Java assignment operator. For instance, --spaceassignspace=1 transforms

x=y;
into
x = y;


7spacedotspace 0HOR

Description: There should be a specified number of spaces at either side of the dot operator ('.'). For instance, --spacedotspace=0 transforms

x . val = y . val;
into
x.val = y.val;


8prefixopspace 0HOR

Description: There should be a specified number of spaces after a Java prefix operator. For instance, --prefixopspace=0 transforms

x = - y;
into
x = -y;


3spaceinfixopspace 1HOR

Description: There should be a specified number of spaces at each side of a Java infix operator. For instance, --spaceinfixopspace=1 transforms

x = y+z;
into
x = y + z;


9spacepostfixop 0HOR

Description: There should be a specified number of spaces before a Java postfix operator. For instance, --spacepostfixop=0 transforms

x = y ++;
into
x = y++;


11castspace 1HOR

Description: There should be a specified number of spaces after a cast. For instance, --castspace=1 transforms

x = (int)y;
into
x = (int) y;


31openparenspacecastspacecloseparen 0HOR

Description: There should be a specified number of spaces after an opening parenthesis ('(') and before a closing parenthesis (')') of a cast expression. For instance, --openparenspacecastspacecloseparen=0 transforms

x = ( int ) y;
into
x = (int) y;


10openparenspacestatspacecloseparen 0HOR

Description: There should be a specified number of spaces after an opening parenthesis ('(') and before a closing parenthesis (')') that occur in a statement context such as in conditions of an if or while statement. For instance, --openparenspacestatspacecloseparen=0 transforms

if ( x == y )
into
if (x == y)


29openparenspacegroupspacecloseparen 0HOR

Description: There should be a specified number of spaces after an opening parenthesis ('(') and before a closing parenthesis (')') of a grouped expression. For instance, --openparenspacegroupspacecloseparen=0 transforms

x = ( y + z ) * ( x - z );
into
x = (y + z) * (x - z);


30openparenspacemethodspacecloseparen 0HOR

Description: There should be a specified number of spaces after an opening parenthesis ('(') and before a closing parenthesis (')') of a constuctor/method declarator/call. For instance, --openparenspacemethodspacecloseparen=0 transforms

public int length( int x, int y )
into
public int length(int x, int y)


13horspaceslineterm  HOR

Description: There shouldn't be horizontal spaces immediately in front of a line terminator. Note that horizontal spaces at the end of "end of line" comments are considered to be part of the comments. Hence, these will not be removed by this rule.

Send mail to support@tiobe.com with questions or comments about this web site. Legal disclaimer: Sun, Sun Microsystems, the Sun Logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Sun Microsystems, Inc. in no way endorses or is affiliated with TIOBE Software.

Copyright © 2002 TIOBE Software BV