GenericTools is the set of classes that provide basic infrastructure for using tools in standard Java SE Velocity projects, as well as a set of tools for use in generic Velocity templates. These tools have no Java EE dependencies and are often safe to use as "singletons". Some of them are not thread-safe to allow both a no-arg constructor and configurability, but the state-changing methods are declared protected with the exception of configure(Map) which is--by default--rendered useless after being used just once. If you require strict thread-safety, be cautious in using any configurable tools and consider restricting the abilities of template authors to prevent circumvention of the lockdown placed on configuration methods.

Default Configuration

The default configuration provided for GenericTools is here. It includes all of the tools listed below.


The dependencies required for GenericTools vary somewhat depending on which tools you use, whether you will rely on core tool management infrastructure, and if so, how you choose to configure your toolbox. More details can be found on the dependencies chart.


  • - For creating s to easily alternate over a set of values.
  • - For simplifying reflective lookup of information about Classes and their fields, methods and constructors.
  • - For convenient access to Context data and meta-data.
  • - For converting String values to richer object types.
  • & - For manipulating, formatting, and comparing dates.
  • - For controlling display of references (e.g. truncating values, "pretty printing" lists, and displaying alternates when a reference is null).
  • - For common escaping needs in Velocity templates (e.g. escaping html, xml, javascript etc.)
  • - For (easy) access to static fields in a class, such as string constants.
  • - A convenience tool to use with #foreach loops. It wraps a list with a custom iterator to provide greater control, allowing loops to end early, skip ahead and more.
  • - For creating and manipulating URIs and URLs. The API for this tool is designed to closely resemble that of the VelocityView tool of the same name.
  • - For working with arrays and lists, treats both transparently the same.
  • - For performing math functions.
  • - For formatting and converting numbers.
  • - To evaluate and render arbitrary strings of VTL, including recursive rendering.
  • - For simplified access to ResourceBundles for internationalization or other dynamic content needs.
  • - Used to sort collections (or arrays, iterators, etc) on any arbitary set of properties exposed by the objects contained within the collection.
  • - For reading/navigating XML files. This uses dom4j under the covers and provides complete XPath support.