Package repast.simphony.util
Class VelocityUtils
java.lang.Object
repast.simphony.util.VelocityUtils
A class providing utility functions for working with template strings through
Velocity. For more information on velocity, including a listing of how
to define variables in it, visit http://jakarta.apache.org/velocity/.
- Version:
- $Revision: 1.1 $ $Date: 2005/12/21 22:25:35 $
- Author:
- Jerry Vos
- See Also:
-
VelocityContext
Velocity
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
Parses a string containing variables who's values will be filled in based on the VelocityContext passed in.getTemplateVarNames
(String toParse) Retrieves the names of the variables contained in the toParse string.
-
Constructor Details
-
VelocityUtils
public VelocityUtils()
-
-
Method Details
-
evaluate
public static String evaluate(org.apache.velocity.VelocityContext context, String toParse, String valueOnError) Parses a string containing variables who's values will be filled in based on the VelocityContext passed in. If there is an error parsing the string, the valueOnError is returned. An example string would be "Var1's value is: ${Var1}"- Parameters:
context
- object containing the values to replace the variables withtoParse
- the string containing the variables and arbitrary textvalueOnError
- the string to return if there is an error parsing the toParse string- Returns:
- either a string based on the variable toParse string or the valueOnError if there was an error parsing the string
-
getTemplateVarNames
Retrieves the names of the variables contained in the toParse string. The code found in this method was harvested from Velocity's parsing code.- Parameters:
toParse
- a string containing variables- Returns:
- an ArrayList of the variables contained in the string
-