mindbridge    2005/08/14 03:57:54

  Modified:    framework/src/descriptor/META-INF tapestry.coerce.xml
  Added:       framework/src/java/org/apache/tapestry/coerce
                        IntArrayToListConverter.java
                        IntArrayToIteratorConverter.java
  Log:
  Adding coercions for int[]
  
  PR: TAPESTRY-290
  
  Revision  Changes    Path
  1.1                  
jakarta-tapestry/framework/src/java/org/apache/tapestry/coerce/IntArrayToListConverter.java
  
  Index: IntArrayToListConverter.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 IntArrayToListConverter implements TypeConverter
  {
      public Object convertValue(Object value)
      {
          int[] values = (int[]) value;
  
          List list = new ArrayList(values.length);
  
          for (int i = 0; i < values.length; i++)
          {
              list.add(new Integer(values[i]));
          }
  
          return list;
      }
  
  }
  
  
  
  1.1                  
jakarta-tapestry/framework/src/java/org/apache/tapestry/coerce/IntArrayToIteratorConverter.java
  
  Index: IntArrayToIteratorConverter.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 IntArrayToIteratorConverter implements TypeConverter
  {
      public Object convertValue(Object value)
      {
          int[] values = (int[]) value;
  
          List list = new ArrayList(values.length);
  
          for (int i = 0; i < values.length; i++)
          {
              list.add(new Integer(values[i]));
          }
  
          return list.iterator();
      }
  
  }
  
  
  
  1.10      +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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- tapestry.coerce.xml       12 Aug 2005 22:24:53 -0000      1.9
  +++ tapestry.coerce.xml       14 Aug 2005 10:57:54 -0000      1.10
  @@ -69,6 +69,7 @@
       <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="int[]" object="instance:IntArrayToIteratorConverter"/>
       <converter class="char[]" 
object="instance:CharArrayToIteratorConverter"/>
       <converter class="boolean[]" 
object="instance:BooleanArrayToIteratorConverter"/>    
     </contribution>
  @@ -89,6 +90,7 @@
       <converter class="java.util.Collection" 
object="instance:CollectionToListConverter"/>
       <converter class="java.util.Iterator" 
object="instance:IteratorToListConverter"/>
       <converter class="java.lang.Object[]" 
object="instance:ObjectArrayToListConverter"/>
  +    <converter class="int[]" object="instance:IntArrayToListConverter"/>
       <converter class="char[]" object="instance:CharArrayToListConverter"/>
       <converter class="boolean[]" 
object="instance:BooleanArrayToListConverter"/>    
     </contribution>
  
  
  

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

Reply via email to