|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.gridsystems.config.tools.Template
public class Template
Simple template implementation.
Instances of this class use a template file as its source, with an optional default template located in the classpath.
Constructor Summary | |
---|---|
Template(java.io.File f)
Creates a template using the specified file as the source. |
|
Template(java.io.File f,
java.lang.String resourceName)
Creates a template using the specified file as the source. |
|
Template(java.io.File f,
java.net.URL url)
Create a template using the specified file and URL as the template source, and its default source respectively. |
Method Summary | |
---|---|
void |
printTo(java.util.Properties props,
java.io.PrintWriter out)
Writes the tamplate into the specified writer, replacing all found keys in the template text with the values in the props argument. |
void |
writeTo(java.util.Properties props,
java.io.File f)
Writes the template to the specified file. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Template(java.io.File f) throws java.io.IOException
f
- The source template file
java.io.IOException
- In case of error handling resourcespublic Template(java.io.File f, java.lang.String resourceName) throws java.io.IOException
f
- The file of the template sourceresourceName
- The default template source as a resource name
java.io.IOException
- In case of error handling resourcespublic Template(java.io.File f, java.net.URL url) throws java.io.IOException
If the file is not found, it will be created as a copy of the specified default. This way, anyone can modify the template, and turning back to the default will be as simple as deleting the file.
f
- The template source fileurl
- The URL of the default template source
java.io.IOException
- In case of error handling resourcesMethod Detail |
---|
public void writeTo(java.util.Properties props, java.io.File f) throws java.io.IOException
props
- The replacements to performf
- The destination file
java.io.IOException
- In case of I/O errorpublic void printTo(java.util.Properties props, java.io.PrintWriter out) throws java.io.IOException
A key in the template has the following syntax: ${key}
props
- The replacement listout
- The writer
java.io.IOException
- In case of I/O error
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |