Title: [waffle-scm] [399] trunk/waffle-distribution/src/site/content: WAFFLE-32: Renamed WaffleTypeConverter to ValueConverter
Revision
399
Author
mauro
Date
2007-11-17 04:21:57 -0600 (Sat, 17 Nov 2007)

Log Message

WAFFLE-32: Renamed WaffleTypeConverter to ValueConverter

Modified Paths

Added Paths

Removed Paths

Diff

Deleted: trunk/examples/paranamer-example/src/main/java/org/codehaus/waffle/example/paranamer/DateTypeConverter.java (398 => 399)

--- trunk/examples/paranamer-example/src/main/java/org/codehaus/waffle/example/paranamer/DateTypeConverter.java	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/examples/paranamer-example/src/main/java/org/codehaus/waffle/example/paranamer/DateTypeConverter.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -1,47 +0,0 @@
-package org.codehaus.waffle.example.paranamer;
-
-import org.codehaus.waffle.bind.BindException;
-import org.codehaus.waffle.bind.WaffleTypeConverter;
-import org.codehaus.waffle.i18n.MessageResources;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * @author Michael Ward
- */
-public class DateTypeConverter implements WaffleTypeConverter {
-    private final MessageResources messageResources;
-
-    public DateTypeConverter(MessageResources messageResources) {
-        this.messageResources = messageResources;
-    }
-
-    /**
-     * Will accept any class stemming from <code>java.util.Date</code>
-     *
-     * @param type represent the type of the field a value is to be bound to
-     * @return true if isA Date
-     */
-    public boolean accept(Class type) {
-        return Date.class.isAssignableFrom(type);
-    }
-
-    public Object convert(String propertyName, String value, Class toType) throws BindException {
-        if (value == null || value.equals("")) {
-            return null;
-        }
-
-        String datePattern = messageResources.getMessageWithDefault("date.format", "dd-MM-yyyy");
-
-        try {
-            return new SimpleDateFormat(datePattern).parse(value);
-        } catch (ParseException e) {
-            String fieldName = messageResources.getMessageWithDefault(propertyName, propertyName);
-            String message = messageResources.getMessage("date.bind.error", fieldName, value, datePattern);
-            throw new BindException(message);
-        }
-    }
-
-}

Copied: trunk/examples/paranamer-example/src/main/java/org/codehaus/waffle/example/paranamer/DateValueConverter.java (from rev 395, trunk/examples/paranamer-example/src/main/java/org/codehaus/waffle/example/paranamer/DateTypeConverter.java) (0 => 399)

--- trunk/examples/paranamer-example/src/main/java/org/codehaus/waffle/example/paranamer/DateValueConverter.java	                        (rev 0)
+++ trunk/examples/paranamer-example/src/main/java/org/codehaus/waffle/example/paranamer/DateValueConverter.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -0,0 +1,47 @@
+package org.codehaus.waffle.example.paranamer;
+
+import org.codehaus.waffle.bind.BindException;
+import org.codehaus.waffle.bind.ValueConverter;
+import org.codehaus.waffle.i18n.MessageResources;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @author Michael Ward
+ */
+public class DateValueConverter implements ValueConverter {
+    private final MessageResources messageResources;
+
+    public DateValueConverter(MessageResources messageResources) {
+        this.messageResources = messageResources;
+    }
+
+    /**
+     * Will accept any class stemming from <code>java.util.Date</code>
+     *
+     * @param type represent the type of the field a value is to be bound to
+     * @return true if isA Date
+     */
+    public boolean accept(Class<?> type) {
+        return Date.class.isAssignableFrom(type);
+    }
+
+    public Object convertValue(String propertyName, String value, Class<?> toType) throws BindException {
+        if (value == null || value.equals("")) {
+            return null;
+        }
+
+        String datePattern = messageResources.getMessageWithDefault("date.format", "dd-MM-yyyy");
+
+        try {
+            return new SimpleDateFormat(datePattern).parse(value);
+        } catch (ParseException e) {
+            String fieldName = messageResources.getMessageWithDefault(propertyName, propertyName);
+            String message = messageResources.getMessage("date.bind.error", fieldName, value, datePattern);
+            throw new BindException(message);
+        }
+    }
+
+}

