tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r501129 - in /tapestry/tapestry5/tapestry-core/trunk/src: main/java/org/apache/tapestry/internal/model/ main/java/org/apache/tapestry/internal/services/ main/java/org/apache/tapestry/internal/structure/ main/java/org/apache/tapestry/model/ ...
Date Mon, 29 Jan 2007 17:53:19 GMT
Author: hlship
Date: Mon Jan 29 09:53:18 2007
New Revision: 501129

URL: http://svn.apache.org/viewvc?view=rev&rev=501129
Log:
Make parameters names case insensitive.

Modified:
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/model/MutableComponentModelImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/ComponentModel.java
    tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/MutableComponentModel.java
    tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/model/MutableComponentModelImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/model/MutableComponentModelImpl.java?view=diff&rev=501129&r1=501128&r2=501129
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/model/MutableComponentModelImpl.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/model/MutableComponentModelImpl.java
Mon Jan 29 09:53:18 2007
@@ -107,24 +107,26 @@
         notBlank(name, "name");
         notBlank(defaultBindingPrefix, "defaultBindingPrefix");
 
+        String caseless = name.toLowerCase();
+
         // TODO: Check for conflict with base model
 
         if (_parameters == null)
             _parameters = newMap();
         else
         {
-            if (_parameters.containsKey(name))
+            if (_parameters.containsKey(caseless))
                 throw new IllegalArgumentException(ModelMessages.duplicateParameter(
                         name,
                         _componentClassName));
         }
 
-        _parameters.put(name, new ParameterModelImpl(name, required, defaultBindingPrefix));
+        _parameters.put(caseless, new ParameterModelImpl(name, required, defaultBindingPrefix));
     }
 
     public ParameterModel getParameterModel(String parameterName)
     {
-        ParameterModel result = InternalUtils.get(_parameters, parameterName);
+        ParameterModel result = InternalUtils.get(_parameters, parameterName.toLowerCase());
 
         if (result == null && _parentModel != null)
             result = _parentModel.getParameterModel(parameterName);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java?view=diff&rev=501129&r1=501128&r2=501129
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/services/ParameterWorker.java
Mon Jan 29 09:53:18 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -245,7 +245,7 @@
 
         builder.end();
 
-        String methodName = transformation.newMemberName("_update_parameter_" + parameterName);
+        String methodName = transformation.newMemberName("update_parameter_" + parameterName);
 
         MethodSignature signature = new MethodSignature(Modifier.PRIVATE, "void", methodName,
                 new String[]
@@ -305,7 +305,7 @@
         builder.addln("return result;");
         builder.end();
 
-        String methodName = transformation.newMemberName("_read_parameter_" + parameterName);
+        String methodName = transformation.newMemberName("read_parameter_" + parameterName);
 
         MethodSignature signature = new MethodSignature(Modifier.PRIVATE, fieldType, methodName,
                 null, null);

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java?view=diff&rev=501129&r1=501128&r2=501129
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/internal/structure/InternalComponentResourcesImpl.java
Mon Jan 29 09:53:18 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -168,12 +168,10 @@
 
     public void addParameter(String parameterName, Binding binding)
     {
-        // TODO: Check for conflicts, etc.
-
         if (_bindings == null)
             _bindings = newMap();
 
-        _bindings.put(parameterName, binding);
+        _bindings.put(parameterName.toLowerCase(), binding);
     }
 
     @SuppressWarnings("unchecked")
@@ -181,12 +179,11 @@
     {
         Binding b = getBinding(parameterName);
 
-        // TODO: If binding is null ...
-
         try
         {
-            // Will throw NPE if binding is null, but this should never be called if binding
is
-            // null.
+            // Will throw NPE if binding is null, but this should never be called if the
+            // parameter is not bound.
+
             Object boundValue = b.get();
 
             return _typeCoercer.coerce(boundValue, expectedType);
@@ -212,8 +209,7 @@
     {
         Binding b = getBinding(parameterName);
 
-        // TODO: If binding is null ...
-
+    
         Class bindingType = b.getBindingType();
 
         try
@@ -233,7 +229,7 @@
 
     private Binding getBinding(String parameterName)
     {
-        return _bindings == null ? null : _bindings.get(parameterName);
+        return _bindings == null ? null : _bindings.get(parameterName.toLowerCase());
     }
 
     public Log getLog()

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/ComponentModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/ComponentModel.java?view=diff&rev=501129&r1=501128&r2=501129
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/ComponentModel.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/ComponentModel.java
Mon Jan 29 09:53:18 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -71,7 +71,12 @@
     /** Returns a list of the class names of mixins that are part of the component's implementation.
*/
     List<String> getMixinClassNames();
 
-    /** Return a single parameter model by parameter name, or null if the parameter is not
defined. */
+    /**
+     * Return a single parameter model by parameter name, or null if the parameter is not
defined.
+     * 
+     * @param parameterName
+     *            the name of the parameter (case is ignored)
+     */
     ParameterModel getParameterModel(String parameterName);
 
     /**

Modified: tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/MutableComponentModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/MutableComponentModel.java?view=diff&rev=501129&r1=501128&r2=501129
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/MutableComponentModel.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/main/java/org/apache/tapestry/model/MutableComponentModel.java
Mon Jan 29 09:53:18 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -25,7 +25,8 @@
 public interface MutableComponentModel extends ComponentModel
 {
     /**
-     * Adds a new formal parameter to the model.
+     * Adds a new formal parameter to the model. Each parameter has a unique name (though
access to
+     * parameters is case insensitive).
      * 
      * @param name
      *            new, unique name for the parameter

Modified: tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java?view=diff&rev=501129&r1=501128&r2=501129
==============================================================================
--- tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java
(original)
+++ tapestry/tapestry5/tapestry-core/trunk/src/test/java/org/apache/tapestry/internal/model/MutableComponentModelImplTest.java
Mon Jan 29 09:53:18 2007
@@ -1,4 +1,4 @@
-// Copyright 2006 The Apache Software Foundation
+// Copyright 2006, 2007 The Apache Software Foundation
 //
 // Licensed under the Apache License, Version 2.0 (the "License");
 // you may not use this file except in compliance with the License.
@@ -83,7 +83,9 @@
 
         model.addParameter("fred", true, "flint");
 
-        assertEquals(model.getParameterModel("fred").getDefaultBindingPrefix(), "flint");
+        // Checks that parameter names are case insensitive
+        
+        assertEquals(model.getParameterModel("Fred").getDefaultBindingPrefix(), "flint");
 
         verify();
     }
@@ -145,14 +147,16 @@
 
         try
         {
-            model.addParameter("fred", true, InternalConstants.PROP_BINDING_PREFIX);
+            // This also helps check that the comparison is caseless!
+            
+            model.addParameter("Fred", true, InternalConstants.PROP_BINDING_PREFIX);
             unreachable();
         }
         catch (IllegalArgumentException ex)
         {
             assertEquals(
                     ex.getMessage(),
-                    "Parameter 'fred' of component org.example.components.Foo is already
defined.");
+                    "Parameter 'Fred' of component org.example.components.Foo is already
defined.");
         }
 
         verify();



Mime
View raw message