Jindent - Java Source Code Formatter http://www.jindent.com
 



title
5.6.2.13 Header/Footer

Jindent is able to insert headers and footers defined by user templates. Additionally Jindent offers several options to recognize existing headers and footers which were inserted by hand or by previous Jindent sessions.



title
5.6.2.13.1 Header

Header detection smart mode

Header detection smart mode

Helps Jindent to recognize comments at the top of source codes as already existing headers.

Jindent counts all contiguous comment lines at the top of the original source code. If the counter is equal or greater as the value of setting "Header detection smart mode" then Jindent defines the analysed comment as a detected header.


Example of detected header. We assume setting "Header detection smart mode" is set to 10:

/*                                                                         #line  1  * MyClass.cpp     1.82 99/03/18                                           line  2  *                                                                         line  3  * Copyright (c) 1994-1999 Sun Microsystems, Inc.                          line  4  * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.              line  5  * All rights reserved.                                                    line  6  *                                                                         line  7  * This software is the confidential and proprietary information of Sun    line  8  * Microsystems, Inc. ("Confidential Information").  You shall not         line  9  * disclose such Confidential Information and shall use it only in         line 10  * accordance with the terms of the license agreement you entered into     line 11  * with Sun.                                                               line 12  */                                                                        line 13 class MyClass { ... }

The found comment at top of this source code example contains 13 lines. Our smart mode detection is set to 10. This means a comment at the top which contains less than 10 lines would not be detected as an previous inserted header.
Therefore Jindent recognizes the comment in this example as an existing header.

Set value of setting "Header detection smart mode" to infinite turns this smart mode feature off.

Set value of setting "Header detection smart mode" to 0 detects every comment at the top of source codes as an existing header.


Of course Jindent provides another setting which provides several actions how to proceed with existing headers. For details please refer to setting: "Header insertion mode"


See also... See also: Header insertion mode , Detect headers containing keys , Detect headers NOT containing keys




Detect headers containing keys

Detect headers containing keys

Helps Jindent to regonize comments at the top of source codes as already existing headers.

Jindent scans all contiguous comment lines at the top of the original source code for specific keywords. If Jindent finds one of these keywords then the analysed comment will be defined as an existing header.


Example of detected existing header. We assume setting "Detect headers containing keys" is set to 'Mircosoft, Copyright'. (It is possible to name several keywords for this setting. Use commas to separate the defined keywords.):

/*                                      
 * MyClass.cpp     1.82 99/03/18        
 *                                      
 * Copyright (c) 1994-1999 Sun Microsystems, Inc.

 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.

 * All rights reserved.                 
 *                                      
 * This software is the confidential and proprietary information of Sun

 * Microsystems, Inc. ("Confidential Information").  You shall not

 * disclose such Confidential Information and shall use it only in

 * accordance with the terms of the license agreement you entered into

 * with Sun.                            
 */                                     
                                        
                                        
class MyClass {                         
    ...                                 
}                                       

The found comment at top of this source code example contains the keywords 'Copyright', but not the keyword 'Microsoft'. One found keyword is enough to detect the analysed comment as an existing header.
The keyword scan is case sensitive and need not necessarily 'match a whole word'.

Please note: It is always a good trick to use copyright statements ('Copyright', '(c)', 'rights reserved', etc.) and company names ('Mircosoft', 'Microsystems', 'Inc.') as keywords to detect headers.

Enter an empty value for setting "Detect headers containing keys" to turn this detection feature off.

Please note: To proceed a proper detection of headers both settings: "Detect headers containing keys" and "Detect headers NOT containing keys" have to terminate in a successful include/exclude search.


Of course Jindent provides another setting which provides several actions how to proceed with detected headers. For details please refer to setting: "Header insertion mode"


See also... See also: Header insertion mode , Detect headers NOT containing keys , Header detection smart mode




Detect headers NOT containing keys

Detect headers NOT containing keys

Helps Jindent to regonize comments at the top of source codes as already existing headers.

This setting works similar to "Detect headers containing keys"
Jindent scans all contiguous comment lines at the top of the original source code for specific keywords. If all keywords are not contained in the analysed comment then it will be defined as an detected header.


Example of detected header. We assume setting "Detect headers NOT containing keys" is set to 'Microsoft'. (It is possible to name several keywords for this setting. Use commas to separate the defined keywords.):

/*                                      
 * MyClass.cpp     1.82 99/03/18        
 *                                      
 * Copyright (c) 1994-1999 Sun Microsystems, Inc.

 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.

 * All rights reserved.                 
 *                                      
 * This software is the confidential and proprietary information of Sun

 * Microsystems, Inc. ("Confidential Information").  You shall not

 * disclose such Confidential Information and shall use it only in

 * accordance with the terms of the license agreement you entered into

 * with Sun.                            
 */                                     
                                        
                                        
class MyClass {                         
    ...                                 
}                                       

The found comment at top of this source code example does not contain the keywords 'Microsoft'. Therfore the analysed comment is detected as an existing header.
The keyword scan is case sensitive and need not necessarily 'match a whole word'.

