is replaced with "David Moisan").
Designed for Scala Lingua scripts but can be used for
general-purpose template loading and replacement.
Permission is granted to use this code in any commercial or non-commercial
application. NO WARRANTY IS IMPLIED.
-
TemplateStream(String)
- Constructor
-
closeTemplateOutput(FileWriter)
- closeTemplateOutput -- Write out unused template, replacing all
unused keywords and close output stream
-
newTemplate(String)
- newTemplate -- Load a new template to match keywords against in future
processing
Note that name is appended to the template start string
and the search is done on that string.
-
replaceString(String, String, FileWriter)
- replaceString
The heart of TemplateStream:
Copy the template to the output stream, replacing the
keyword with the specified text.
-
setTemplateDelim(String, String, String, String)
- SetTemplateDelim --
Sets the strings that delimit the start and end
of the template, and the command prefix that differentiates
substitution keywords from plain text
TemplateStream
public TemplateStream(String contents)
- Constructor
- Parameters:
- contents - String Contents of all templates
setTemplateDelim
public void setTemplateDelim(String start,
String end,
String keystart,
String keyend)
- SetTemplateDelim --
Sets the strings that delimit the start and end
of the template, and the command prefix that differentiates
substitution keywords from plain text
- Parameters:
- String - start Opening string in template
- String - end Closing string in template
- String - keystart Keyword opening delimiter
- String - keyend Keyword closing delimiter
newTemplate
public boolean newTemplate(String name)
- newTemplate -- Load a new template to match keywords against in future
processing
Note that name is appended to the template start string
and the search is done on that string.
- Parameters:
- name - String Name of template to load
- Returns:
- s boolean true if template loaded, false if not
replaceString
public boolean replaceString(String keyword,
String replacement,
FileWriter deststream) throws IOException
- replaceString
The heart of TemplateStream:
Copy the template to the output stream, replacing the
keyword with the specified text.
- Parameters:
- keyword - String Keyword to replace
- replacement - String text that replaces keyword
- deststream - FileWriter Output stream
- Returns:
- s boolean true if keyword found and replaced, false if not.
- Throws: IOException
- Thrown for I/O errors
closeTemplateOutput
public void closeTemplateOutput(FileWriter deststream) throws IOException
- closeTemplateOutput -- Write out unused template, replacing all
unused keywords and close output stream
- Parameters:
- deststream - FileWriter Output stream
- Throws: IOException
- Thrown for I/O errors
All Packages Class Hierarchy This Package Previous Next Index