Class AlternatorTool
java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.AlternatorTool
- All Implemented Interfaces:
Serializable
@ValidScope("application")
@DefaultKey("alternator")
@Deprecated
public class AlternatorTool
extends SafeConfig
implements Serializable
Deprecated.
use CSS3 nth-child(even/odd) selectors or #if($foreach.index % 2)
Simple tool to provide easy in-template instantiation of
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.
- Since:
- Velocity Tools 1.2
- Version:
- $Revision$ $Date$
- See Also:
-
Field Summary
FieldsFields inherited from class SafeConfig
LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Make an automaticAlternatorfrom the specified objects.protected voidconfigure(ValueParser parser) Deprecated.Looks for a default auto-alternate value in the given params, if not, set the default to true.booleanDeprecated.Returns true if the default for auto-alternating is true.Deprecated.Returns a new Alternator for the specified list with the specified automatic shifting preference.Deprecated.Make an automaticAlternatorfrom the specifed objects.Deprecated.Make a manualAlternatorfrom the specified objects.protected voidsetAutoAlternateDefault(boolean bool) Deprecated.Sets the default for auto-alternating.Methods inherited from class SafeConfig
configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode
-
Field Details
-
AUTO_ALTERNATE_DEFAULT_KEY
-
-
Constructor Details
-
AlternatorTool
public AlternatorTool()Deprecated.
-
-
Method Details
-
configure
Deprecated.Looks for a default auto-alternate value in the given params, if not, set the default to true.- Overrides:
configurein classSafeConfig- Parameters:
parser- configuration values
-
getAutoAlternateDefault
public boolean getAutoAlternateDefault()Deprecated.Returns true if the default for auto-alternating is true.- Returns:
- flag value
- Since:
- VelocityTools 1.3
-
setAutoAlternateDefault
protected void setAutoAlternateDefault(boolean bool) Deprecated.Sets the default for auto-alternating.- Parameters:
bool- flag value- Since:
- VelocityTools 1.3
-
make
Deprecated.Make an automaticAlternatorfrom the specifed objects.- Parameters:
list- values to alternate over- Returns:
- alternator
-
make
Deprecated.Returns a new Alternator for the specified list with the specified automatic shifting preference.- Parameters:
auto- SeeAlternator.setAuto(boolean auto).list- The list of elements to alternate.- Returns:
- alternator
-
auto
Deprecated.Make an automaticAlternatorfrom the specified objects.- Parameters:
list- objects to alternate over- Returns:
- a new, automatic Alternator with the specified values or
nullif there are none specified. - Since:
- VelocityTools 1.3
-
manual
Deprecated.Make a manualAlternatorfrom the specified objects.- Parameters:
list- objects to alternate over- Returns:
- a new, manual Alternator with the values in the array or
nullif the array isnull. - Since:
- VelocityTools 1.3
-