Lets you specify/view/adjust environment variables.
Environment variables can be used in header,
footer and Javadoc
templates to form expressions that will be resolved during printing. Embedded
strings of the form $variable$ are replaced with their
corresponding value. This process is called 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 chosen.
Example 2.1. Header template with environment variables expressions
//============================================================== // file : $file.name$ // project: $project$ // // create: date: $date$ // by: $author$ // //-------------------------------------------------------------- // copyright: BSJT Software License (see class documentation) //==============================================================
Example 2.2. Sample environment variables
- author = John Doo
- project.description = Nukes: The OpenSource CMS
Jalopy lets you define custom variables, but also provides access to the Java environment variables as well as some Jalopy-specific variables that are generally useful for common source formatting needs.
Lets you view and/or modify the custom environment variables.
Use the Add... and Remove buttons to add or remove items to and from the list.
Select a variable and press the Change... button if you want to adjust an existing environment variable.
Local Overrides
Custom user variables are stored as part of your code convention and are
therefore shared across a whole team. If you need to define user-specific
information, e.g. to automatically add the name of the developer who creates a
class, this is possible via the local overrides file
".user.properties".
When found in the Jalopy settings directory, the variables defined here will override any other custom or system variables. The overrides file uses the common java.util.Properties format.
On a typical Windows XP installation, the local overrides file for user John Doo would be
C:\Documents and Settings\John Doo\.jalopy\.user.propertiesOn Linux it might be
/home/John Doo/.jalopy/.user.propertiesFurther information about the Jalopy settings directory can be found in Chapter 2, Configuration.
To define/override the variables "author" and "division", the local overrides file might look like this:
Since 1.6
Please note that the environment may be overwritten manually using the Console and Ant Plug-ins as well. Please refer to the Plug-in documentation.
Lets you view your Java system environment variables.
All system environment variables are automatically available as well, but cannot be changed from within Jalopy.
Additionally, 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 2.2. Local environment variables
| Name | Description | Scope | Since |
|---|---|---|---|
file | The absolute path of the currently processed source file
(e.g. /usr/projects/test/MyFile.java) | global | 1.0 |
file.name | The name of the currently processed source file
(e.g. MyFile.java) | global | 1.0 |
file.format | A string represent ion of the file format that will be used to write a file (UNIX, DOS or MAC) | global | 1.0 |
convention | The name of the currently active code convention (as specified in the settings) | global | 1.0 |
convention.desc | The description of the currently active code convention (as specified in the settings) | global | 1.0 |
project | The name of the currently active project/profile. For IDE Plug-ins this resolves to the current IDE project, otherwise the active Jalopy profile name is used | global | 1.0.1 |
project.desc | The description of the currently active Jalopy profile | global | 1.0.1 |
tab.size | The current indentation setting (as specified in the settings) | global | 1.0 |
date | The current date, formatted in the style specified in the Date/Time settings (see Section 2.4.5, “Date/Time” below) | global | 1.0 |
date.year | The current year | global | 1.0 |
date.long | The current date, formatted as
java.text.DateFormat LONG style | global | 1.0 |
date.full | The current date, formatted as
java.text.DateFormat FULL style | global | 1.0 |
time | The current time, formatted in the style specified in the Date/Time settings (see Section 2.4.5, “Date/Time” below) | global | 1.0 |
time.long | The current time, formatted as
java.text.DateFormat LONG style | global | 1.0 |
time.full | The current time, formatted as
java.text.DateFormat FULL style | global | 1.0 |
package.name | The package name of the currently processed source file (e.g. com.foo.mypackage) | global | 1.0 |
class.name | Holds the name of the currently processed class, interface or enum | Javadoc class, interface, field, constructor, method, getter, setter | 1.0 |
field.name | Holds the name of the currently processed field | Javadoc field | 1.0 |
field.type | Holds the type name of the currently processed field | Javadoc field | 1.0 |
method.name | Holds the name of the currently processed method | Javadoc method | 1.0 |
param.name | Holds the name of the currently processed Javadoc parameter tag | Javadoc constructor, method | 1.0 |
param.type | Holds the type of the currently processed Javadoc parameter tag | Javadoc constructor, method | 1.0 |
exception.type | Holds the type of the currently processed throws clause member | Javadoc constructor, method | 1.0 |
return.type | Holds the return type of the currently processed method | Javadoc method | 1.0 |
property.name | Holds the property name of the currently processed getter/setter method. You can control the behavior during variable interpolation with the "Format bean property" option | Javadoc getter/getter method | 1.1 |
Once defined, variables can then be enclosed with dollar signs 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 2.5. Header template with environment variable expressions
//=============================================================== // file : $file.name$ // project: $project$ // // last change: date: $Date$ // by: $author$ // revision: $Revision$ //--------------------------------------------------------------- // copyright: BSJT Software License (see class documentation) //===============================================================
Example 2.6. Header after interpolation
//=============================================================== // file : Byte.java // project: bsjt-rt // // last change: date: $Date$ // by: John Doo // revision: $Revision$ //--------------------------------------------------------------- // copyright: BSJT Software License (see class documentation) //===============================================================
As you can see in the above example, if a variable is not defined, Jalopy won't touch the expression and simply preserves the original content. This way, the formatter works nicely with other source code tools and SCM products.
The available user and local environment variables are provided from within the context menu of the text component when customizing the different templates.
Please see Section 2.4.1, “Custom variables”, Section 2.4.2, “System variables” and Section 2.4.3, “Local variables” for a description of the different available variable types.
Lets you define the patterns that should be used for the
$date$ and $time$ expressions (see Section 2.4.3, “Local variables”).
For a detailed description, the list of available patterns and further
examples, please refer to the Javadoc for the
java.text.SimpleDateFormat class.
Date pattern
Lets you define the pattern that is used for the $date$
variable expression (see Local variables).
The default pattern is M/d/yy which translates to something
like 12/24/98.
Since 1.2
Time pattern
Lets you define the pattern that is used for the $time$
variable expression (see Local variables).
The default pattern is h:mm a which translates to something
like 02:56 PM.
Since 1.2






