This section describes the available options to control the handling of headers. A header is a uniform comment that appears at the very top of a source file and usually displays the company’s copyright notice.
Example 2.883. Typical header before package statement
/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2000 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.editor; ...
Lets you control the different header options.
Enables or disables the header feature. When enabled and no header could be detected, the specified header template will be inserted. To avoid header duplication, you have to tell Jalopy how to detect existing headers. See Section 126.96.36.199.1, “Detection” below.
If you enable this option, the header template will be re-inserted with every run. Any existing header(s) will be removed. Note that when you specify multiple keys to identify existing headers, all recognized headers will be removed! This option is only available, when you’ve enabled the header feature.
When enabled, Jalopy keeps expanded RCS-style tags in existing header comments.
An expanded RCS tag looks like
$keyword: data $.
It is good advise to replace headers upon every formatting run in order to
enforce the company’s copyright statement under all circumstances. This might
cause problems though when the header contains RCS-style tags. Because the
current keyword data is lost upon formatting, the SCM thinks the files are
different even if the file did not change otherwise. So, after submitting the
files show no differences (because the tags have been expanded again by the
For example, if you have a file with the CVS
tag, after checkout the header might look like this
Example 2.884. Header with expanded keyword
/* Copyright (c) 2001-2003, Foobar Systems Ltd. * * $Id: TestCheckin.java,v 1.2 2004/01/12 21:52:18 xf016997 Exp $ */
But after formatting, the keyword data gets lost when the Keep tags option was disabled
Enabling this option will allow you to keep the existing data and the file will look exactly like in Example 2.884, “Header with expanded keyword” after formatting. Please note that this feature works for nested tags, too. If you define RCS tags in your template that contain variable expressions, their values are still kept.
Example 2.886. Header template with nested tags
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Fossi GmbH Source File: $file.name$ // Copyright (c) 2003-$date.year$ by Fossi GmbH // // $Created: $date$ ($time.long$) by $user.name$ $ // Last Change: $date$ ($time.long$) by $user.name$ //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
After the first formatting run, the header could look like this
Example 2.887. Header template after formatting
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Fossi GmbH Source File: Installer.java // Copyright (c) 2003-2004 by Fossi GmbH // // $Created: 11.05.2004 (09:52:12) by eso $ // Last Change: 11.05.2004 (09:52:12) by eso //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
After the next formatting run, it might look like this
Example 2.888. Header template after further formatting
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // Fossi GmbH Source File: Installer.java // Copyright (c) 2003-2004 by Fossi GmbH // // $Created: 11.05.2004 (09:52:12) by eso $ // Last Change: 28.05.2004 (13:04:39) by harold //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
This option is only available when the header feature has been enabled.
To avoid header duplication, Jalopy needs to detect existing headers. Two methods are provided to allow great flexibility.
Lets you specify the number of single-line comments at the top of a file
(before the first language keyword, being either
enum) that should be recognized as a header.
Jalopy simply counts the number of single-line comments at the top of a source file and if this number is greater or equal to the specified line count, all consecutive single-line comments at the top will be assumed to be part of a header.
Example 2.889. Single-line comment header
//=============================================================== // file : Byte.java // project: bsjt-rt // // last change: date: $Date$ // by: $Author$ // revision: $Revision$ //--------------------------------------------------------------- // copyright: BSJT Software License (see class documentation) //=============================================================== package com.bsjt.foo; import ...
In order to recognize the above single-line comments as a header, the line count must be no less than '1', but it would be best to set it to '10'. A number equal to '0' disables the Count Lines detection.
The second approach is to specify one or several unique keys that are part of your header. This technique only works with headers that are defined as multi-line comments. To add, remove or change identify keys, use the corresponding button beneath the keys list.
Specifying several keys makes it easy to switch between headers. Define both a key for the old header that is to be removed and for your new header that should be inserted. This way, you are sure that even new additions that happen to contain the old header (maybe checked out from some SCM) are treated correctly. A good key for the header in Example 2.883, “Typical header before package statement” above would be “Sun Public License Notice”.
Lets you add new identify keys. Pressing the button will invoke a new dialog where you can enter the identify key.
Enter the identify key in the text field and press the Add button to submit your addition. Press the Cancel button if you want to dismiss the action. Please note that the Add button is only enabled if the text field is not empty.
Lets you alter an already defined identify key. Pressing the button will invoke a new dialog where you can change the currently selected identify key. The button is only available if an item is currently selected in the keys list.
Change the identify key and press the Change button to submit your change. Press the Cancel button if you want to dismiss the action. Please note that the Change button is only enabled if the text field is not empty.
Lets you remove the currently selected key(s) from the list. The Remove button is only available if an item is currently selected in the keys list.
Lets you specify the header template. Enter the desired text into the text area. You should use either one multi-line comment or several single-line comments. Any leading or trailing white space will be removed upon saving. Note that if you leave the template text empty, no header template will be inserted during printing, but existing headers may still be removed!
Since Jalopy 1.7, it’s also possible to maintain multiple header comments in source files. Please note that if you prefer to separate the different comments with blank lines and don’t want to enable the override feature, you need to tell Jalopy to keep blank lines between header comments with the Section 188.8.131.52, “Keep blank lines in headers up to” option. You can use variable expressions throughout the template text. See Section 2.4.4, “Usage” for more information about this feature.