Class AlternatorTool
- java.lang.Object
-
- org.apache.velocity.tools.generic.AlternatorTool
-
public class AlternatorTool extends java.lang.ObjectSimple tool to provide easy in-template instantiation ofAlternators from varying "list" types.Example Use:
toolbox.xml... <tool> <key>alternator</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.AlternatorTool</class> <parameter name="auto-alternate" value="true"/> </tool> template... #set( $color = $alternator.auto('red', 'blue') ) ## use manual alternation for this one #set( $style = $alternator.manual(['hip','fly','groovy']) ) #foreach( $i in [1..5] ) Number $i is $color and $style. I dig $style.next numbers. #end * output... Number 1 is red and hip. I dig hip numbers. Number 2 is blue and fly. I dig fly numbers. Number 3 is red and groovy. I dig groovy numbers. Number 4 is blue and hip. I dig hip numbers. Number 5 is red and fly. I dig fly numbers.- Since:
- Velocity Tools 1.2
- Version:
- $Revision: 484710 $ $Date: 2006-12-08 11:40:42 -0800 (Fri, 08 Dec 2006) $
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAUTO_ALTERNATE_DEFAULT_KEYprivate booleanautoAlternateDefault
-
Constructor Summary
Constructors Constructor Description AlternatorTool()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Alternatorauto(java.lang.Object[] array)Make an automaticAlternatorfrom the specified object array.Alternatorauto(java.lang.Object o1, java.lang.Object o2)Make an automaticAlternatorfrom a list containing the two specified objects.Alternatorauto(java.util.List list)Make an automaticAlternatorfrom values in the specified List.voidconfigure(java.util.Map params)Looks for a default auto-alternate value in the given params, if not, set the default to true.booleangetAutoAlternateDefault()Returns true if the default for auto-alternating is true.Alternatormake(boolean auto, java.lang.Object[] array)Deprecated.Useauto(Object[] array)ormanual(Object[] array)instead.Alternatormake(boolean auto, java.lang.Object o1, java.lang.Object o2)Deprecated.Useauto(Object o1, Object o2)ormanual(Object o1, Object o2)instead.Alternatormake(boolean auto, java.util.List list)Deprecated.Useauto(List list)ormanual(List list)instead.Alternatormake(java.lang.Object[] array)Make an automaticAlternatorfrom an object array.Alternatormake(java.lang.Object o1, java.lang.Object o2)Make an automaticAlternatorfrom a list containing the two specified objects.Alternatormake(java.util.List list)Make an automaticAlternatorfrom a List.Alternatormanual(java.lang.Object[] array)Make a manualAlternatorfrom the specified object array.Alternatormanual(java.lang.Object o1, java.lang.Object o2)Make a manualAlternatorfrom a list containing the two specified objects.Alternatormanual(java.util.List list)Make a manualAlternatorfrom values in the specified List.protected voidsetAutoAlternateDefault(boolean bool)Sets the default for auto-alternating.
-
-
-
Field Detail
-
AUTO_ALTERNATE_DEFAULT_KEY
public static final java.lang.String AUTO_ALTERNATE_DEFAULT_KEY
- Since:
- VelocityTools 1.3
- See Also:
- Constant Field Values
-
autoAlternateDefault
private boolean autoAlternateDefault
-
-
Method Detail
-
configure
public void configure(java.util.Map params)
Looks for a default auto-alternate value in the given params, if not, set the default to true.- Since:
- VelocityTools 1.3
-
getAutoAlternateDefault
public boolean getAutoAlternateDefault()
Returns true if the default for auto-alternating is true.- Since:
- VelocityTools 1.3
-
setAutoAlternateDefault
protected void setAutoAlternateDefault(boolean bool)
Sets the default for auto-alternating.- Since:
- VelocityTools 1.3
-
make
public Alternator make(java.util.List list)
Make an automaticAlternatorfrom a List.
-
make
public Alternator make(boolean auto, java.util.List list)
Deprecated.Useauto(List list)ormanual(List list)instead.
-
make
public Alternator make(java.lang.Object[] array)
Make an automaticAlternatorfrom an object array.
-
make
public Alternator make(boolean auto, java.lang.Object[] array)
Deprecated.Useauto(Object[] array)ormanual(Object[] array)instead.
-
make
public Alternator make(java.lang.Object o1, java.lang.Object o2)
Make an automaticAlternatorfrom a list containing the two specified objects.- Returns:
- The new Alternator, or
nullif arguments were illegal.
-
make
public Alternator make(boolean auto, java.lang.Object o1, java.lang.Object o2)
Deprecated.Useauto(Object o1, Object o2)ormanual(Object o1, Object o2)instead.
-
auto
public Alternator auto(java.util.List list)
Make an automaticAlternatorfrom values in the specified List.- Returns:
- a new, automatic Alternator with the values in the List or
nullif the List isnull. - Since:
- VelocityTools 1.3
-
auto
public Alternator auto(java.lang.Object[] array)
Make an automaticAlternatorfrom the specified object array.- Returns:
- a new, automatic Alternator with the values in the array or
nullif the array isnull. - Since:
- VelocityTools 1.3
-
auto
public Alternator auto(java.lang.Object o1, java.lang.Object o2)
Make an automaticAlternatorfrom a list containing the two specified objects.- Parameters:
o1- The first of two objects for alternation between. Must be non-null.o2- The second of two objects for alternation between. Must be non-null.- Returns:
- The new Alternator, or
nullif an argument wasnull. - Since:
- VelocityTools 1.3
-
manual
public Alternator manual(java.util.List list)
Make a manualAlternatorfrom values in the specified List.- Returns:
- a new, manual Alternator with the values in the List or
nullif the List isnull. - Since:
- VelocityTools 1.3
-
manual
public Alternator manual(java.lang.Object[] array)
Make a manualAlternatorfrom the specified object array.- Returns:
- a new, manual Alternator with the values in the array or
nullif the array isnull. - Since:
- VelocityTools 1.3
-
manual
public Alternator manual(java.lang.Object o1, java.lang.Object o2)
Make a manualAlternatorfrom a list containing the two specified objects.- Parameters:
o1- The first of two objects for alternation between. Must be non-null.o2- The second of two objects for alternation between. Must be non-null.- Returns:
- The new Alternator, or
nullif an argument wasnull. - Since:
- VelocityTools 1.3
-
-