Lets you specify, view and adjust environment variables.
Environment variables are simple key/value pairs and can be used in
header,
footer and Javadoc
templates to form expressions that will be resolved during formatting. Embedded
strings of the form $variable$
are replaced with their
corresponding value. This process is called variable
interpolation.
Valid keys take the form [a-zA-Z_][a-zA-Z0-9_.-]*
and are case-sensitive. Values can be freely chosen.
Example 2.3. 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.4. 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 Edit... 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 specified variables will override any other custom or system variables. The overrides file uses the common java.util.Properties format.
Table 2.3. Typical .overrides locations for user “John Doo”
Operating System | Jalopy .overrides Location |
---|---|
Linux | /home/John Doo/.jalopy/.user.properties |
Mac OS X | /Users/John Doo/.jalopy/.user.properties |
Solaris | /export/home/John Doo/.jalopy/.user.properties |
Windows Vista | C:\Users\John Doo\AppData\Roaming\.jalopy\.user.properties |
Windows XP | C:\Documents and Settings\John Doo\.jalopy\.user.properties |
Please consult your operating system documentation if your system uses different paths for the user directories. Detailed information about the Jalopy settings directory can be found in Chapter 2, Configuration.
Since 1.6
The above example would define/override the variables “author” and “division”. Please note that the environment may be overwritten manually using the Console and Ant plug-ins as well. Please refer to the corresponding 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.4. 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 representation of the line ending character(s) 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/setter | 1.1 |
Property.Name | Holds the capitalized property name of the currently processed getter/setter method | Javadoc getter/setter | 1.9.3 |
Once defined, variables can be enclosed with dollar signs to form variable
expressions and embedded in comment templates. Variable expressions take the form
$[a-zA-Z_][a-zA-Z0-9_.-]*$
.
During emitting, these expressions will be interpolated and the value of the variable inserted into the source file.
Example 2.7. 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.8. 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 descriptions 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. The default pattern is M/d/yy
, which translates to
something like 07/23/09
.
Since 1.2
Time pattern
Lets you define the pattern that is used for the
$time$
variable expression. The default pattern is h:mm a
, which translates to
something like 02:56 PM
.
Since 1.2