You can use macros in your templates to have various strings automatically generated when you create objects from the template. Macros are called in templates in the form __MacroName__ with two underscores before and two underscores after the macro name. The IDE includes several uneditable macros and one editable macro. All of these macros are available for .java files and some of them are available for other types of files. You can also create your own macros.
The IDE has the following uneditable macros.
Macro | Generated String |
---|---|
__DATE__ | Substitutes the date of template creation. |
__TIME__ | Substitutes the time of template creation. |
__NAME__ | Substitutes the name of the class (without extension). |
__PACKAGE__ | Substitutes the name of the package that the class is in. Do not use this macro for the package statement in a Java class. It is better to provide the package statement for the template itself. When a class is created from a template, the package statement is automatically changed to reflect the package that the class is created in. |
__PACKAGE_SLASHES__ | Substitutes the name of the class's package. However, the name is delimited with slashes (/) instead of periods (.). |
__PACKAGE_AND_NAME__ | Substitutes the name of the package and the file, substituted in the form packageName.fileName. If the file resides in the root of the filesystem, it is substituted only with the filename. |
__PACKAGE_AND_NAME_SLASHES__ |
Works the same as PACKAGE_AND_NAME. However names are delimited with slashes (/) instead of periods (.). |
__QUOTES__ | Substitutes a double quote mark ("). This macro is necessary if you want to place a macro between quote marks. If you enclose a macro in actual quotes in the template, text substitution for that macro does not occur when you create an object from that template. |
Many templates in the IDE use the __USER__ macro, which substitutes the user name in files created from the template.
To edit the __USER__ macro:
To create a new macro for use in templates:
When you define the macro, do not place the underscore characters at the beginning and end of the macro name.
See Also | |
---|---|
Creating a Template Modifying a Template Creating a Template for a Group of Files |