类 AlternatorTool

java.lang.Object
org.apache.velocity.tools.generic.SafeConfig
org.apache.velocity.tools.generic.AlternatorTool
所有已实现的接口:
Serializable

@ValidScope("application") @DefaultKey("alternator") @Deprecated public class AlternatorTool extends SafeConfig implements Serializable
已过时。
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.
 
从以下版本开始:
Velocity Tools 1.2
版本:
$Revision$ $Date$
另请参阅:
  • 字段详细资料

    • AUTO_ALTERNATE_DEFAULT_KEY

      public static final String AUTO_ALTERNATE_DEFAULT_KEY
      已过时。
      另请参阅:
  • 构造器详细资料

    • AlternatorTool

      public AlternatorTool()
      已过时。
  • 方法详细资料

    • configure

      protected void configure(ValueParser parser)
      已过时。
      Looks for a default auto-alternate value in the given params, if not, set the default to true.
      覆盖:
      configure 在类中 SafeConfig
      参数:
      parser - configuration values
    • getAutoAlternateDefault

      public boolean getAutoAlternateDefault()
      已过时。
      Returns true if the default for auto-alternating is true.
      返回:
      flag value
      从以下版本开始:
      VelocityTools 1.3
    • setAutoAlternateDefault

      protected void setAutoAlternateDefault(boolean bool)
      已过时。
      Sets the default for auto-alternating.
      参数:
      bool - flag value
      从以下版本开始:
      VelocityTools 1.3
    • make

      public Alternator make(Object... list)
      已过时。
      Make an automatic Alternator from the specifed objects.
      参数:
      list - values to alternate over
      返回:
      alternator
    • make

      public Alternator make(boolean auto, Object... list)
      已过时。
      Returns a new Alternator for the specified list with the specified automatic shifting preference.
      参数:
      auto - See Alternator.setAuto(boolean auto).
      list - The list of elements to alternate.
      返回:
      alternator
    • auto

      public Alternator auto(Object... list)
      已过时。
      Make an automatic Alternator from the specified objects.
      参数:
      list - objects to alternate over
      返回:
      a new, automatic Alternator with the specified values or null if there are none specified.
      从以下版本开始:
      VelocityTools 1.3
    • manual

      public Alternator manual(Object... list)
      已过时。
      Make a manual Alternator from the specified objects.
      参数:
      list - objects to alternate over
      返回:
      a new, manual Alternator with the values in the array or null if the array is null.
      从以下版本开始:
      VelocityTools 1.3