[jboss-cvs] jboss-seam/src/main/org/jboss/seam/util ...

Gavin King gavin.king at jboss.com
Tue Nov 21 00:17:13 EST 2006


  User: gavin   
  Date: 06/11/21 00:17:13

  Modified:    src/main/org/jboss/seam/util  Conversions.java
  Log:
  support Properties
  
  Revision  Changes    Path
  1.8       +19 -0     jboss-seam/src/main/org/jboss/seam/util/Conversions.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: Conversions.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/util/Conversions.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -b -r1.7 -r1.8
  --- Conversions.java	27 Oct 2006 12:58:10 -0000	1.7
  +++ Conversions.java	21 Nov 2006 05:17:13 -0000	1.8
  @@ -8,6 +8,7 @@
   import java.util.HashSet;
   import java.util.List;
   import java.util.Map;
  +import java.util.Properties;
   import java.util.Set;
   
   public class Conversions
  @@ -31,6 +32,7 @@
         put(Set.class, new SetConverter());
         put(List.class, new ListConverter());
         put(Map.class, new MapConverter());
  +      put(Properties.class, new PropertiesConverter());
         //put(Date.class, new DateTimeConverter());
         //put(Short.class, new ShortConverter());
         //put(Byte.class, new ByteConverter());
  @@ -192,6 +194,23 @@
         }
      }
      
  +   public static class PropertiesConverter implements Converter<Properties>
  +   {
  +      public Properties toObject(PropertyValue values, Type type)
  +      {
  +         Map<String, String> keyedValues = values.getKeyedValues();
  +         Properties map = new Properties();
  +         Converter elementConverter = converters.get(String.class);
  +         for ( Map.Entry<String, String> me: keyedValues.entrySet() )
  +         {
  +            String key = me.getKey();
  +            Object element = elementConverter.toObject( new FlatPropertyValue( me.getValue() ), String.class );
  +            map.put(key, element);
  +         }
  +         return map;
  +      }
  +   }
  +   
      public static class ClassConverter implements Converter<Class>
      {
         public Class toObject(PropertyValue value, Type type)
  
  
  



More information about the jboss-cvs-commits mailing list