Modified: trunk/examples/paranamer-example/src/main/resources/META-INF/ParameterNames.list (398 => 399)

--- trunk/examples/paranamer-example/src/main/resources/META-INF/ParameterNames.list	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/examples/paranamer-example/src/main/resources/META-INF/ParameterNames.list	2007-11-17 10:21:57 UTC (rev 399)
@@ -9,9 +9,9 @@
 org.codehaus.waffle.example.paranamer.Item getName 
 org.codehaus.waffle.example.paranamer.Item setId int id 
 org.codehaus.waffle.example.paranamer.Item setName java.lang.String name 
-org.codehaus.waffle.example.paranamer.DateTypeConverter DateTypeConverter org.codehaus.waffle.i18n.MessageResources messageResources 
-org.codehaus.waffle.example.paranamer.DateTypeConverter accept java.lang.Class type 
-org.codehaus.waffle.example.paranamer.DateTypeConverter convert java.lang.String,java.lang.String,java.lang.Class propertyName,value,toType 
+org.codehaus.waffle.example.paranamer.DateValueConverter DateValueConverter org.codehaus.waffle.i18n.MessageResources messageResources 
+org.codehaus.waffle.example.paranamer.DateValueConverter accept java.lang.Class type 
+org.codehaus.waffle.example.paranamer.DateValueConverter convertValue java.lang.String,java.lang.String,java.lang.Class propertyName,value,toType 
 org.codehaus.waffle.example.paranamer.MyRegistrar MyRegistrar org.codehaus.waffle.registrar.Registrar delegate 
 org.codehaus.waffle.example.paranamer.MyRegistrar application 
 org.codehaus.waffle.example.paranamer.MyRegistrar session 

Modified: trunk/examples/paranamer-example/src/main/webapp/WEB-INF/web.xml (398 => 399)

--- trunk/examples/paranamer-example/src/main/webapp/WEB-INF/web.xml	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/examples/paranamer-example/src/main/webapp/WEB-INF/web.xml	2007-11-17 10:21:57 UTC (rev 399)
@@ -19,7 +19,7 @@
     <!-- 2. We are adding a Custom Converter to handle Date objects -->
     <context-param>
         <param-name>register:DateConverter</param-name>
-        <param-value>org.codehaus.waffle.example.paranamer.DateTypeConverter</param-value>
+        <param-value>org.codehaus.waffle.example.paranamer.DateValueConverter</param-value>
     </context-param>
 
     <!-- 3. Waffle context listener (ServletContext and HttpSession) -->

Deleted: trunk/examples/paranamer-example/src/test/java/org/codehaus/waffle/example/paranamer/DateTypeConverterTest.java (398 => 399)

--- trunk/examples/paranamer-example/src/test/java/org/codehaus/waffle/example/paranamer/DateTypeConverterTest.java	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/examples/paranamer-example/src/test/java/org/codehaus/waffle/example/paranamer/DateTypeConverterTest.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -1,48 +0,0 @@
-package org.codehaus.waffle.example.paranamer;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import ognl.OgnlException;
-
-import org.codehaus.waffle.bind.BindException;
-import org.codehaus.waffle.i18n.DefaultMessageResources;
-import org.junit.Assert;
-import org.junit.Test;
-
-
-public class DateTypeConverterTest {
-
-    @Test
-    public void canAccept() {
-        DateTypeConverter converter = new DateTypeConverter(new DefaultMessageResources());
-
-        Assert.assertTrue(converter.accept(Date.class));
-        Assert.assertTrue(converter.accept(java.sql.Date.class));
-    }
-
-    @Test
-    public void canConvert() throws OgnlException {
-        DateTypeConverter converter = new DateTypeConverter(new DefaultMessageResources());
-        Date date = (Date) converter.convert("property-name", "19-09-2004", Date.class);
-
-        Assert.assertEquals("09-19-2004", new SimpleDateFormat("MM-dd-yyyy").format(date));
-    }
-
-    @Test(expected=BindException.class)
-    public void cannotConvertBadValue() {
-        DateTypeConverter converter = new DateTypeConverter(new DefaultMessageResources());
-        converter.convert("property-name", "bad-value", Date.class);
-     }
-
-    @Test
-    public void canUseDefaultFormatWhenNoAlternativeProvided() {
-        DateTypeConverter converter = new DateTypeConverter(new DefaultMessageResources());
-        Date date = (Date) converter.convert("property-name", "00-21-1986", Date.class);
-
-        assertNotNull(date);
-    }
-}
-

