You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by mi...@apache.org on 2005/08/13 00:24:53 UTC

cvs commit: jakarta-tapestry/framework/src/java/org/apache/tapestry/coerce IteratorToListConverter.java

mindbridge    2005/08/12 15:24:53

  Modified:    framework/src/descriptor/META-INF tapestry.coerce.xml
  Added:       framework/src/java/org/apache/tapestry/coerce
                        IteratorToListConverter.java
  Log:
  One more List converter, this time for iterators.
  Not needed, but adding it just for completeness.
  Maybe the whole coercion process can be performed by a specialized framework.
  
  Revision  Changes    Path
  1.9       +1 -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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- tapestry.coerce.xml	12 Aug 2005 04:48:20 -0000	1.8
  +++ tapestry.coerce.xml	12 Aug 2005 22:24:53 -0000	1.9
  @@ -87,6 +87,7 @@
     <contribution configuration-id="ListConverters">
       <converter class="java.lang.Object" object="instance:ObjectToListConverter"/>
       <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="char[]" object="instance:CharArrayToListConverter"/>
       <converter class="boolean[]" object="instance:BooleanArrayToListConverter"/>    
  
  
  
  1.1                  jakarta-tapestry/framework/src/java/org/apache/tapestry/coerce/IteratorToListConverter.java
  
  Index: IteratorToListConverter.java
  ===================================================================
  // Copyright 2004, 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.Iterator;
  import java.util.List;
  
  /**
   * @author Mindbridge
   * @since 4.0
   */
  public class IteratorToListConverter implements TypeConverter
  {
  
      public Object convertValue(Object value)
      {
          Iterator it = (Iterator) value;
          List list = new ArrayList();
          while (it.hasNext())
          	list.add(it.next());
          return list;
      }
  
  }
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-dev-help@jakarta.apache.org