File Generation Services |
| Method | Parameters | Description |
|---|
_setFileNamePrefix [ top ] | String: | | | Prepended to file name root
|
|
The file name prefix is prepended to the
file name root of each generated file.
You would normally use this method in the init section. The default value for the
file name prefix is taken from the configuration
setting main.FileNamePrefix.
Example:
_setFileNamePrefix( "Add" );
|
_getFileNamePrefix [ top ] | |
Returns the file name prefix as a String.
See: _setFileNamePrefix
|
_setFileNameSuffix [ top ] | String: | | | Appended to file name root
|
|
The file name suffix is appended to the
file name root of each generated file.
You would normally use this method in the init section when specifying what files to
generate. The default value for the file name
suffix is taken from the configuration setting main.FileNameSuffix.
Example:
_setFileNameSuffix( ".pl" );
|
_getFileNameSuffix [ top ] | |
Returns the file name suffix as a String.
See: _setFileNameSuffix
|
_setFullFileName [ top ] | String: | | | Full file name of generated file
|
|
The full name of the generated file is known as the full file name. The full
file name can be set directly using
_setFullFileName or by using the _setFileNamePrefix, _setFileNameRoot and _setFileNameSuffix methods.
You would normally use this method in the init section. The default value for the
full file name is taken from the concatenating the
configuration settings main.FileNamePrefix, main.FileNameRoot and main.FileNameSuffix.
Example:
_setFullFileName( "Generated.java" );
|
_getFullFileName [ top ] | |
Returns the full file name as a String.
If the file name was specified using _setFileNamePrefix, _setFileNameRoot, and _setFileNameSuffix, then the full file
name is formed by concatenating the file
name prefix, the file name root
and the file name suffix.
This method always returns the full file name of the
file currently being generated, if more than one full file
name was specified using _setFullFileNames.
See: _setFullFileName
|
_setFullFileNames [ top ] | String[]: | | | Array containing the full file name of each generated file
|
|
The full name of each generated file is known as the full file name. The list of full file
names can be set directly using the
_setFullFileNames method or by using the _setFileNamePrefix, _setFileNameRoots and _setFileNameSuffix methods.
You would normally use this method in the init section.
See: _setFullFileName
Example:
String[] fullFileNames =
new String[] { "First.java", "Second.java" };
_setFullFileNames( fullFileNames );
|
_getFullFileNames [ top ] | |
Returns the list of full file name values as a String array.
See: _setFullFileNames
|
_setFileNameRoot [ top ] | String: | | | The file name root of the generated file
|
|
The full name of each generated file is formed by concatenating
the file name prefix, the current file name root and the file
name suffix. You would normally use this method in the
init section to set the file name
root.
See: _setFileNameRoots
Example:
_setFileNameSuffix( ".java" );
_setFileNameRoot( "Foo" );
|
_getFileNameRoot [ top ] | |
Returns the file name root of the generated file as a String.
See: _setFileNameRoot
|
_setFileNameRoots [ top ] | String[]: | | | The file name roots of the files to generate
|
|
The full name of each generated file is formed by concatenating
the file name prefix, the file name root and the file
name suffix. You would normally use the
_setFileNameRoots method in the init section of the template to set the list
of file name rootss of the files to generate.
By breaking the generated file name into three sections (prefix,
root, suffix) you can refer to each part separately. This is can
be used to generate many files with the same prefix or suffix.
For example, you might have value objects named:
Apple.java, Orange.java, and
Pear.java.
Example:
String[] objects = new String[] { "Apple", "Orange", "Pear" };
_setFileNameSuffix( ".java" );
_setFileNameRoots( objects );
|
_getFileNameRoots [ top ] | |
Returns the list of file name root values as a String array.
See: _setFileNameRoots
|
_getFileIndex [ top ] | |
Returns the index of the current file being generated as an
integer. This integer references the position of the file name as
specified in the array provided to _setFileNameRoots or _setFullFileNames. This method can be used
to index other data structures based on the file being generated.
The index starts at zero.
See: _setFileNameRoots, _setFullFileNames
|
_getNumFiles [ top ] | |
Returns to number of files specified in the array provided to
_setFileNameRoots or _setFullFileNames.
See: _setFileNameRoots, _setFullFileNames
|
_setOutputFolder [ top ] | Folder: | | | The output folder for generated files
|
|
Files generated by theCodeWriter
program are saved to an ouput folder. You
can use the _setOutputFolder method to set the
location of this output folder.
The default output folder is specified by the setting
main.OutputFolder.
You can also specify the output folder using the the
-O command line option.
Example:
_setOutputFolder( "../output" );
|
_getOutputFolder [ top ] | |
Returns the name of the output folder for
generated files as a String.
See: _setOutputFolder
|
_setBackupFolder [ top ] | Folder: | | | The backup folder for generated files
|
|
By default, files generated by theCodeWriter program are backed up to a backup folder. You can use the
_setBackupFolder method to set the location of this
backup folder.
Note: the backup folder is
specified relative to the output
folder.
The default backup folder is specified by the setting
main.BackupFolder.
You can also specify the backup folder
using the the -b command line option.
Example:
_setBackupFolder( "backup" );
|
_getBackupFolder [ top ] | |
Returns the name of the backup folder for
generated files as a String.
See: _setBackupFolder
|
_setBackupPrefix [ top ] | String: | | | The backup prefix for generated files
|
|
You can use the _setBackupPrefix method to set a
String that is prepended to the name of each backup file.
Note that the date and time are placed before this prefix,
in the format YYYYMMDDhhmmss.
The default backup prefix is specified by the setting
main.BackupPrefix.
Example:
_setBackupPrefix( "-" );
|
_setBackupSuffix [ top ] | String: | | | The backup suffix for generated files
|
|
You can use the _setBackupSuffix method to set a
String that is appended to the name of each backup file.
The default backup suffix is specified by the setting
main.BackupSuffix.
Example:
_setBackupSuffix( "-backup.txt" );
|
_backup [ top ] | boolean: | | | If true, generated files will be backed up
|
|
By default, generated files are backed up to a backup folder. You can disable backups by
specifying an argument of false to this method.
Conversely, an argument of true enables backups.
The -B command line option disables backups.
|
_save [ top ] | boolean: | | | If true, generated files are saved
|
|
By default, generated files are saved to an output folder. You can disable saving of
generated files by specifying an argument of false to
this method. Conversely, an argument of true enables
saving of generated files.
The -g command line option enables
saving of generated files. The -G
command line option disables saving of generated files.
|
_saveTextFile [ top ] | String: | | | File path of text file to save
| String: | | | Contents of text file to save
|
|
This utility method saves a text file to disk.
If there was a problem, an exception is thrown.
See: _loadTextFile
|
_loadTextFile [ top ] | String: | | | File path of text file to load
|
|
This utility method loads a text file to disk.
If there was a problem, an exception is thrown.
See: _saveTextFile
|
Control Services |
| Method | Parameters | Description |
|---|
_getProperty [ top ] | |
Get the value of a configuration property such as main.TemplateScript. These values are hard
coded into the CodeWriter program
when the template is compiled by Jostraca. They are not updated
unless the template is recompiled.
|
_getFirstUserArg [ top ] | |
Template specific user arguments may be specified to Jostraca on
the command line to indicate the sources of, for example, external
meta data such as the name of an XML file. These arguments must
follow the name of the template on the command line. The -a option can be used to specify arguments
when the -l option is used to specify
more than one template on the command line.
Jostraca uses a set of special arguments to control the CodeWriter program (these are prefixed with
jsa: so as not to conflict with user
arguments). This method returns the first non Jostraca argument.
Example:
jostraca template.jtm firstUserArg \
secondUserArg thirdUserArg
jostraca -l templateOne.jtm templateTwo.jtm \
-a firstUserArg -a secondUserArg -a thirdUserArg
See: _getUserArg and _getArgs.
|
_getSecondUserArg [ top ] | |
This method returns the second non Jostraca argument on the
command line.
See: _getFirstUserArg.
|
_getThirdUserArg [ top ] | |
This method returns the third non Jostraca argument on the command
line.
See: _getSecondUserArg.
|
_getUserArg [ top ] | int: | | | Index of user argument
|
|
Template specific user arguments may be specified to Jostraca on
the command line to indicate the sources of, for example, external
meta data such as the name of an XML file. These arguments must
follow the name of the template. The -a option can be used to specify arguments
when the -l option is used to specify
more than one template on the command line.
Jostraca uses a set of special arguments to control the CodeWriter (these are prefixed with
jsa: so as not to conflict with user arguments). This
method returns the specified non Jostraca argument. The first
argument is at index zero.
See: _getFirstUserArg and _getArgs.
|
_getUserArgs [ top ] | |
This method returns the full list of user command line arguments passed
to the CodeWriter.
See: _getUserArg and _getArgs.
|
_getNumUserArgs [ top ] | |
This method returns the number of user command line arguments passed
to the CodeWriter.
See: _getUserArgs.
|
_getArgs [ top ] | |
This method returns the full list of command line arguments passed
to the CodeWriter, including special control
arguments.
See: _getUserArgs.
|
_getNumArgs [ top ] | |
This method returns the number of all command line arguments passed
to the CodeWriter, including special control
arguments.
See: _getArgs.
|
Text Production Services |
| Method | Parameters | Description |
|---|
_insert [ top ] | String: | | | Text to insert into the generated file
|
|
The text of the generated file is created by calls to the
_insert method. This method is like a
print statement, with output being directed to the
text of the generated file.
Note: <% _insert( anExpression ); %> may
be abbreviated as <%=anExpression%>.
The _insert method accepts any valid expression of
the script language. The String equivalent of the expression is then
inserted into the text of the generated file. Of course, the
String equivalent of any given expression is script language
dependent (Although you can expect reasonable behaviour in most
cases, especially for variables).
|
_spaces [ top ] | int: | | | Number of spaces to place in the String
|
|
This method creates a String with the specified number of
spaces. This can be useful for aligning columns in the generated
file.
Example:
<%=fieldName%><%=_spaces( 20 - fieldName.length() )%><%=fieldType%>
|
_left [ top ] | String: | | | Text to align
| int: | | | Number of spaces to place in the column
|
|
This method aligns a String on the left side of a column of spaces
of the specified width. This can be useful for aligning columns
in the generated file.
Example:
<%=_left( field, 20 )%>
|
_right [ top ] | String: | | | Text to align
| int: | | | Number of spaces to place in the column
|
|
This method aligns a String on the right side of a column of
spaces of the specified width. This can be useful for aligning
columns in the generated file.
Example:
<%=_right( field, 20 )%>
|
_center [ top ] | String: | | | Text to align
| int: | | | Number of spaces to place in the column
|
|
This method centers a String inside a column of spaces of the
specified width.
Example:
<%=_center( field, 20 )%>
|
_setText [ top ] | String: | | | The full text of the generated file
|
|
Explicitly set the text of the generated file directly. You can
use the _setText method to manipulate the generated
text as a whole.
See: _getText
Example:
String text = _getText();
text.replace( 'x', 'y' );
_setText( text );
|
_getText [ top ] | |
Returns the text of the generated file as a String.
See: _setText
|