Copied: trunk/examples/paranamer-example/src/test/java/org/codehaus/waffle/example/paranamer/DateValueConverterTest.java (from rev 395, trunk/examples/paranamer-example/src/test/java/org/codehaus/waffle/example/paranamer/DateTypeConverterTest.java) (0 => 399)

--- trunk/examples/paranamer-example/src/test/java/org/codehaus/waffle/example/paranamer/DateValueConverterTest.java	                        (rev 0)
+++ trunk/examples/paranamer-example/src/test/java/org/codehaus/waffle/example/paranamer/DateValueConverterTest.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -0,0 +1,48 @@
+package org.codehaus.waffle.example.paranamer;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import ognl.OgnlException;
+
+import org.codehaus.waffle.bind.BindException;
+import org.codehaus.waffle.i18n.DefaultMessageResources;
+import org.junit.Assert;
+import org.junit.Test;
+
+
+public class DateValueConverterTest {
+
+    @Test
+    public void canAccept() {
+        DateValueConverter converter = new DateValueConverter(new DefaultMessageResources());
+
+        Assert.assertTrue(converter.accept(Date.class));
+        Assert.assertTrue(converter.accept(java.sql.Date.class));
+    }
+
+    @Test
+    public void canConvert() throws OgnlException {
+        DateValueConverter converter = new DateValueConverter(new DefaultMessageResources());
+        Date date = (Date) converter.convertValue("property-name", "19-09-2004", Date.class);
+
+        Assert.assertEquals("09-19-2004", new SimpleDateFormat("MM-dd-yyyy").format(date));
+    }
+
+    @Test(expected=BindException.class)
+    public void cannotConvertBadValue() {
+        DateValueConverter converter = new DateValueConverter(new DefaultMessageResources());
+        converter.convertValue("property-name", "bad-value", Date.class);
+     }
+
+    @Test
+    public void canUseDefaultFormatWhenNoAlternativeProvided() {
+        DateValueConverter converter = new DateValueConverter(new DefaultMessageResources());
+        Date date = (Date) converter.convertValue("property-name", "00-21-1986", Date.class);
+
+        assertNotNull(date);
+    }
+}
+

Deleted: trunk/examples/simple-example/src/main/java/org/codehaus/waffle/example/simple/DateTypeConverter.java (398 => 399)

--- trunk/examples/simple-example/src/main/java/org/codehaus/waffle/example/simple/DateTypeConverter.java	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/examples/simple-example/src/main/java/org/codehaus/waffle/example/simple/DateTypeConverter.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -1,47 +0,0 @@
-package org.codehaus.waffle.example.simple;
-
-import org.codehaus.waffle.bind.BindException;
-import org.codehaus.waffle.bind.WaffleTypeConverter;
-import org.codehaus.waffle.i18n.MessageResources;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-/**
- * @author Michael Ward
- */
-public class DateTypeConverter implements WaffleTypeConverter {
-    private final MessageResources messageResources;
-
-    public DateTypeConverter(MessageResources messageResources) {
-        this.messageResources = messageResources;
-    }
-
-    /**
-     * Will accept any class stemming from <code>java.util.Date</code>
-     *
-     * @param type represent the type of the field a value is to be bound to
-     * @return true if isA Date
-     */
-    public boolean accept(Class type) {
-        return Date.class.isAssignableFrom(type);
-    }
-
-    public Object convert(String propertyName, String value, Class toType) throws BindException {
-        if (value == null || value.equals("")) {
-            return null;
-        }
-
-        String datePattern = messageResources.getMessageWithDefault("date.format", "dd-MM-yyyy");
-
-        try {
-            return new SimpleDateFormat(datePattern).parse(value);
-        } catch (ParseException e) {
-            String fieldName = messageResources.getMessageWithDefault(propertyName, propertyName);
-            String message = messageResources.getMessage("date.bind.error", fieldName, value, datePattern);
-            throw new BindException(message);
-        }
-    }
-
-}

