|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--sdsu.util.Template
A Template is an document containing variables. This class does the variable substitution and replaces with given values. If a variable is not given a value, it and the variable marker is removed from the template. Variables in denoted in the template by preceeding and following them by a special string, the variableMarker. The default value for the variableMarker is @@@. The creator of the template must insure this string does not occur as text in the template.
Constructor Summary | |
Template(java.lang.String templateText)
Creates a template object using the given text |
Method Summary | |
void |
clear()
Clears all variables. |
static Template |
fromFile(java.lang.String fileName)
Reads the text for a template from the given file. |
void |
replace(java.util.Hashtable variablesAndValues)
Replaces all occurances of the given variables with given values. |
void |
replace(java.lang.String variableName,
java.lang.String variableValue)
Replaces all occurances of the given variable with given string. |
void |
setVariableMarker(java.lang.String newMarker)
Changes the value of the variable marker. |
java.lang.String |
toString()
Returns the template with all variables subsituted for the given values. |
Methods inherited from class java.lang.Object |
equals,
getClass,
hashCode,
notify,
notifyAll,
wait,
wait,
wait |
Constructor Detail |
public Template(java.lang.String templateText)
Method Detail |
public static Template fromFile(java.lang.String fileName) throws java.io.FileNotFoundException, java.io.IOException
public void clear()
public void replace(java.lang.String variableName, java.lang.String variableValue)
public void replace(java.util.Hashtable variablesAndValues)
variablesAndValues
- a hashtable whose keys are used as the variables
and values are used as values of the variables. Keys and values are
converted to strings before using.public void setVariableMarker(java.lang.String newMarker)
newMarker
- the new value for the variable markerpublic java.lang.String toString()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |