hlship      2005/07/21 08:43:35

  Modified:    .        status.xml
               framework/src/test/org/apache/tapestry/coerce
                        TestBooleanConverters.java
               framework/src/descriptor/META-INF tapestry.coerce.xml
  Added:       framework/src/test/org/apache/tapestry/coerce TestMisc.java
               framework/src/java/org/apache/tapestry/coerce
                        CharArrayToIteratorConverter.java
                        BooleanArrayToIteratorConverter.java
  Log:
  TAPESTRY-425: Foreach components cannot handle primitive arrays
  
  Revision  Changes    Path
  1.168     +1 -0      jakarta-tapestry/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tapestry/status.xml,v
  retrieving revision 1.167
  retrieving revision 1.168
  diff -u -r1.167 -r1.168
  --- status.xml        21 Jul 2005 13:56:17 -0000      1.167
  +++ status.xml        21 Jul 2005 15:43:35 -0000      1.168
  @@ -61,6 +61,7 @@
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-427">InspectorButton 
ignores its disabled parameter</action>
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-383, 
TAPESTRY-224">Properly position cursor into form fields</action>
         <action type="fix" dev="HLS" due-to="Kent Tong" 
fixes-bug="TAPESTRY-406">Bean Property does not get updated from component 
parameter</action>
  +      <action type="fix" dev="HLS" due-to="Laurent Etiemble" 
fixes-bug="TAPESTRY-425">Foreach components cannot handle primitive 
arrays</action>
       </release>
       <release version="4.0-beta-2" date="Jul 9 2005">
         <action type="fix" dev="HLS" fixes-bug="TAPESTRY-356">FormConditional 
extends BaseComponent but has no template</action>
  
  
  
  1.4       +21 -0     
jakarta-tapestry/framework/src/test/org/apache/tapestry/coerce/TestBooleanConverters.java
  
  Index: TestBooleanConverters.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/test/org/apache/tapestry/coerce/TestBooleanConverters.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestBooleanConverters.java        18 Apr 2005 17:07:53 -0000      1.3
  +++ TestBooleanConverters.java        21 Jul 2005 15:43:35 -0000      1.4
  @@ -16,6 +16,7 @@
   
   import java.util.ArrayList;
   import java.util.HashMap;
  +import java.util.Iterator;
   import java.util.List;
   import java.util.Map;
   
  @@ -92,4 +93,24 @@
           assertSame(Boolean.TRUE, c.convertValue("foo"));
       }
   
  +    public void testBooleanArrayToIterator()
  +    {
  +        TypeConverter c = new BooleanArrayToIteratorConverter();
  +
  +        boolean[] input =
  +        { false, true, true, false };
  +
  +        Iterator i = (Iterator) c.convertValue(input);
  +
  +        for (int j = 0; j < input.length; j++)
  +        {
  +            Boolean expected = input[j] ? Boolean.TRUE : Boolean.FALSE;
  +
  +            assertSame(expected, i.next());
  +        }
  +
  +        assertEquals(false, i.hasNext());
  +
  +    }
  +
   }
  \ No newline at end of file
  
  
  
  1.1                  
jakarta-tapestry/framework/src/test/org/apache/tapestry/coerce/TestMisc.java
  
  Index: TestMisc.java
  ===================================================================
  // Copyright 2005 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.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.coerce;
  
  import java.util.Iterator;
  
  import org.apache.hivemind.test.HiveMindTestCase;
  
  /**
   * Tests for random, simple converters.
   * 
   * @author Howard Lewis Ship
   * @since 4.0
   */
  public class TestMisc extends HiveMindTestCase
  {
      public void testCharArrayToIteratorConverter()
      {
          char[] characters = "Good Morning, Tapestry!".toCharArray();
  
          CharArrayToIteratorConverter c = new CharArrayToIteratorConverter();
  
          Iterator i = (Iterator) c.convertValue(characters);
  
          for (int j = 0; j < characters.length; j++)
          {
              Character expected = new Character(characters[j]);
              assertEquals(expected, i.next());
          }
          
          assertEquals(false, i.hasNext());
      }
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/java/org/apache/tapestry/coerce/CharArrayToIteratorConverter.java
  
  Index: CharArrayToIteratorConverter.java
  ===================================================================
  // Copyright 2005 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.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.coerce;
  
  import java.util.ArrayList;
  import java.util.List;
  
  /**
   * @author Laurent ETIEMBLE, Howard M. Lewis Ship
   * @since 4.0
   */
  public class CharArrayToIteratorConverter implements TypeConverter
  {
      public Object convertValue(Object value)
      {
          char[] characters = (char[]) value;
  
          List list = new ArrayList(characters.length);
  
          for (int i = 0; i < characters.length; i++)
          {
              list.add(new Character(characters[i]));
          }
  
          return list.iterator();
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/java/org/apache/tapestry/coerce/BooleanArrayToIteratorConverter.java
  
  Index: BooleanArrayToIteratorConverter.java
  ===================================================================
  // Copyright 2005 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.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.tapestry.coerce;
  
  import java.util.ArrayList;
  import java.util.List;
  
  import org.apache.tapestry.coerce.TypeConverter;
  
  /**
   * Converts primitive arrays of booleans to a Iterator (of a List of ) 
Boolean.
   * 
   * @author Laurent ETIEMBLE, Howard M. Lewis Ship
   * @since 4.0
   */
  public class BooleanArrayToIteratorConverter implements TypeConverter
  {
  
      public Object convertValue(Object value)
      {
          boolean[] booleans = (boolean[]) value;
  
          List list = new ArrayList(booleans.length);
  
          for (int i = 0; i < booleans.length; i++)
          {
              boolean b = booleans[i];
  
              list.add(b ? Boolean.TRUE : Boolean.FALSE);
          }
  
          return list.iterator();
      }
  
  }
  
  
  
  1.7       +2 -0      
jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.coerce.xml
  
  Index: tapestry.coerce.xml
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tapestry/framework/src/descriptor/META-INF/tapestry.coerce.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- tapestry.coerce.xml       11 May 2005 20:08:23 -0000      1.6
  +++ tapestry.coerce.xml       21 Jul 2005 15:43:35 -0000      1.7
  @@ -69,6 +69,8 @@
       <converter class="java.lang.Object" 
object="instance:ObjectToIteratorConverter"/>
       <converter class="java.util.Collection" 
object="instance:CollectionToIteratorConverter"/>
       <converter class="java.lang.Object[]" 
object="instance:ObjectArrayToIteratorConverter"/>
  +    <converter class="char[]" 
object="instance:CharArrayToIteratorConverter"/>
  +    <converter class="boolean[]" 
object="instance:BooleanArrayToIteratorConverter"/>    
     </contribution>
     
     <service-point id="IteratorConverter" interface="TypeConverter">
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to