Class VelocityUtils

java.lang.Object
repast.simphony.util.VelocityUtils

public class VelocityUtils extends Object
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 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 with
      toParse - the string containing the variables and arbitrary text
      valueOnError - 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

      public static ArrayList<String> getTemplateVarNames(String toParse)
      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