Jostraca Reference

Template Services

Ant Attributes
Command Line Options
Configuration Settings
Glossary
Template Directives
Template Sections
Template Services
Standard Files and Folders
www.jostraca.org
info@jostraca.org

Index (most frequently used first) [ alphabetical index ]
File Generation Services   
_setFileNamePrefix   Set the file name prefix for generated files.
_getFileNamePrefix   Get the file name prefix for generated files.
_setFileNameSuffix   Set the file name suffix for generated files.
_getFileNameSuffix   Get the file name suffix for generated files.
_setFullFileName   Set the full file name of the generated file.
_getFullFileName   Get the full file name of the generated file.
_setFullFileNames   Set the full file name for each generated file.
_getFullFileNames   Get the list of full file names, one for each generated file.
_setFileNameRoot   Set the file name root for each generated file.
_getFileNameRoot   Get the file name root of the generated file.
_setFileNameRoots   Set the file name root for each generated file.
_getFileNameRoots   Get the list of file name roots, one for each generated file.
_getFileIndex   Get the index integer of the file currently being generated.
_getNumFiles   Get the number of files to generate.
_setOutputFolder   Set the output folder for generated files.
_getOutputFolder   Get the output folder for generated files.
_setBackupFolder   Set the backup folder for generated files.
_getBackupFolder   Get the backup folder for generated files.
_setBackupPrefix   Set the prefix of backup file names.
_setBackupSuffix   Set the suffix of backup file names.
_backup   Enable/disable backups of generated files.
_save   Enable/disable saving of generated files.
_saveTextFile   Save a text file to disk.
_loadTextFile   Load a text file from disk.
Control Services   
_getProperty   Get template compile time property.
_getFirstUserArg   Get the first user command line argument.
_getSecondUserArg   Get the second user command line argument.
_getThirdUserArg   Get the third user command line argument.
_getUserArg   Get the specified user command line argument.
_getUserArgs   Get the list of user command line arguments to the CodeWriter.
_getNumUserArgs   Get the number of user command line arguments to the CodeWriter.
_getArgs   Get the full list of command line arguments to the CodeWriter.
_getNumArgs   Get the number of all command line arguments to the CodeWriter.
Text Production Services   
_insert   Insert text into the generated file.
_spaces   Create a String consisting of the specified number of spaces.
_left   Left align a String within a column of the specified width.
_right   pight align a String within a column of the specified width.
_center   Center a String within a column of the specified width.
_setText   Set the text of the generated file.
_getText   Get the text of the generated file.







File Generation Services
MethodParameters 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 ]
None
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 ]
None
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 ]
None
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 ]
None
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 ]
None
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 ]
None
Returns the list of file name root values as a String array.
See: _setFileNameRoots
_getFileIndex
[ top ]
None
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 ]
None
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 ]
None
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 ]
None
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
MethodParameters Description
_getProperty
[ top ]
String:
    Name of property
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 ]
None
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 ]
None
This method returns the second non Jostraca argument on the command line.

See: _getFirstUserArg.
_getThirdUserArg
[ top ]
None
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 ]
None
This method returns the full list of user command line arguments passed to the CodeWriter.

See: _getUserArg and _getArgs.
_getNumUserArgs
[ top ]
None
This method returns the number of user command line arguments passed to the CodeWriter.

See: _getUserArgs.
_getArgs
[ top ]
None
This method returns the full list of command line arguments passed to the CodeWriter, including special control arguments.

See: _getUserArgs.
_getNumArgs
[ top ]
None
This method returns the number of all command line arguments passed to the CodeWriter, including special control arguments.

See: _getArgs.

Text Production Services
MethodParameters 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 ]
None
Returns the text of the generated file as a String.
See: _setText

Index (alphabetical) [ top ]
_backup   Enable/disable backups of generated files.
_center   Center a String within a column of the specified width.
_getArgs   Get the full list of command line arguments to the CodeWriter.
_getBackupFolder   Get the backup folder for generated files.
_getFileIndex   Get the index integer of the file currently being generated.
_getFileNamePrefix   Get the file name prefix for generated files.
_getFileNameRoot   Get the file name root of the generated file.
_getFileNameRoots   Get the list of file name roots, one for each generated file.
_getFileNameSuffix   Get the file name suffix for generated files.
_getFirstUserArg   Get the first user command line argument.
_getFullFileName   Get the full file name of the generated file.
_getFullFileNames   Get the list of full file names, one for each generated file.
_getNumArgs   Get the number of all command line arguments to the CodeWriter.
_getNumFiles   Get the number of files to generate.
_getNumUserArgs   Get the number of user command line arguments to the CodeWriter.
_getOutputFolder   Get the output folder for generated files.
_getProperty   Get template compile time property.
_getSecondUserArg   Get the second user command line argument.
_getText   Get the text of the generated file.
_getThirdUserArg   Get the third user command line argument.
_getUserArg   Get the specified user command line argument.
_getUserArgs   Get the list of user command line arguments to the CodeWriter.
_insert   Insert text into the generated file.
_left   Left align a String within a column of the specified width.
_loadTextFile   Load a text file from disk.
_right   pight align a String within a column of the specified width.
_save   Enable/disable saving of generated files.
_saveTextFile   Save a text file to disk.
_setBackupFolder   Set the backup folder for generated files.
_setBackupPrefix   Set the prefix of backup file names.
_setBackupSuffix   Set the suffix of backup file names.
_setFileNamePrefix   Set the file name prefix for generated files.
_setFileNameRoot   Set the file name root for each generated file.
_setFileNameRoots   Set the file name root for each generated file.
_setFileNameSuffix   Set the file name suffix for generated files.
_setFullFileName   Set the full file name of the generated file.
_setFullFileNames   Set the full file name for each generated file.
_setOutputFolder   Set the output folder for generated files.
_setText   Set the text of the generated file.
_spaces   Create a String consisting of the specified number of spaces.































Copyright © 2000-2001 Richard Rodger.