OverviewDownloadDocumentationPlug-insLinksContact
Features | History | Manual | FAQ | Javadoc
This page generated: December 10 2003

4.3.8. Environment

Lets you specify/view environment variables. Environment variables can be used in headers, footers and Javadoc templates to form variable expressions that will be resolved during printing. I call this process variable interpolation.

Environment variables are simple key/value pairs. Valid keys take the form ([a-zA-Z_][a-zA-Z0-9_.])+ and are case-sensitive. Values can be freely choosen.

Example 4.142. Sample environment variables

author = <a href="http://jalopy.sf.net/contact.html">Marco Hunsicker</a>
project = Jalopy Java Source Code Formatter

4.3.8.1. User environment variables

Lets you specify you're user specific environment variables. Use the Add... and Remove buttons to add or remove items to and from the list.

4.3.8.2. System environment variables

All system environment variables are automatically available as well but cannot be changed from within Jalopy.

4.3.8.3. Local environment variables

Additionaly, Jalopy provides some local variables that are automatically set depending on the execution context.

The current list of valid local variables reads as follows:

Table 4.1. Local environment variables

fileThe absolute path of the currently processed Java file (e.g. /usr/projects/test/MyFile.java)
fileNameThe name of the currently processed Java file (e.g. MyFile.java)
fileFormatA string represention of the file format that will be used to write a file (e.g. UNIX or DOS)
packageThe package name of the currently processed Java file (e.g. com.foo.mypackage)
conventionThe name of the currently active code convention (as specified in the settings)
tabSizeThe current indentation setting (as specified in the settings)
objectTypeOnly applies to Javadoc templates: Holds the type name of the class for a constructor.
paramTypeOnly applies to Javadoc templates: Holds the type name of a parameter.
exceptionTypeOnly applies to Javadoc templates: Holds the type name of a throws clause.

4.3.8.4. Usage

Once defined, variables can then be enclosed with the dollar sign to form variable expressions. Variable expressions thus take the form $([a-zA-Z_][a-zA-Z0-9_.]+)$.

During printing these expressions will be interpolated and the value of the variable inserted into the output file.

Example 4.143. Header template with environment variable expressions

//==============================================================================
// file :       $fileName$
// project:     $project$
//
// last change: date:       $Date$
//              by:         $Author$
//              revision:   $Revision$
//------------------------------------------------------------------------------
// copyright:   BSJT Software License (see class documentation)
//==============================================================================

Example 4.144. Header after interpolation

//==============================================================================
// file :       Byte.java
// project:     bsjt-rt
//
// last change: date:       $Date$
//              by:         $Author$
//              revision:   $Revision$
//------------------------------------------------------------------------------
// copyright:   BSJT Software License (see class documentation)
//==============================================================================

As you see with the above example, if a variable is not defined, Jalopy won't touch the expression and simply preserve the original content. This way Jalopy works nicely with other source code tools and SCM products.

to top