Using Macros in Templates
You can also use macros in your templates to have various strings automatically generated when you create objects from 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. You can also create your own macros.
The IDE has the following uneditable macros:
- __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.
- __PACKAGE_SLASHES__ - Substitutes the name of the class's package, but 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 but
delimits names 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.
To edit the __USER__ macro:
- Choose Tools
Options.
- Expand the Editing node, and select the Java Sources node.
- Select the Strings Table property, and click the ellipsis (...) button to open its custom property editor.
- Edit the value of USER and click OK.
To create a new macros for use in templates:
- Choose Tools
Options.
- Expand the Editing node, and select the Java Sources node.
- Select the Strings Table property, and click the ellipsis (...) button to open its custom property editor.
- Add macros in the form MacroName=Value and click OK.
When you define the macro, do not place the underscore characters at the beginning and end of the macro name.
Legal Notices