click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r929149 - in /click/trunk/click: documentation/docs/ framework/src/org/apache/click/ framework/src/org/apache/click/control/ framework/test/org/apache/click/ framework/test/org/apache/click/control/
Date Tue, 30 Mar 2010 14:15:08 GMT
Author: sabob
Date: Tue Mar 30 14:15:08 2010
New Revision: 929149

URL: http://svn.apache.org/viewvc?rev=929149&view=rev
Log:
replaced page and control getmessage methods with varargs. CLK-604

Modified:
    click/trunk/click/documentation/docs/roadmap-changes.html
    click/trunk/click/framework/src/org/apache/click/Page.java
    click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java
    click/trunk/click/framework/test/org/apache/click/PageTest.java
    click/trunk/click/framework/test/org/apache/click/control/ControlTest.java

Modified: click/trunk/click/documentation/docs/roadmap-changes.html
URL: http://svn.apache.org/viewvc/click/trunk/click/documentation/docs/roadmap-changes.html?rev=929149&r1=929148&r2=929149&view=diff
==============================================================================
--- click/trunk/click/documentation/docs/roadmap-changes.html (original)
+++ click/trunk/click/documentation/docs/roadmap-changes.html Tue Mar 30 14:15:08 2010
@@ -192,6 +192,10 @@ includes improved Ajax support and @Bind
         [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-585">CLK-585</a>].
       </li>
       <li class="change">
+        Replaced Page and Control getMessage methods with varargs equivalents
+        [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-604">CLK-604</a>].
+      </li>
+      <li class="change">
         Removed Click core's dependency on Velocity. This issue was raised by by Andrey Rybin
         [<a target="_blank" href="https://issues.apache.org/jira/browse/CLK-606">CLK-606</a>].
       </li>

Modified: click/trunk/click/framework/src/org/apache/click/Page.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/Page.java?rev=929149&r1=929148&r2=929149&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/Page.java (original)
+++ click/trunk/click/framework/src/org/apache/click/Page.java Tue Mar 30 14:15:08 2010
@@ -826,24 +826,6 @@ public class Page implements Serializabl
     }
 
     /**
-     * Return the formatted page message for the given resource name
-     * and message format argument or null if no message was found. The resource
-     * message returned will use the Locale obtained from the Context.
-     * <p/>
-     * {@link #getMessage(java.lang.String, java.lang.Object[])} is invoked to
-     * retrieve the message for the specified name.
-     *
-     * @param name resource name of the message
-     * @param arg the message argument to format
-     * @return the named localized message for the page or null if no message
-     * was found
-     */
-    public String getMessage(String name, Object arg) {
-        Object[] args = new Object[] { arg };
-        return getMessage(name, args);
-    }
-
-    /**
      * Return the formatted page message for the given resource name and
      * message format arguments or null if no message was found. The resource
      * message returned will use the Locale obtained from the Context.
@@ -856,7 +838,7 @@ public class Page implements Serializabl
      * @return the named localized message for the page or null if no message
      * was found
      */
-    public String getMessage(String name, Object[] args) {
+    public String getMessage(String name, Object... args) {
         String value = getMessage(name);
 
         return MessageFormat.format(value, args);

Modified: click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java?rev=929149&r1=929148&r2=929149&view=diff
==============================================================================
--- click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java (original)
+++ click/trunk/click/framework/src/org/apache/click/control/AbstractControl.java Tue Mar
30 14:15:08 2010
@@ -403,24 +403,6 @@ public abstract class AbstractControl im
 
     /**
      * Return the formatted message for the given resource name and message
-     * format argument or null if no message was found. The resource message
-     * returned will use the Locale obtained from the Context.
-     * <p/>
-     * {@link #getMessage(java.lang.String, java.lang.Object[])} is invoked to
-     * retrieve the message for the specified name.
-     *
-     * @param name resource name of the message
-     * @param arg the message argument to format
-     * @return the named localized message for the control or null if no message
-     * was found
-     */
-    public String getMessage(String name, Object arg) {
-        Object[] args = new Object[] { arg };
-        return getMessage(name, args);
-    }
-
-    /**
-     * Return the formatted message for the given resource name and message
      * format arguments or null if no message was found. The resource
      * message returned will use the Locale obtained from the Context.
      * <p/>
@@ -432,7 +414,7 @@ public abstract class AbstractControl im
      * @return the named localized message for the control or null if no message
      * was found
      */
-    public String getMessage(String name, Object[] args) {
+    public String getMessage(String name, Object... args) {
         String value = getMessage(name);
         if (value == null) {
             return null;

Modified: click/trunk/click/framework/test/org/apache/click/PageTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/PageTest.java?rev=929149&r1=929148&r2=929149&view=diff
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/PageTest.java (original)
+++ click/trunk/click/framework/test/org/apache/click/PageTest.java Tue Mar 30 14:15:08 2010
@@ -139,4 +139,31 @@ public class PageTest extends TestCase {
 
         container.stop();
     }
+
+    /**
+     * Test getMessage variations.
+     */
+    public void testGetMessage() {
+        MockContext.initContext();
+
+        String expected = "Version 0.21";
+
+        Page page = new Page();
+        String version = page.getMessage("version");
+        assertEquals(expected, version);
+
+        version = page.getMessage("version", "arg");
+        assertEquals(expected, version);
+
+        version = page.getMessage("version", "arg1", "arg2");
+        assertEquals(expected, version);
+
+        version = page.getMessage("version", (String) null);
+        assertEquals(expected, version);
+
+        Object args[] = new Object[1];
+        args[0] = null;
+        version = page.getMessage("version", args);
+        assertEquals(expected, version);
+    }
 }

Modified: click/trunk/click/framework/test/org/apache/click/control/ControlTest.java
URL: http://svn.apache.org/viewvc/click/trunk/click/framework/test/org/apache/click/control/ControlTest.java?rev=929149&r1=929148&r2=929149&view=diff
==============================================================================
--- click/trunk/click/framework/test/org/apache/click/control/ControlTest.java (original)
+++ click/trunk/click/framework/test/org/apache/click/control/ControlTest.java Tue Mar 30
14:15:08 2010
@@ -18,9 +18,11 @@
  */
 package org.apache.click.control;
 
+import com.sun.java_cup.internal.version;
 import junit.framework.Assert;
 import junit.framework.TestCase;
 import org.apache.click.MockContext;
+import org.apache.click.Page;
 
 /**
  * Miscellaneous Control tests.
@@ -107,4 +109,35 @@ public class ControlTest extends TestCas
             Assert.assertTrue(true);
         }
     }
+
+    /**
+     * Test getMessage variations.
+     */
+    public void testGetMessage() {
+        MockContext.initContext();
+
+        String expected = "Version 0.21";
+
+        Page page = new Page();
+        Field field = new TextField("field");
+        page.addControl(field);
+
+        String version = field.getMessage("version");
+        System.out.println("V " + version);
+        assertEquals(expected, version);
+
+        version = field.getMessage("version", "arg");
+        assertEquals(expected, version);
+
+        version = field.getMessage("version", "arg1", "arg2");
+        assertEquals(expected, version);
+
+        version = field.getMessage("version", (String) null);
+        assertEquals(expected, version);
+
+        Object args[] = new Object[1];
+        args[0] = null;
+        version = field.getMessage("version", args);
+        assertEquals(expected, version);
+    }
 }
\ No newline at end of file



Mime
View raw message