org.apache.velocity.app.tools

Class VelocityFormatter.VelocityAlternator

Enclosing Class:
VelocityFormatter
Known Direct Subclasses:
VelocityFormatter.VelocityAutoAlternator

public class VelocityFormatter.VelocityAlternator
extends java.lang.Object

Class that returns alternating values in a template. It stores a list of alternate Strings, whenever alternate() is called it switches to the next in the list. The current alternate is retrieved through toString() - i.e. just by referencing the object in a Velocity template. For an example of usage see the makeAlternator() method below.

Field Summary

protected String[]
alternates
protected int
current

Constructor Summary

VelocityAlternator(String[] alternates)
Constructor takes an array of Strings.

Method Summary

String
alternate()
Alternates to the next in the list.
String
toString()
Returns the current alternate.

Field Details

alternates

protected String[] alternates


current

protected int current

Constructor Details

VelocityAlternator

public VelocityAlternator(String[] alternates)
Constructor takes an array of Strings.

Parameters:
alternates - A String[].

Method Details

alternate

public String alternate()
Alternates to the next in the list.

Returns:
The current alternate in the sequence.


toString

public String toString()
Returns the current alternate.

Returns:
A String.


Copyright B) 2002 Apache Software Foundation. All Rights Reserved.