Copied: trunk/examples/simple-example/src/main/java/org/codehaus/waffle/example/simple/DateValueConverter.java (from rev 395, trunk/examples/simple-example/src/main/java/org/codehaus/waffle/example/simple/DateTypeConverter.java) (0 => 399)

--- trunk/examples/simple-example/src/main/java/org/codehaus/waffle/example/simple/DateValueConverter.java	                        (rev 0)
+++ trunk/examples/simple-example/src/main/java/org/codehaus/waffle/example/simple/DateValueConverter.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -0,0 +1,47 @@
+package org.codehaus.waffle.example.simple;
+
+import org.codehaus.waffle.bind.BindException;
+import org.codehaus.waffle.bind.ValueConverter;
+import org.codehaus.waffle.i18n.MessageResources;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+/**
+ * @author Michael Ward
+ */
+public class DateValueConverter implements ValueConverter {
+    private final MessageResources messageResources;
+
+    public DateValueConverter(MessageResources messageResources) {
+        this.messageResources = messageResources;
+    }
+
+    /**
+     * Will accept any class stemming from <code>java.util.Date</code>
+     *
+     * @param type represent the type of the field a value is to be bound to
+     * @return true if isA Date
+     */
+    public boolean accept(Class<?> type) {
+        return Date.class.isAssignableFrom(type);
+    }
+
+    public Object convertValue(String propertyName, String value, Class<?> toType) throws BindException {
+        if (value == null || value.equals("")) {
+            return null;
+        }
+
+        String datePattern = messageResources.getMessageWithDefault("date.format", "dd-MM-yyyy");
+
+        try {
+            return new SimpleDateFormat(datePattern).parse(value);
+        } catch (ParseException e) {
+            String fieldName = messageResources.getMessageWithDefault(propertyName, propertyName);
+            String message = messageResources.getMessage("date.bind.error", fieldName, value, datePattern);
+            throw new BindException(message);
+        }
+    }
+
+}

Modified: trunk/examples/simple-example/src/main/webapp/WEB-INF/web.xml (398 => 399)

--- trunk/examples/simple-example/src/main/webapp/WEB-INF/web.xml	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/examples/simple-example/src/main/webapp/WEB-INF/web.xml	2007-11-17 10:21:57 UTC (rev 399)
@@ -15,7 +15,7 @@
     <!-- 2. We are adding a custom components -->
     <context-param>
         <param-name>register:DateConverter</param-name>
-        <param-value>org.codehaus.waffle.example.simple.DateTypeConverter</param-value>
+        <param-value>org.codehaus.waffle.example.simple.DateValueConverter</param-value>
     </context-param>
     <context-param>
         <param-name>org.codehaus.waffle.monitor.ActionMonitor</param-name>

Deleted: trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/DateTypeConverterTest.java (398 => 399)

--- trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/DateTypeConverterTest.java	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/DateTypeConverterTest.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -1,46 +0,0 @@
-package org.codehaus.waffle.example.simple;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import ognl.OgnlException;
-
-import org.codehaus.waffle.bind.BindException;
-import org.codehaus.waffle.i18n.DefaultMessageResources;
-import org.junit.Assert;
-import org.junit.Test;
-
-public class DateTypeConverterTest {
-
-    @Test
-    public void canAccept() {
-        DateTypeConverter converter = new DateTypeConverter(new DefaultMessageResources());
-
-        Assert.assertTrue(converter.accept(Date.class));
-        Assert.assertTrue(converter.accept(java.sql.Date.class));
-    }
-
-    @Test
-    public void canConvert() throws OgnlException {
-        DateTypeConverter converter = new DateTypeConverter(new DefaultMessageResources());
-        Date date = (Date) converter.convert("property-name", "19-09-2004", Date.class);
-
-        Assert.assertEquals("09-19-2004", new SimpleDateFormat("MM-dd-yyyy").format(date));
-    }
-
-    @Test(expected=BindException.class)
-    public void cannotConvertBadValue() {
-        DateTypeConverter converter = new DateTypeConverter(new DefaultMessageResources());
-        converter.convert("property-name", "bad-value", Date.class);
-     }
-
-    @Test
-    public void canUseDefaultFormatWhenNoAlternativeProvided() {
-        DateTypeConverter converter = new DateTypeConverter(new DefaultMessageResources());
-        Date date = (Date) converter.convert("property-name", "00-21-1986", Date.class);
-
-        assertNotNull(date);
-    }
-}

Copied: trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/DateValueConverterTest.java (from rev 395, trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/DateTypeConverterTest.java) (0 => 399)

--- trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/DateValueConverterTest.java	                        (rev 0)
+++ trunk/examples/simple-example/src/test/java/org/codehaus/waffle/example/simple/DateValueConverterTest.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -0,0 +1,46 @@
+package org.codehaus.waffle.example.simple;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import ognl.OgnlException;
+
+import org.codehaus.waffle.bind.BindException;
+import org.codehaus.waffle.i18n.DefaultMessageResources;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class DateValueConverterTest {
+
+    @Test
+    public void canAccept() {
+        DateValueConverter converter = new DateValueConverter(new DefaultMessageResources());
+
+        Assert.assertTrue(converter.accept(Date.class));
+        Assert.assertTrue(converter.accept(java.sql.Date.class));
+    }
+
+    @Test
+    public void canConvert() throws OgnlException {
+        DateValueConverter converter = new DateValueConverter(new DefaultMessageResources());
+        Date date = (Date) converter.convertValue("property-name", "19-09-2004", Date.class);
+
+        Assert.assertEquals("09-19-2004", new SimpleDateFormat("MM-dd-yyyy").format(date));
+    }
+
+    @Test(expected=BindException.class)
+    public void cannotConvertBadValue() {
+        DateValueConverter converter = new DateValueConverter(new DefaultMessageResources());
+        converter.convertValue("property-name", "bad-value", Date.class);
+     }
+
+    @Test
+    public void canUseDefaultFormatWhenNoAlternativeProvided() {
+        DateValueConverter converter = new DateValueConverter(new DefaultMessageResources());
+        Date date = (Date) converter.convertValue("property-name", "00-21-1986", Date.class);
+
+        assertNotNull(date);
+    }
+}

Modified: trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/OgnlTypeConverter.java (398 => 399)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/OgnlTypeConverter.java	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/OgnlTypeConverter.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -18,25 +18,26 @@
 import java.util.Map;
 
 /**
- * An extension of Ognl's <code>DefaultTypeConverter</code> which handles Java 5 enums and will delegate
- * custom <code>WaffleTypeConverter</code>'s registered per application.
+ * An implementation of Ognl's <code>TypeConverter</code> which handles Java 5 enums and will delegate
+ * custom <code>ValueConverter</code>'s registered per application.
  *
  * @author Michael Ward
+ * @author Mauro Talevi
  */
 public class OgnlTypeConverter implements TypeConverter {
     private static final String EMPTY = "";
-    private final WaffleTypeConverter[] waffleTypeConverters;
-    private final Map<Class, WaffleTypeConverter> cache = new HashMap<Class, WaffleTypeConverter>();
+    private final ValueConverter[] valueConverters;
+    private final Map<Class<?>, ValueConverter> cache = new HashMap<Class<?>, ValueConverter>();
 
     public OgnlTypeConverter() {
-        this.waffleTypeConverters = new WaffleTypeConverter[0];
+        this.valueConverters = new ValueConverter[0];
     }
 
-    public OgnlTypeConverter(WaffleTypeConverter... waffleTypeConverters) {
-        if (waffleTypeConverters == null) {
-            this.waffleTypeConverters = new WaffleTypeConverter[0];
+    public OgnlTypeConverter(ValueConverter... valueConverters) {
+        if (valueConverters == null) {
+            this.valueConverters = new ValueConverter[0];
         } else {
-            this.waffleTypeConverters = waffleTypeConverters;
+            this.valueConverters = valueConverters;
         }
     }
 
@@ -83,24 +84,24 @@
             return Enum.valueOf(toType, value);
         }
 
-        WaffleTypeConverter waffleTypeConverter = findConverter(toType);
+        ValueConverter waffleTypeConverter = findConverter(toType);
 
         if (waffleTypeConverter != null) {
-            return waffleTypeConverter.convert(propertyName, value, toType);
+            return waffleTypeConverter.convertValue(propertyName, value, toType);
         }
 
         return OgnlOps.convertValue(value, toType);
     }
 
-    private WaffleTypeConverter findConverter(Class toType) {
+    private ValueConverter findConverter(Class<?> toType) {
         if (cache.containsKey(toType)) { // cache hit
             return cache.get(toType);
         }
 
-        for (WaffleTypeConverter waffleTypeConverter : waffleTypeConverters) {
-            if (waffleTypeConverter.accept(toType)) {
-                cache.put(toType, waffleTypeConverter);
-                return waffleTypeConverter;
+        for (ValueConverter converter : valueConverters) {
+            if (converter.accept(toType)) {
+                cache.put(toType, converter);
+                return converter;
             }
         }
 

Copied: trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/ValueConverter.java (from rev 395, trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/WaffleTypeConverter.java) (0 => 399)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/ValueConverter.java	                        (rev 0)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/ValueConverter.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (C) 2005,2006 Michael Ward                                      *
+ * All rights reserved.                                                      *
+ * ------------------------------------------------------------------------- *
+ * The software in this package is published under the terms of the BSD      *
+ * style license a copy of which has been included with this distribution in *
+ * the LICENSE.txt file.                                                     *
+ *                                                                           *
+ * Original code by: Michael Ward                                            *
+ *****************************************************************************/
+package org.codehaus.waffle.bind;
+
+/**
+ * Implementation of this interface will be responsible for converting values of specific type(s).
+ *
+ * @author Michael Ward
+ */
+public interface ValueConverter {
+
+    boolean accept(Class<?> type);
+
+    Object convertValue(String propertyName, String value, Class<?> toType) throws BindException;
+
+}

Deleted: trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/WaffleTypeConverter.java (398 => 399)

--- trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/WaffleTypeConverter.java	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/waffle-core/src/main/java/org/codehaus/waffle/bind/WaffleTypeConverter.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -1,23 +0,0 @@
-/*****************************************************************************
- * Copyright (C) 2005,2006 Michael Ward                                      *
- * All rights reserved.                                                      *
- * ------------------------------------------------------------------------- *
- * The software in this package is published under the terms of the BSD      *
- * style license a copy of which has been included with this distribution in *
- * the LICENSE.txt file.                                                     *
- *                                                                           *
- * Original code by: Michael Ward                                            *
- *****************************************************************************/
-package org.codehaus.waffle.bind;
-
-/**
- * Implementation of this interface will be responsible for converting specific type(s).
- *
- * @author Michael Ward
- */
-public interface WaffleTypeConverter {
-
-    boolean accept(Class type);
-
-    Object convert(String propertyName, String value, Class toType) throws BindException;
-}

Modified: trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/OgnlTypeConverterTest.java (398 => 399)

--- trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/OgnlTypeConverterTest.java	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/waffle-core/src/test/java/org/codehaus/waffle/bind/OgnlTypeConverterTest.java	2007-11-17 10:21:57 UTC (rev 399)
@@ -40,16 +40,16 @@
     @Test
     public void canConvertDelegatesToWaffleTypeConverter() {
         // Mock TypeConverter 
-        final WaffleTypeConverter waffleTypeConverter = mockery.mock(WaffleTypeConverter.class);
+        final ValueConverter waffleTypeConverter = mockery.mock(ValueConverter.class);
         mockery.checking(new Expectations() {
             {
                 one(waffleTypeConverter).accept(Vector.class);
                 will(returnValue(true));
-                one(waffleTypeConverter).convert(with(same("propertyName")), with(same("foobar")), with(same(Vector.class)));
+                one(waffleTypeConverter).convertValue(with(same("propertyName")), with(same("foobar")), with(same(Vector.class)));
                 will(returnValue(new Vector<Object>()));
             }
         });
-        WaffleTypeConverter[] waffleTypeConverters = {waffleTypeConverter};
+        ValueConverter[] waffleTypeConverters = {waffleTypeConverter};
         OgnlTypeConverter converter = new OgnlTypeConverter(waffleTypeConverters);
 
         converter.convertValue("propertyName", "foobar", Vector.class);

Modified: trunk/waffle-distribution/src/site/content/binding-validation.html (398 => 399)

--- trunk/waffle-distribution/src/site/content/binding-validation.html	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/waffle-distribution/src/site/content/binding-validation.html	2007-11-17 10:21:57 UTC (rev 399)
@@ -48,10 +48,10 @@
     </p>
 
 
-    <h4>WaffleTypeConverter</h4>
+    <h4>ValueConverter</h4>
 
     <p>
-      Implementation of the <b>WaffleTypeConverter</b> interface is needed to handle these custom type conversions. This
+      Implementation of the <b>ValueConverter</b> interface is needed to handle these custom value conversions. This
       interface defines two methods:
     </p>
 
@@ -67,7 +67,7 @@
           handle conversions for the class type passed.</td>
         </tr>
         <tr class="a">
-          <td align="left">Object convert(String propertyName, String
+          <td align="left">Object convertValue(String propertyName, String
           value, Class toType)</td>
           <td align="left">responsible for handling the conversion
           (only called if implementation returned true from the <i>accept()</i>
@@ -82,11 +82,11 @@
     </p>
 
     <textarea class="java:nogutter:nocontrols" name="code">
-      public class DateTypeConverter implements WaffleTypeConverter {
+      public class DateValueConverter implements ValueConverter {
 
         private MessageResources messageResources;
 
-        public DateTypeConverter(MessageResources messageResources) {
+        public DateValueConverter(MessageResources messageResources) {
             this.messageResources = messageResources;
         }
 
@@ -100,7 +100,7 @@
             return Date.class.isAssignableFrom(type);
         }
 
-        public Object convert(String propertyName, String value, Class toType) throws BindException {
+        public Object convertValue(String propertyName, String value, Class toType) throws BindException {
             String format = messageResources.getMessageWithDefault("date.format", "dd-MM-yyyy");
 
             try {
@@ -119,7 +119,7 @@
     <textarea class="xml:nogutter:nocontrols" name="code">
       <context-param>
         <param-name>register:DateConverter</param-name>
-        <param-value>com.mycompany.DateTypeConverter</param-value>
+        <param-value>com.mycompany.DateValueConverter</param-value>
       </context-param>
     </textarea>
 

Modified: trunk/waffle-distribution/src/templates/eclipse/webapp/WEB-INF/web.xml (398 => 399)

--- trunk/waffle-distribution/src/templates/eclipse/webapp/WEB-INF/web.xml	2007-11-17 09:43:43 UTC (rev 398)
+++ trunk/waffle-distribution/src/templates/eclipse/webapp/WEB-INF/web.xml	2007-11-17 10:21:57 UTC (rev 399)
@@ -25,7 +25,7 @@
     <!-- 2. We are adding a Custom Converter to handle Date objects -->
     <context-param>
         <param-name>register:DateConverter</param-name>
-        <param-value>org.codehaus.waffle.example.paranamer.DateTypeConverter</param-value>
+        <param-value>org.codehaus.waffle.example.paranamer.DateValueConverter</param-value>
     </context-param>
 
     <!-- 3. Waffle context listener (ServletContext and HttpSession) -->


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to