velocity-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nbu...@apache.org
Subject svn commit: r608697 - /velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
Date Fri, 04 Jan 2008 00:55:39 GMT
Author: nbubna
Date: Thu Jan  3 16:55:38 2008
New Revision: 608697

URL: http://svn.apache.org/viewvc?rev=608697&view=rev
Log:
update autoAlternate key and re-add some methods still necessary until Velocity 1.6 is out

Modified:
    velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java

Modified: velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
URL: http://svn.apache.org/viewvc/velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java?rev=608697&r1=608696&r2=608697&view=diff
==============================================================================
--- velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
(original)
+++ velocity/tools/trunk/src/main/java/org/apache/velocity/tools/generic/AlternatorTool.java
Thu Jan  3 16:55:38 2008
@@ -24,7 +24,8 @@
 
 /**
  * Simple tool to provide easy in-template instantiation of
- * {@link Alternator}s from varying "list" types.
+ * {@link Alternator}s from varying "list" types or individual
+ * arguments.
  *
  * <p><b>Example Use:</b>
  * <pre>
@@ -38,7 +39,7 @@
  * template...
  * #set( $color = $alternator.auto('red', 'blue') )
  * ## use manual alternation for this one
- * #set( $style = $alternator.manual(['hip','fly','groovy']) )
+ * #set( $style = $alternator.manual('hip','fly','groovy') )
  * #foreach( $i in [1..5] )
  *   Number $i is $color and $style. I dig $style.next numbers.
  * #end *
@@ -57,8 +58,10 @@
 @DefaultKey("alternator")
 public class AlternatorTool extends AbstractLockConfig
 {
-    /** @since VelocityTools 1.3 */
-    public static final String AUTO_ALTERNATE_DEFAULT_KEY = "auto-alternate";
+    @Deprecated
+    public static final String OLD_AUTO_ALTERNATE_DEFAULT_KEY = "auto-alternate";
+
+    public static final String AUTO_ALTERNATE_DEFAULT_KEY = "autoAlternate";
 
     // it's true by default in Alternator
     private boolean autoAlternateDefault = true;
@@ -69,9 +72,14 @@
      */
     protected void configure(ValueParser parser)
     {
-        // it's true by default in Alternator
-        autoAlternateDefault =
-            parser.getBoolean(AUTO_ALTERNATE_DEFAULT_KEY, true);
+        Boolean auto = parser.getBoolean(AUTO_ALTERNATE_DEFAULT_KEY);
+        if (auto == null)
+        {
+            // check for old key, use true as default (just like Alternator)
+            auto = parser.getBoolean(OLD_AUTO_ALTERNATE_DEFAULT_KEY,
+                                     Boolean.TRUE);
+        }
+        this.autoAlternateDefault = auto.booleanValue();
     }
 
     /**
@@ -101,6 +109,15 @@
     }
 
     /**
+     * @deprecated Will be unnecessary with Velocity 1.6
+     */
+    @Deprecated 
+    public Alternator make(Collection list)
+    {
+        return make(autoAlternateDefault, list);
+    }
+
+    /**
      * Returns a new Alternator for the specified list with the specified
      * automatic shifting preference.
      *
@@ -125,6 +142,15 @@
     /**
      * @deprecated Will be unnecessary with Velocity 1.6
      */
+    @Deprecated 
+    public Alternator make(boolean auto, Collection list)
+    {
+        return make(auto, new Object[] { list });
+    }
+
+    /**
+     * @deprecated Will be unnecessary with Velocity 1.6
+     */
     @Deprecated
     public Alternator make(Object o1, Object o2)
     {
@@ -160,6 +186,15 @@
      * @deprecated Will be unnecessary with Velocity 1.6
      */
     @Deprecated
+    public Alternator auto(Collection list)
+    {
+        return make(true, list);
+    }
+
+    /**
+     * @deprecated Will be unnecessary with Velocity 1.6
+     */
+    @Deprecated
     public Alternator auto(Object o1, Object o2)
     {
         return make(true, o1, o2);
@@ -173,6 +208,15 @@
      * @since VelocityTools 1.3
      */
     public Alternator manual(Object... list)
+    {
+        return make(false, list);
+    }
+
+    /**
+     * @deprecated Will be unnecessary with Velocity 1.6
+     */
+    @Deprecated
+    public Alternator manual(Collection list)
     {
         return make(false, list);
     }



Mime
View raw message