Please note: It is always a good trick to use your own company name ('Microsoft', 'Microsystems', etc.) as an exlcude keyword to detect headers. Therefore Jindent will only detect headers which are NOT from your company.

Enter an empty value of setting "Detect headers containing keys" to turn this detection feature off.

Please note: To proceed a proper detection of headers both settings: "Detect headers containing keys" and "Detect headers NOT containing keys" have to terminate in a successful include/exclude search.


Of course Jindent provides another setting which provides several actions how to proceed with detected headers. For details please refer to setting: "Header insertion mode"

See also... See also: Header insertion mode , Detect headers containing keys , Header detection smart mode




Format detected headers

Format detected headers

Enables formatting of detected headers.

Disable this setting to preserve header formatting style from original source codes.



An example of original input source code:

/************************************************************************
 * MyClass.cpp     1.82 99/03/18                                        *

 *                                                                      *

 * Copyright (c) 1994-1999 Sun Microsystems, Inc.                       *

 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.           *

 * All rights reserved.                                                 *

 *                                                                      *

 * This software is the confidential and proprietary information of Sun *

 * Microsystems, Inc. ("Confidential Information").  You shall not      *

 * disclose such Confidential Information and shall use it only in      *

 * accordance with the terms of the license agreement you entered into  *

 * with Sun.                                                            *

 ************************************************************************/

package mypackage;                      
                                        
                                        
class MyClass {                         
    ...                                 
}                                       


After formatting the same example looks like:

/*                                      
 * MyClass.cpp     1.82 99/03/18        
 *                                      
 * Copyright (c) 1994-1999 Sun Microsystems, Inc.

 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.

 * All rights reserved.                 
 *                                      
 * This software is the confidential and proprietary information of Sun

 * Microsystems, Inc. ("Confidential Information").  You shall not

 * disclose such Confidential Information and shall use it only in

 * accordance with the terms of the license agreement you entered into

 * with Sun.                            
 */                                     
                                        
                                        
class MyClass {                         
    ...                                 
}                                       



Blank lines before header

Blank lines before header

Inserts a blank line before detected and new inserted headers.



Set "Blank lines before header" to 2 and "Blank lines after header" to 1 and an example output could look like:

                                       
                                       
/*                                      
 * MyClass.cpp     1.82 99/03/18        
 *                                      
 * Copyright (c) 1994-1999 Sun Microsystems, Inc.

 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.

 * All rights reserved.                 
 *                                      
 * This software is the confidential and proprietary information of Sun

 * Microsystems, Inc. ("Confidential Information").  You shall not

 * disclose such Confidential Information and shall use it only in

 * accordance with the terms of the license agreement you entered into

 * with Sun.                            
 */                                     
                                       
class MyClass {                         
    ...                                 
}                                       


Set "Blank lines before header" to 1 and "Blank lines after header" to 2 and an the same example looks like:

                                        
/*                                      
 * MyClass.cpp     1.82 99/03/18        
 *                                      
 * Copyright (c) 1994-1999 Sun Microsystems, Inc.

 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.

 * All rights reserved.                 
 *                                      
 * This software is the confidential and proprietary information of Sun

 * Microsystems, Inc. ("Confidential Information").  You shall not

 * disclose such Confidential Information and shall use it only in

 * accordance with the terms of the license agreement you entered into

 * with Sun.                            
 */                                     
                                        
                                        
class MyClass {                         
    ...                                 
}                                       



Blank lines after header

Blank lines after header

Inserts a blank line before detected and new inserted headers.

Please refer to setting "Blank lines before header" for a detailed example.



Header text template

Header text template

Header template for insertion at the top of source files.


Example template:

/*                                      
 * $fileName$    $version$ $date$       
 *                                      
 * Copyright (c) 
1994-2005 Sun Microsystems, Inc.
 * 
901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
 * All rights reserved.                 
 *                                      
 * This software is the confidential and proprietary information of Sun

 * Microsystems, Inc. ("Confidential Information").  You shall not

 * disclose such Confidential Information and shall use it only in

 * accordance with the terms of the license agreement you entered into

 * with Sun.                            
 */                                     


And the generated header insertion could look like:

/*                                      
 * TestClass.cpp    1.8 2005-01-10      
 *                                      
 * Copyright (c) 1994-2005 Sun Microsystems, Inc.

 * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.

 * All rights reserved.                 
 *                                      
 * This software is the confidential and proprietary information of Sun

 * Microsystems, Inc. ("Confidential Information").  You shall not

 * disclose such Confidential Information and shall use it only in

 * accordance with the terms of the license agreement you entered into

 * with Sun.                            
 */                                     
class TestClass {                       
    ...                                 
}                                       

In this example version is a user defined environment variable.
Variable date represents the current date and fileName the filename of the corresponding file.
For more details about environment variables please refer to topic 'Environment Variables' and to section 'templates' in topic 'JavaDocs'.

See also... See also: Jindent - Settings - Environment - Environment Variables - Special Variables




Header insertion mode

Header insertion mode

Defines how to insert header templates and how to proceed with detected headers from further insertions.

This setting provides three different modes for header template insertion: