myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r956992 - in /myfaces/extensions/cdi/trunk/jse-modules/message-module: api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/ impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/ impl/src/test/java/org/apache/myfaces...
Date Tue, 22 Jun 2010 19:34:22 GMT
Author: gpetracek
Date: Tue Jun 22 19:34:21 2010
New Revision: 956992

URL: http://svn.apache.org/viewvc?rev=956992&view=rev
Log:
EXTCDI-21 cleanup

Modified:
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/NamedArgument.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NamedArguments.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ArgumentDescriptorTest.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestArgument.java
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_de.properties
    myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_en.properties

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java?rev=956992&r1=956991&r2=956992&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/MessageInterpolator.java
Tue Jun 22 19:34:21 2010
@@ -34,7 +34,7 @@ public interface MessageInterpolator ext
      * @param messageText the message text which has to be interpolated
      * @param arguments a list of numbered and/or named arguments for the current message
      * @return the final (interpolated) message text
-     *         if it was possible to replace the parameters with the given attributes
+     *         if it was possible to replace the parameters with the given arguments
      *         the unmodified messageText otherwise
      */
     String interpolate(MessageContext messageContext, String messageText, Serializable...
arguments);

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/NamedArgument.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/NamedArgument.java?rev=956992&r1=956991&r2=956992&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/NamedArgument.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/api/src/main/java/org/apache/myfaces/extensions/cdi/message/api/NamedArgument.java
Tue Jun 22 19:34:21 2010
@@ -21,7 +21,7 @@ package org.apache.myfaces.extensions.cd
 import java.io.Serializable;
 
 /**
- * to allow a simpler interface for adding attributes.
+ * to allow a simpler interface for adding arguments.
  * furthermore, it allows message with mixed (numbered and named) arguments
  * 
  * @author Gerhard Petracek

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java?rev=956992&r1=956991&r2=956992&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/DefaultMessageBuilder.java
Tue Jun 22 19:34:21 2010
@@ -232,7 +232,7 @@ class DefaultMessageBuilder implements M
             return checkedResult(
                     interpolateMessage(messageInterpolator,
                                        message,
-                                       tryToRestoreLazyArguments(baseMessage, this.messageContext)),
+                                       restoreArguments(baseMessage, this.messageContext)),
                     baseMessage);
         }
 
@@ -315,13 +315,13 @@ class DefaultMessageBuilder implements M
     }
 
     //see javadoc of {@link ArgumentDescriptor} for more details
-    private Serializable[] tryToRestoreLazyArguments(Message baseMessage, MessageContext
messageContext)
+    private Serializable[] restoreArguments(Message baseMessage, MessageContext messageContext)
     {
-        if (messageContext == null)
+        if (messageContext == null || baseMessage.getArguments() == null)
         {
             return baseMessage.getArguments();
         }
-        List<Serializable> result = new ArrayList<Serializable>();
+        List<Serializable> result = new ArrayList<Serializable>(baseMessage.getArguments().length);
 
         for (Serializable argument : baseMessage.getArguments())
         {

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NamedArguments.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NamedArguments.java?rev=956992&r1=956991&r2=956992&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NamedArguments.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/message/impl/NamedArguments.java
Tue Jun 22 19:34:21 2010
@@ -40,15 +40,15 @@ public class NamedArguments
     {
     }
 
-    public static Serializable[] convert(Map<String, Serializable> attributes)
+    public static Serializable[] convert(Map<String, Serializable> arguments)
     {
-        if (attributes == null || attributes.size() == 0)
+        if (arguments == null || arguments.size() == 0)
         {
             return new Serializable[]{};
         }
 
         NamedArguments.NamedArgumentBuilder namedArgumentBuilder = new NamedArguments().getNamedArgumentBuilder();
-        for (Map.Entry<String, Serializable> entry : attributes.entrySet())
+        for (Map.Entry<String, Serializable> entry : arguments.entrySet())
         {
             namedArgumentBuilder = namedArgumentBuilder.add(entry.getKey(), entry.getValue());
         }

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ArgumentDescriptorTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ArgumentDescriptorTest.java?rev=956992&r1=956991&r2=956992&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ArgumentDescriptorTest.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/ArgumentDescriptorTest.java
Tue Jun 22 19:34:21 2010
@@ -29,11 +29,11 @@ import org.junit.Test;
 public class ArgumentDescriptorTest extends AbstractTest
 {
     @Test
-    public void lazyNumberedAttributeTest()
+    public void lazyNumberedArgumentsTest()
     {
-        TestArgument dynArgument = new TestArgument("brand");
+        TestArgument dynArgument = new TestArgument("brand_key");
 
-        assertEquals("{brand}", dynArgument.getKey());
+        assertEquals("{brand_key}", dynArgument.getKey());
 
         String messageText = this.messageContext.config().use().messageInterpolator(new NumberedArgumentAwareMessageInterpolator()).create()
                 .message().text("{info}").argument(dynArgument.getKey()).toText();
@@ -43,11 +43,11 @@ public class ArgumentDescriptorTest exte
     }
 
     @Test
-    public void lazyNamedAttributeTest()
+    public void lazyNamedArgumentsTest()
     {
-        TestArgument dynArgument = new TestArgument("brand");
+        TestArgument dynArgument = new TestArgument("brand_key");
 
-        assertEquals("{brand}", dynArgument.getKey());
+        assertEquals("{brand_key}", dynArgument.getKey());
 
         String messageText = this.messageContext.config().use().messageInterpolator(new ELAwareMessageInterpolator(new
TestELProvider())).create()
                 .message().text("{brand_info}").namedArgument("brand", dynArgument.getKey()).toText();
@@ -55,4 +55,46 @@ public class ArgumentDescriptorTest exte
         assertEquals("jCar", dynArgument.toString(this.messageContext));
         assertEquals("value: jCar", messageText);
     }
+
+    @Test
+    public void normalTextAsNumberedArgumentsTest()
+    {
+        TestArgument dynArgument = new TestArgument("brand-value") {
+            private static final long serialVersionUID = -5398006578422304127L;
+
+            @Override
+            public String getKey()
+            {
+                return this.key;
+            }
+        };
+
+        assertEquals("brand-value", dynArgument.getKey());
+
+        String messageText = this.messageContext.config().use().messageInterpolator(new NumberedArgumentAwareMessageInterpolator()).create()
+                .message().text("{info}").argument(dynArgument.getKey()).toText();
+
+        assertEquals("value: brand-value", messageText);
+    }
+
+    @Test
+    public void normalTextAsNamedArgumentsTest()
+    {
+        TestArgument dynArgument = new TestArgument("brand-value") {
+            private static final long serialVersionUID = -5398006578422304127L;
+
+            @Override
+            public String getKey()
+            {
+                return this.key;
+            }
+        };
+
+        assertEquals("brand-value", dynArgument.getKey());
+
+        String messageText = this.messageContext.config().use().messageInterpolator(new ELAwareMessageInterpolator(new
TestELProvider())).create()
+                .message().text("{brand_info}").namedArgument("brand", dynArgument.getKey()).toText();
+
+        assertEquals("value: brand-value", messageText);
+    }
 }
\ No newline at end of file

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestArgument.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestArgument.java?rev=956992&r1=956991&r2=956992&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestArgument.java
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/TestArgument.java
Tue Jun 22 19:34:21 2010
@@ -29,7 +29,7 @@ import java.io.Serializable;
 class TestArgument implements Localizable, Serializable
 {
     private static final long serialVersionUID = -4503818588255027507L;
-    private String key;
+    protected String key;
 
     TestArgument(String key)
     {

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_de.properties
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_de.properties?rev=956992&r1=956991&r2=956992&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_de.properties
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_de.properties
Tue Jun 22 19:34:21 2010
@@ -2,4 +2,5 @@ hello=Test Nachricht
 formatted_number=value: {0}
 info=value: {0}
 brand_info=value: {brand}
-brand=jCar
\ No newline at end of file
+brand=jCar
+brand_key=jCar
\ No newline at end of file

Modified: myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_en.properties
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_en.properties?rev=956992&r1=956991&r2=956992&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_en.properties
(original)
+++ myfaces/extensions/cdi/trunk/jse-modules/message-module/impl/src/test/java/org/apache/myfaces/extensions/cdi/message/test/messages_en.properties
Tue Jun 22 19:34:21 2010
@@ -2,4 +2,5 @@ hello=test message
 formatted_number=value: {0}
 info=value: {0}
 brand_info=value: {brand}
-brand=jCar
\ No newline at end of file
+brand=jCar
+brand_key=jCar
\ No newline at end of file



Mime
View raw message