|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.velocity.tools.generic.AlternatorTool
public class AlternatorTool
Simple tool to provide easy in-template instantiation of
Alternator
s 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.
Field Summary | |
---|---|
static java.lang.String |
AUTO_ALTERNATE_DEFAULT_KEY
|
private boolean |
autoAlternateDefault
|
Constructor Summary | |
---|---|
AlternatorTool()
|
Method Summary | |
---|---|
Alternator |
auto(java.util.List list)
Make an automatic Alternator from values in the specified List. |
Alternator |
auto(java.lang.Object[] array)
Make an automatic Alternator from the specified object array. |
Alternator |
auto(java.lang.Object o1,
java.lang.Object o2)
Make an automatic Alternator from a list containing the two
specified objects. |
void |
configure(java.util.Map params)
Looks for a default auto-alternate value in the given params, if not, set the default to true. |
boolean |
getAutoAlternateDefault()
Returns true if the default for auto-alternating is true. |
Alternator |
make(boolean auto,
java.util.List list)
Deprecated. Use auto(List list) or
manual(List list) instead. |
Alternator |
make(boolean auto,
java.lang.Object[] array)
Deprecated. Use auto(Object[] array) or
manual(Object[] array) instead. |
Alternator |
make(boolean auto,
java.lang.Object o1,
java.lang.Object o2)
Deprecated. Use auto(Object o1, Object o2) or
manual(Object o1, Object o2) instead. |
Alternator |
make(java.util.List list)
Make an automatic Alternator from a List. |
Alternator |
make(java.lang.Object[] array)
Make an automatic Alternator from an object array. |
Alternator |
make(java.lang.Object o1,
java.lang.Object o2)
Make an automatic Alternator from a list containing the two
specified objects. |
Alternator |
manual(java.util.List list)
Make a manual Alternator from values in the specified List. |
Alternator |
manual(java.lang.Object[] array)
Make a manual Alternator from the specified object array. |
Alternator |
manual(java.lang.Object o1,
java.lang.Object o2)
Make a manual Alternator from a list containing the two
specified objects. |
protected void |
setAutoAlternateDefault(boolean bool)
Sets the default for auto-alternating. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String AUTO_ALTERNATE_DEFAULT_KEY
private boolean autoAlternateDefault
Constructor Detail |
---|
public AlternatorTool()
Method Detail |
---|
public void configure(java.util.Map params)
public boolean getAutoAlternateDefault()
protected void setAutoAlternateDefault(boolean bool)
public Alternator make(java.util.List list)
Alternator
from a List.
public Alternator make(boolean auto, java.util.List list)
auto(List list)
or
manual(List list)
instead.
public Alternator make(java.lang.Object[] array)
Alternator
from an object array.
public Alternator make(boolean auto, java.lang.Object[] array)
auto(Object[] array)
or
manual(Object[] array)
instead.
public Alternator make(java.lang.Object o1, java.lang.Object o2)
Alternator
from a list containing the two
specified objects.
null
if arguments
were illegal.public Alternator make(boolean auto, java.lang.Object o1, java.lang.Object o2)
auto(Object o1, Object o2)
or
manual(Object o1, Object o2)
instead.
public Alternator auto(java.util.List list)
Alternator
from values in the specified List.
null
if the List is null
.public Alternator auto(java.lang.Object[] array)
Alternator
from the specified object array.
null
if the array is null
.public Alternator auto(java.lang.Object o1, java.lang.Object o2)
Alternator
from a list containing the two
specified objects.
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
.
null
if an argument
was null
.public Alternator manual(java.util.List list)
Alternator
from values in the specified List.
null
if the List is null
.public Alternator manual(java.lang.Object[] array)
Alternator
from the specified object array.
null
if the array is null
.public Alternator manual(java.lang.Object o1, java.lang.Object o2)
Alternator
from a list containing the two
specified objects.
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
.
null
if an argument
was null
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |