@ValidScope(value="application") @DefaultKey(value="alternator") @Deprecated public class AlternatorTool extends SafeConfig implements Serializable
Alternators from varying "list" types or individual
arguments.
Example Use:
tools.xml...
<tools>
<toolbox scope="application">
<tool class="org.apache.velocity.tools.generic.AlternatorTool"/>
</toolbox>
</tools>
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.
| Modifier and Type | Field and Description |
|---|---|
static String |
AUTO_ALTERNATE_DEFAULT_KEY
Deprecated.
|
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY| Constructor and Description |
|---|
AlternatorTool()
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
Alternator |
auto(Object... list)
Deprecated.
Make an automatic
Alternator from the specified objects. |
protected void |
configure(ValueParser parser)
Deprecated.
Looks for a default auto-alternate value in the given params,
if not, set the default to true.
|
boolean |
getAutoAlternateDefault()
Deprecated.
Returns true if the default for auto-alternating is true.
|
Alternator |
make(boolean auto,
Object... list)
Deprecated.
Returns a new Alternator for the specified list with the specified
automatic shifting preference.
|
Alternator |
make(Object... list)
Deprecated.
Make an automatic
Alternator from the specifed objects. |
Alternator |
manual(Object... list)
Deprecated.
Make a manual
Alternator from the specified objects. |
protected void |
setAutoAlternateDefault(boolean bool)
Deprecated.
Sets the default for auto-alternating.
|
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeModepublic static final String AUTO_ALTERNATE_DEFAULT_KEY
protected void configure(ValueParser parser)
configure in class SafeConfigparser - configuration valuespublic boolean getAutoAlternateDefault()
protected void setAutoAlternateDefault(boolean bool)
bool - flag valuepublic Alternator make(Object... list)
Alternator from the specifed objects.list - values to alternate overpublic Alternator make(boolean auto, Object... list)
auto - See Alternator.setAuto(boolean auto).list - The list of elements to alternate.public Alternator auto(Object... list)
Alternator from the specified objects.list - objects to alternate overnull if there are none specified.public Alternator manual(Object... list)
Alternator from the specified objects.list - objects to alternate overnull if the array is null.Copyright © 2002–2021 The Apache Software Foundation. All rights reserved.