]> source.dussan.org Git - vaadin-framework.git/commitdiff
#8101 Renamed source type to presentation and target type to model for
authorArtur Signell <artur@vaadin.com>
Wed, 21 Dec 2011 17:08:08 +0000 (19:08 +0200)
committerArtur Signell <artur@vaadin.com>
Wed, 21 Dec 2011 17:08:08 +0000 (19:08 +0200)
clarity

13 files changed:
src/com/vaadin/data/util/converter/BooleanToStringConverter.java
src/com/vaadin/data/util/converter/Converter.java
src/com/vaadin/data/util/converter/DateToStringConverter.java
src/com/vaadin/data/util/converter/DoubleToStringConverter.java
src/com/vaadin/data/util/converter/IntegerToStringConverter.java
src/com/vaadin/data/util/converter/LongToDateConverter.java
src/com/vaadin/data/util/converter/NumberToStringConverter.java
src/com/vaadin/data/util/converter/ReverseConverter.java
src/com/vaadin/ui/AbstractField.java
src/com/vaadin/ui/Table.java
tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java
tests/testbench/com/vaadin/tests/components/abstractfield/Vaadin6ImplicitDoubleConverter.java
tests/testbench/com/vaadin/tests/components/table/DoublesInTable.java

index 466f0f3b7933ec1621cb46b9071ca2919f656119..9c6add7c993ecd5512785b0599f65f3cd29b8b60 100644 (file)
@@ -27,7 +27,7 @@ public class BooleanToStringConverter implements Converter<Boolean, String> {
      * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public Boolean convertFromTargetToSource(String value, Locale locale)\r
+    public Boolean convertToModel(String value, Locale locale)\r
             throws ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -61,7 +61,7 @@ public class BooleanToStringConverter implements Converter<Boolean, String> {
      * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public String convertFromSourceToTarget(Boolean value, Locale locale)\r
+    public String convertToPresentation(Boolean value, Locale locale)\r
             throws ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -78,7 +78,7 @@ public class BooleanToStringConverter implements Converter<Boolean, String> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getSourceType()\r
      */\r
-    public Class<Boolean> getSourceType() {\r
+    public Class<Boolean> getModelType() {\r
         return Boolean.class;\r
     }\r
 \r
@@ -87,7 +87,7 @@ public class BooleanToStringConverter implements Converter<Boolean, String> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getTargetType()\r
      */\r
-    public Class<String> getTargetType() {\r
+    public Class<String> getPresentationType() {\r
         return String.class;\r
     }\r
 \r
index 943d6ec76a8a0466681af46762a42ad5ec0ae79d..2a2c3025d99bca70815704492f26c169c0fc4ba0 100644 (file)
@@ -8,13 +8,13 @@ import java.io.Serializable;
 import java.util.Locale;\r
 \r
 /**\r
- * Interface that implements conversion between objects of one type to another\r
- * and back.\r
+ * Interface that implements conversion between objects between model and\r
+ * presentation types.\r
  * <p>\r
- * Typically {@link #convertFromSourceToTarget(Object, Locale)} and\r
- * {@link #convertFromTargetToSource(Object, Locale)} should be symmetric so\r
- * that chaining these together returns the original result for all input but\r
- * this is not a requirement.\r
+ * Typically {@link #convertToPresentation(Object, Locale)} and\r
+ * {@link #convertToModel(Object, Locale)} should be symmetric so that chaining\r
+ * these together returns the original result for all input but this is not a\r
+ * requirement.\r
  * </p>\r
  * <p>\r
  * Converters must not have any side effects (never update UI from inside a\r
@@ -27,18 +27,18 @@ import java.util.Locale;
  * If conversion of a value fails, a {@link ConversionException} is thrown.\r
  * </p>\r
  * \r
- * @param <SOURCE>\r
- *            The source type. Must be compatible with what\r
- *            {@link #getSourceType()} returns.\r
- * @param <TARGET>\r
- *            The target type. Must be compatible with what\r
- *            {@link #getTargetType()} returns.\r
+ * @param <MODEL>\r
+ *            The model type. Must be compatible with what\r
+ *            {@link #getModelType()} returns.\r
+ * @param <PRESENTATION>\r
+ *            The presentation type. Must be compatible with what\r
+ *            {@link #getPresentationType()} returns.\r
  * @author Vaadin Ltd.\r
  * @version\r
  * @VERSION@\r
  * @since 7.0\r
  */\r
-public interface Converter<SOURCE, TARGET> extends Serializable {\r
+public interface Converter<MODEL, PRESENTATION> extends Serializable {\r
 \r
     /**\r
      * Converts the given value from target type to source type.\r
@@ -46,9 +46,8 @@ public interface Converter<SOURCE, TARGET> extends Serializable {
      * A converter can optionally use locale to do the conversion.\r
      * </p>\r
      * A converter should in most cases be symmetric so chaining\r
-     * {@link #convertFromSourceToTarget(Object, Locale)} and\r
-     * {@link #convertFromTargetToSource(Object, Locale)} should return the\r
-     * original value.\r
+     * {@link #convertToPresentation(Object, Locale)} and\r
+     * {@link #convertToModel(Object, Locale)} should return the original value.\r
      * \r
      * @param value\r
      *            The value to convert, compatible with the target type. Can be\r
@@ -59,7 +58,7 @@ public interface Converter<SOURCE, TARGET> extends Serializable {
      * @throws ConversionException\r
      *             If the value could not be converted\r
      */\r
-    public SOURCE convertFromTargetToSource(TARGET value, Locale locale)\r
+    public MODEL convertToModel(PRESENTATION value, Locale locale)\r
             throws ConversionException;\r
 \r
     /**\r
@@ -68,9 +67,8 @@ public interface Converter<SOURCE, TARGET> extends Serializable {
      * A converter can optionally use locale to do the conversion.\r
      * </p>\r
      * A converter should in most cases be symmetric so chaining\r
-     * {@link #convertFromSourceToTarget(Object, Locale)} and\r
-     * {@link #convertFromTargetToSource(Object, Locale)} should return the\r
-     * original value.\r
+     * {@link #convertToPresentation(Object, Locale)} and\r
+     * {@link #convertToModel(Object, Locale)} should return the original value.\r
      * \r
      * @param value\r
      *            The value to convert, compatible with the target type. Can be\r
@@ -81,34 +79,33 @@ public interface Converter<SOURCE, TARGET> extends Serializable {
      * @throws ConversionException\r
      *             If the value could not be converted\r
      */\r
-    public TARGET convertFromSourceToTarget(SOURCE value, Locale locale)\r
+    public PRESENTATION convertToPresentation(MODEL value, Locale locale)\r
             throws ConversionException;\r
 \r
     /**\r
      * The source type of the converter.\r
      * \r
      * Values of this type can be passed to\r
-     * {@link #convertFromSourceToTarget(Object, Locale)}.\r
+     * {@link #convertToPresentation(Object, Locale)}.\r
      * \r
      * @return The source type\r
      */\r
-    public Class<SOURCE> getSourceType();\r
+    public Class<MODEL> getModelType();\r
 \r
     /**\r
      * The target type of the converter.\r
      * \r
      * Values of this type can be passed to\r
-     * {@link #convertFromTargetToSource(Object, Locale)}.\r
+     * {@link #convertToModel(Object, Locale)}.\r
      * \r
      * @return The target type\r
      */\r
-    public Class<TARGET> getTargetType();\r
+    public Class<PRESENTATION> getPresentationType();\r
 \r
     /**\r
      * An exception that signals that the value passed to\r
-     * {@link Converter#convertFromSourceToTarget(Object, Locale)} or\r
-     * {@link Converter#convertFromTargetToSource(Object, Locale)} could not be\r
-     * converted.\r
+     * {@link Converter#convertToPresentation(Object, Locale)} or\r
+     * {@link Converter#convertToModel(Object, Locale)} could not be converted.\r
      * \r
      * @author Vaadin Ltd\r
      * @version\r
index 56405b776a920cbe8f187f48e2bc402736bad2de..947a426db61db11a8e76eed7d8d9b4d9dff22625 100644 (file)
@@ -28,8 +28,8 @@ public class DateToStringConverter implements Converter<Date, String> {
 \r
     /**\r
      * Returns the format used by\r
-     * {@link #convertFromSourceToTarget(Date, Locale)} and\r
-     * {@link #convertFromTargetToSource(String, Locale)}.\r
+     * {@link #convertToPresentation(Date, Locale)} and\r
+     * {@link #convertToModel(String, Locale)}.\r
      * \r
      * @param locale\r
      *            The locale to use\r
@@ -53,7 +53,7 @@ public class DateToStringConverter implements Converter<Date, String> {
      * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public Date convertFromTargetToSource(String value, Locale locale)\r
+    public Date convertToModel(String value, Locale locale)\r
             throws com.vaadin.data.util.converter.Converter.ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -66,7 +66,7 @@ public class DateToStringConverter implements Converter<Date, String> {
         Date parsedValue = getFormat(locale).parse(value, parsePosition);\r
         if (parsePosition.getIndex() != value.length()) {\r
             throw new ConversionException("Could not convert '" + value\r
-                    + "' to " + getTargetType().getName());\r
+                    + "' to " + getPresentationType().getName());\r
         }\r
 \r
         return parsedValue;\r
@@ -79,7 +79,7 @@ public class DateToStringConverter implements Converter<Date, String> {
      * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public String convertFromSourceToTarget(Date value, Locale locale)\r
+    public String convertToPresentation(Date value, Locale locale)\r
             throws com.vaadin.data.util.converter.Converter.ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -93,7 +93,7 @@ public class DateToStringConverter implements Converter<Date, String> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getSourceType()\r
      */\r
-    public Class<Date> getSourceType() {\r
+    public Class<Date> getModelType() {\r
         return Date.class;\r
     }\r
 \r
@@ -102,7 +102,7 @@ public class DateToStringConverter implements Converter<Date, String> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getTargetType()\r
      */\r
-    public Class<String> getTargetType() {\r
+    public Class<String> getPresentationType() {\r
         return String.class;\r
     }\r
 \r
index e548936e2f30640e96b6c7b91fcd76ca538c4b62..a6bebaddd3b4c13f847830b99aa42984e109eaa1 100644 (file)
@@ -28,8 +28,8 @@ public class DoubleToStringConverter implements Converter<Double, String> {
 \r
     /**\r
      * Returns the format used by\r
-     * {@link #convertFromSourceToTarget(Double, Locale)} and\r
-     * {@link #convertFromTargetToSource(String, Locale)}.\r
+     * {@link #convertToPresentation(Double, Locale)} and\r
+     * {@link #convertToModel(String, Locale)}.\r
      * \r
      * @param locale\r
      *            The locale to use\r
@@ -50,7 +50,7 @@ public class DoubleToStringConverter implements Converter<Double, String> {
      * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public Double convertFromTargetToSource(String value, Locale locale)\r
+    public Double convertToModel(String value, Locale locale)\r
             throws ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -63,7 +63,7 @@ public class DoubleToStringConverter implements Converter<Double, String> {
         Number parsedValue = getFormat(locale).parse(value, parsePosition);\r
         if (parsePosition.getIndex() != value.length()) {\r
             throw new ConversionException("Could not convert '" + value\r
-                    + "' to " + getTargetType().getName());\r
+                    + "' to " + getPresentationType().getName());\r
         }\r
         return parsedValue.doubleValue();\r
     }\r
@@ -75,7 +75,7 @@ public class DoubleToStringConverter implements Converter<Double, String> {
      * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public String convertFromSourceToTarget(Double value, Locale locale)\r
+    public String convertToPresentation(Double value, Locale locale)\r
             throws ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -89,7 +89,7 @@ public class DoubleToStringConverter implements Converter<Double, String> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getSourceType()\r
      */\r
-    public Class<Double> getSourceType() {\r
+    public Class<Double> getModelType() {\r
         return Double.class;\r
     }\r
 \r
@@ -98,7 +98,7 @@ public class DoubleToStringConverter implements Converter<Double, String> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getTargetType()\r
      */\r
-    public Class<String> getTargetType() {\r
+    public Class<String> getPresentationType() {\r
         return String.class;\r
     }\r
 }\r
index afd63b88c475fc38072bce34733aa3fa8162b685..5c0d6761c0380950344dc588251c352e0d26314d 100644 (file)
@@ -25,8 +25,8 @@ public class IntegerToStringConverter implements Converter<Integer, String> {
 \r
     /**\r
      * Returns the format used by\r
-     * {@link #convertFromSourceToTarget(Integer, Locale)} and\r
-     * {@link #convertFromTargetToSource(String, Locale)}.\r
+     * {@link #convertToPresentation(Integer, Locale)} and\r
+     * {@link #convertToModel(String, Locale)}.\r
      * \r
      * @param locale\r
      *            The locale to use\r
@@ -39,7 +39,7 @@ public class IntegerToStringConverter implements Converter<Integer, String> {
         return NumberFormat.getIntegerInstance(locale);\r
     }\r
 \r
-    public Integer convertFromTargetToSource(String value, Locale locale)\r
+    public Integer convertToModel(String value, Locale locale)\r
             throws ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -54,7 +54,7 @@ public class IntegerToStringConverter implements Converter<Integer, String> {
         Number parsedValue = getFormat(locale).parse(value, parsePosition);\r
         if (parsePosition.getIndex() != value.length()) {\r
             throw new ConversionException("Could not convert '" + value\r
-                    + "' to " + getSourceType().getName());\r
+                    + "' to " + getModelType().getName());\r
         }\r
 \r
         if (parsedValue == null) {\r
@@ -64,7 +64,7 @@ public class IntegerToStringConverter implements Converter<Integer, String> {
         return parsedValue.intValue();\r
     }\r
 \r
-    public String convertFromSourceToTarget(Integer value, Locale locale)\r
+    public String convertToPresentation(Integer value, Locale locale)\r
             throws ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -73,11 +73,11 @@ public class IntegerToStringConverter implements Converter<Integer, String> {
         return getFormat(locale).format(value);\r
     }\r
 \r
-    public Class<Integer> getSourceType() {\r
+    public Class<Integer> getModelType() {\r
         return Integer.class;\r
     }\r
 \r
-    public Class<String> getTargetType() {\r
+    public Class<String> getPresentationType() {\r
         return String.class;\r
     }\r
 \r
index c7d2a33c76348e082183bb6d420ebb2a43e4c92c..c22e8af16e91d18dcd43beb38c945dbbaf2064f3 100644 (file)
@@ -24,7 +24,7 @@ public class LongToDateConverter implements Converter<Long, Date> {
      * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public Long convertFromTargetToSource(Date value, Locale locale) {\r
+    public Long convertToModel(Date value, Locale locale) {\r
         if (value == null) {\r
             return null;\r
         }\r
@@ -39,7 +39,7 @@ public class LongToDateConverter implements Converter<Long, Date> {
      * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public Date convertFromSourceToTarget(Long value, Locale locale) {\r
+    public Date convertToPresentation(Long value, Locale locale) {\r
         if (value == null) {\r
             return null;\r
         }\r
@@ -52,7 +52,7 @@ public class LongToDateConverter implements Converter<Long, Date> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getSourceType()\r
      */\r
-    public Class<Long> getSourceType() {\r
+    public Class<Long> getModelType() {\r
         return Long.class;\r
     }\r
 \r
@@ -61,7 +61,7 @@ public class LongToDateConverter implements Converter<Long, Date> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getTargetType()\r
      */\r
-    public Class<Date> getTargetType() {\r
+    public Class<Date> getPresentationType() {\r
         return Date.class;\r
     }\r
 \r
index 227751dbfdc0746c2e497edd81597689f164cc51..cd4c1363b78550a197f1041c4d8a700aa04d1121 100644 (file)
@@ -24,8 +24,8 @@ public class NumberToStringConverter implements Converter<Number, String> {
 \r
     /**\r
      * Returns the format used by\r
-     * {@link #convertFromSourceToTarget(Number, Locale)} and\r
-     * {@link #convertFromTargetToSource(String, Locale)}.\r
+     * {@link #convertToPresentation(Number, Locale)} and\r
+     * {@link #convertToModel(String, Locale)}.\r
      * \r
      * @param locale\r
      *            The locale to use\r
@@ -46,7 +46,7 @@ public class NumberToStringConverter implements Converter<Number, String> {
      * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public Number convertFromTargetToSource(String value, Locale locale)\r
+    public Number convertToModel(String value, Locale locale)\r
             throws ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -61,7 +61,7 @@ public class NumberToStringConverter implements Converter<Number, String> {
         Number parsedValue = getFormat(locale).parse(value, parsePosition);\r
         if (parsePosition.getIndex() != value.length()) {\r
             throw new ConversionException("Could not convert '" + value\r
-                    + "' to " + getTargetType().getName());\r
+                    + "' to " + getPresentationType().getName());\r
         }\r
 \r
         if (parsedValue == null) {\r
@@ -78,7 +78,7 @@ public class NumberToStringConverter implements Converter<Number, String> {
      * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public String convertFromSourceToTarget(Number value, Locale locale)\r
+    public String convertToPresentation(Number value, Locale locale)\r
             throws ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -92,7 +92,7 @@ public class NumberToStringConverter implements Converter<Number, String> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getSourceType()\r
      */\r
-    public Class<Number> getSourceType() {\r
+    public Class<Number> getModelType() {\r
         return Number.class;\r
     }\r
 \r
@@ -101,7 +101,7 @@ public class NumberToStringConverter implements Converter<Number, String> {
      * \r
      * @see com.vaadin.data.util.converter.Converter#getTargetType()\r
      */\r
-    public Class<String> getTargetType() {\r
+    public Class<String> getPresentationType() {\r
         return String.class;\r
     }\r
 \r
index d3e2540b57ab532f4cf4ce7e5cf4ae397d1c9453..c86ba72395ef9eaa5fee5c0520174dde1f3182b4 100644 (file)
@@ -10,9 +10,9 @@ import java.util.Locale;
  * A converter that wraps another {@link Converter} and reverses source and\r
  * target types.\r
  * \r
- * @param <SOURCE>\r
+ * @param <MODEL>\r
  *            The source type\r
- * @param <TARGET>\r
+ * @param <PRESENTATION>\r
  *            The target type\r
  * \r
  * @author Vaadin Ltd\r
@@ -20,10 +20,10 @@ import java.util.Locale;
  * @VERSION@\r
  * @since 7.0\r
  */\r
-public class ReverseConverter<SOURCE, TARGET> implements\r
-        Converter<SOURCE, TARGET> {\r
+public class ReverseConverter<MODEL, PRESENTATION> implements\r
+        Converter<MODEL, PRESENTATION> {\r
 \r
-    private Converter<TARGET, SOURCE> realConverter;\r
+    private Converter<PRESENTATION, MODEL> realConverter;\r
 \r
     /**\r
      * Creates a converter from source to target based on a converter that\r
@@ -32,7 +32,7 @@ public class ReverseConverter<SOURCE, TARGET> implements
      * @param converter\r
      *            The converter to use in a reverse fashion\r
      */\r
-    public ReverseConverter(Converter<TARGET, SOURCE> converter) {\r
+    public ReverseConverter(Converter<PRESENTATION, MODEL> converter) {\r
         this.realConverter = converter;\r
     }\r
 \r
@@ -43,9 +43,9 @@ public class ReverseConverter<SOURCE, TARGET> implements
      * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public SOURCE convertFromTargetToSource(TARGET value, Locale locale)\r
+    public MODEL convertToModel(PRESENTATION value, Locale locale)\r
             throws com.vaadin.data.util.converter.Converter.ConversionException {\r
-        return realConverter.convertFromSourceToTarget(value, locale);\r
+        return realConverter.convertToPresentation(value, locale);\r
     }\r
 \r
     /*\r
@@ -55,9 +55,9 @@ public class ReverseConverter<SOURCE, TARGET> implements
      * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java\r
      * .lang.Object, java.util.Locale)\r
      */\r
-    public TARGET convertFromSourceToTarget(SOURCE value, Locale locale)\r
+    public PRESENTATION convertToPresentation(MODEL value, Locale locale)\r
             throws com.vaadin.data.util.converter.Converter.ConversionException {\r
-        return realConverter.convertFromTargetToSource(value, locale);\r
+        return realConverter.convertToModel(value, locale);\r
     }\r
 \r
     /*\r
@@ -65,8 +65,8 @@ public class ReverseConverter<SOURCE, TARGET> implements
      * \r
      * @see com.vaadin.data.util.converter.Converter#getSourceType()\r
      */\r
-    public Class<SOURCE> getSourceType() {\r
-        return realConverter.getTargetType();\r
+    public Class<MODEL> getModelType() {\r
+        return realConverter.getPresentationType();\r
     }\r
 \r
     /*\r
@@ -74,8 +74,8 @@ public class ReverseConverter<SOURCE, TARGET> implements
      * \r
      * @see com.vaadin.data.util.converter.Converter#getTargetType()\r
      */\r
-    public Class<TARGET> getTargetType() {\r
-        return realConverter.getSourceType();\r
+    public Class<PRESENTATION> getPresentationType() {\r
+        return realConverter.getModelType();\r
     }\r
 \r
 }\r
index d6ce5450960e3232a401a54eb28c0e9434398f9e..9e4bdde064e626f56b23522f51ddd0d1e533a9b2 100644 (file)
@@ -726,7 +726,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
 
         // Check if the current converter is compatible.
         if (newDataSource != null
-                && (getConverter() == null || !getConverter().getSourceType()
+                && (getConverter() == null || !getConverter().getModelType()
                         .isAssignableFrom(newDataSource.getType()))) {
             // Set a new converter if there is a new data source and the
             // there is no old converter or the old is incompatible.
@@ -813,7 +813,7 @@ public abstract class AbstractField<T> extends AbstractComponent implements
     private T convertFromDataSource(Object newValue)
             throws Converter.ConversionException {
         if (converter != null) {
-            return converter.convertFromSourceToTarget(newValue, getLocale());
+            return converter.convertToPresentation(newValue, getLocale());
         }
         if (newValue == null) {
             return null;
@@ -850,11 +850,11 @@ public abstract class AbstractField<T> extends AbstractComponent implements
              * an exception.
              */
             try {
-                return converter.convertFromTargetToSource(fieldValue,
+                return converter.convertToModel(fieldValue,
                         getLocale());
             } catch (com.vaadin.data.util.converter.Converter.ConversionException e) {
                 throw new Converter.ConversionException(
-                        getValueConversionError(converter.getSourceType()), e);
+                        getValueConversionError(converter.getModelType()), e);
             }
         }
 
@@ -1030,11 +1030,11 @@ public abstract class AbstractField<T> extends AbstractComponent implements
         // to validate the converted value
         if (getConverter() != null) {
             try {
-                valueToValidate = getConverter().convertFromTargetToSource(
+                valueToValidate = getConverter().convertToModel(
                         fieldValue, getLocale());
             } catch (Exception e) {
                 throw new InvalidValueException(
-                        getValueConversionError(getConverter().getSourceType()));
+                        getValueConversionError(getConverter().getModelType()));
             }
         }
 
index fabb632494aebd113b63b40a04e6412050417d21..5ab0fb9029ebde4070af508f3d93c443bb7c0bd7 100644 (file)
@@ -3476,7 +3476,7 @@ public class Table extends AbstractSelect implements Action.Container,
         }
         Object value = property.getValue();
         if (converter != null) {
-            return converter.convertFromSourceToTarget(value, getLocale());
+            return converter.convertToPresentation(value, getLocale());
         }
         return (null != value) ? value.toString() : "";
     }
@@ -5131,7 +5131,18 @@ public class Table extends AbstractSelect implements Action.Container,
         return rowGenerator;
     }
 
-    // FIXME: Javadoc
+    /**
+     * Sets a converter for a property id.
+     * <p>
+     * The converter is used to format the the data for the given property id
+     * before displaying it in the table.
+     * </p>
+     * 
+     * @param propertyId
+     *            The propertyId to format using the converter
+     * @param converter
+     *            The converter to use for the property id
+     */
     public void setConverter(Object propertyId, Converter<?, String> converter) {
         if (!getContainerPropertyIds().contains(propertyId)) {
             throw new IllegalArgumentException("PropertyId " + propertyId
@@ -5151,12 +5162,26 @@ public class Table extends AbstractSelect implements Action.Container,
         refreshRowCache();
     }
 
-    // FIXME: Javadoc
+    /**
+     * Checks if there is a converter set explicitly for the given property id.
+     * 
+     * @param propertyId
+     *            The propertyId to check
+     * @return true if a converter has been set for the property id, false
+     *         otherwise
+     */
     protected boolean hasConverter(Object propertyId) {
         return propertyValueConverters.containsKey(propertyId);
     }
 
-    // FIXME: Javadoc
+    /**
+     * Returns the converter used to format the given propertyId.
+     * 
+     * @param propertyId
+     *            The propertyId to check
+     * @return The converter used to format the propertyId or null if no
+     *         converter has been set
+     */
     public Converter<Object, String> getConverter(Object propertyId) {
         return propertyValueConverters.get(propertyId);
     }
index f39b479943a6e6e16a934be201d2e53a6fd9a404..9de7425423eae081dd753c3672a329f4ab524b67 100644 (file)
@@ -36,19 +36,19 @@ public class AbstractFieldValueConversions extends TestCase {
         TextField tf = new TextField();\r
         tf.setConverter(new Converter<String, String>() {\r
 \r
-            public String convertFromTargetToSource(String value, Locale locale) {\r
+            public String convertToModel(String value, Locale locale) {\r
                 return value;\r
             }\r
 \r
-            public String convertFromSourceToTarget(String value, Locale locale) {\r
+            public String convertToPresentation(String value, Locale locale) {\r
                 return value;\r
             }\r
 \r
-            public Class<String> getSourceType() {\r
+            public Class<String> getModelType() {\r
                 return String.class;\r
             }\r
 \r
-            public Class<String> getTargetType() {\r
+            public Class<String> getPresentationType() {\r
                 return String.class;\r
             }\r
         });\r
@@ -66,20 +66,20 @@ public class AbstractFieldValueConversions extends TestCase {
         TextField tf = new TextField();\r
         tf.setConverter(new Converter<Integer, String>() {\r
 \r
-            public Integer convertFromTargetToSource(String value, Locale locale) {\r
+            public Integer convertToModel(String value, Locale locale) {\r
                 throw new ConversionException("Failed");\r
             }\r
 \r
-            public String convertFromSourceToTarget(Integer value, Locale locale) {\r
+            public String convertToPresentation(Integer value, Locale locale) {\r
                 throw new ConversionException("Failed");\r
             }\r
 \r
-            public Class<Integer> getSourceType() {\r
+            public Class<Integer> getModelType() {\r
                 // TODO Auto-generated method stub\r
                 return null;\r
             }\r
 \r
-            public Class<String> getTargetType() {\r
+            public Class<String> getPresentationType() {\r
                 // TODO Auto-generated method stub\r
                 return null;\r
             }\r
@@ -111,7 +111,7 @@ public class AbstractFieldValueConversions extends TestCase {
         CheckBox cb = new CheckBox();\r
         cb.setConverter(new Converter<Boolean, Boolean>() {\r
 \r
-            public Boolean convertFromTargetToSource(Boolean value,\r
+            public Boolean convertToModel(Boolean value,\r
                     Locale locale) {\r
                 // value from a CheckBox should never be null as long as it is\r
                 // not set to null (handled by conversion below).\r
@@ -119,7 +119,7 @@ public class AbstractFieldValueConversions extends TestCase {
                 return value;\r
             }\r
 \r
-            public Boolean convertFromSourceToTarget(Boolean value,\r
+            public Boolean convertToPresentation(Boolean value,\r
                     Locale locale) {\r
                 // Datamodel -> field\r
                 if (value == null) {\r
@@ -129,11 +129,11 @@ public class AbstractFieldValueConversions extends TestCase {
                 return value;\r
             }\r
 \r
-            public Class<Boolean> getSourceType() {\r
+            public Class<Boolean> getModelType() {\r
                 return Boolean.class;\r
             }\r
 \r
-            public Class<Boolean> getTargetType() {\r
+            public Class<Boolean> getPresentationType() {\r
                 return Boolean.class;\r
             }\r
 \r
@@ -143,7 +143,7 @@ public class AbstractFieldValueConversions extends TestCase {
         cb.setPropertyDataSource(property);\r
         assertEquals(Boolean.FALSE, property.getValue());\r
         assertEquals(Boolean.FALSE, cb.getValue());\r
-        Boolean newDmValue = cb.getConverter().convertFromSourceToTarget(\r
+        Boolean newDmValue = cb.getConverter().convertToPresentation(\r
                 cb.getValue(), new Locale("fi", "FI"));\r
         assertEquals(Boolean.FALSE, newDmValue);\r
 \r
index 1d00fea17e418fe0d13cd4adffedb6794c4e0088..9ef42cf4b026aeb220bb24a0fa3da84611c2b441 100644 (file)
@@ -7,7 +7,7 @@ import com.vaadin.data.util.converter.Converter;
 public class Vaadin6ImplicitDoubleConverter implements\r
         Converter<Double, String> {\r
 \r
-    public Double convertFromTargetToSource(String value, Locale locale)\r
+    public Double convertToModel(String value, Locale locale)\r
             throws com.vaadin.data.util.converter.Converter.ConversionException {\r
         if (null == value) {\r
             return null;\r
@@ -15,7 +15,7 @@ public class Vaadin6ImplicitDoubleConverter implements
         return new Double(value.toString());\r
     }\r
 \r
-    public String convertFromSourceToTarget(Double value, Locale locale)\r
+    public String convertToPresentation(Double value, Locale locale)\r
             throws com.vaadin.data.util.converter.Converter.ConversionException {\r
         if (value == null) {\r
             return null;\r
@@ -24,11 +24,11 @@ public class Vaadin6ImplicitDoubleConverter implements
 \r
     }\r
 \r
-    public Class<Double> getSourceType() {\r
+    public Class<Double> getModelType() {\r
         return Double.class;\r
     }\r
 \r
-    public Class<String> getTargetType() {\r
+    public Class<String> getPresentationType() {\r
         return String.class;\r
     }\r
 \r
index 273114d2ea06e2b3f66a572af930a7ecdf4bf867..e92c1ab17ad91156ec69d4aec0a4e7d561dbf545 100644 (file)
@@ -145,14 +145,14 @@ public class DoublesInTable extends TestBase {
     private void addConverters(Table t) {\r
         t.setConverter("sex", new Converter<Sex, String>() {\r
 \r
-            public Sex convertFromTargetToSource(String value, Locale locale)\r
+            public Sex convertToModel(String value, Locale locale)\r
                     throws com.vaadin.data.util.converter.Converter.ConversionException {\r
                 // not used in this test - Table only converts from source to\r
                 // target\r
                 return null;\r
             }\r
 \r
-            public String convertFromSourceToTarget(Sex value, Locale locale)\r
+            public String convertToPresentation(Sex value, Locale locale)\r
                     throws com.vaadin.data.util.converter.Converter.ConversionException {\r
                 if (value == null) {\r
                     value = Sex.UNKNOWN;\r
@@ -160,23 +160,23 @@ public class DoublesInTable extends TestBase {
                 return value.getStringRepresentation();\r
             }\r
 \r
-            public Class<Sex> getSourceType() {\r
+            public Class<Sex> getModelType() {\r
                 return Sex.class;\r
             }\r
 \r
-            public Class<String> getTargetType() {\r
+            public Class<String> getPresentationType() {\r
                 return String.class;\r
             }\r
         });\r
         t.setConverter("deceased", new Converter<Boolean, String>() {\r
 \r
-            public Boolean convertFromTargetToSource(String value, Locale locale) {\r
+            public Boolean convertToModel(String value, Locale locale) {\r
                 // not used in this test - Table only converts from source to\r
                 // target\r
                 return null;\r
             }\r
 \r
-            public String convertFromSourceToTarget(Boolean value, Locale locale) {\r
+            public String convertToPresentation(Boolean value, Locale locale) {\r
                 if (value == null || value) {\r
                     return "YES, DEAD!";\r
                 } else {\r
@@ -184,24 +184,24 @@ public class DoublesInTable extends TestBase {
                 }\r
             }\r
 \r
-            public Class<Boolean> getSourceType() {\r
+            public Class<Boolean> getModelType() {\r
                 return Boolean.class;\r
             }\r
 \r
-            public Class<String> getTargetType() {\r
+            public Class<String> getPresentationType() {\r
                 return String.class;\r
             }\r
         });\r
         t.setConverter("age", new Converter<Integer, String>() {\r
 \r
-            public Integer convertFromTargetToSource(String value, Locale locale)\r
+            public Integer convertToModel(String value, Locale locale)\r
                     throws com.vaadin.data.util.converter.Converter.ConversionException {\r
                 // not used in this test - Table only converts from source to\r
                 // target\r
                 return null;\r
             }\r
 \r
-            public String convertFromSourceToTarget(Integer value, Locale locale)\r
+            public String convertToPresentation(Integer value, Locale locale)\r
                     throws com.vaadin.data.util.converter.Converter.ConversionException {\r
                 if (value == null) {\r
                     return null;\r
@@ -217,34 +217,34 @@ public class DoublesInTable extends TestBase {
                 }\r
             }\r
 \r
-            public Class<Integer> getSourceType() {\r
+            public Class<Integer> getModelType() {\r
                 return Integer.class;\r
             }\r
 \r
-            public Class<String> getTargetType() {\r
+            public Class<String> getPresentationType() {\r
                 return String.class;\r
             }\r
         });\r
         t.setConverter("address", new Converter<Address, String>() {\r
 \r
-            public Address convertFromTargetToSource(String value, Locale locale)\r
+            public Address convertToModel(String value, Locale locale)\r
                     throws ConversionException {\r
                 // not used in this test - Table only converts from source to\r
                 // target\r
                 return null;\r
             }\r
 \r
-            public String convertFromSourceToTarget(Address value, Locale locale)\r
+            public String convertToPresentation(Address value, Locale locale)\r
                     throws ConversionException {\r
                 return value.getStreetAddress() + ", " + value.getCity() + " ("\r
                         + value.getCountry() + ")";\r
             }\r
 \r
-            public Class<Address> getSourceType() {\r
+            public Class<Address> getModelType() {\r
                 return Address.class;\r
             }\r
 \r
-            public Class<String> getTargetType() {\r
+            public Class<String> getPresentationType() {\r
                 return String.class;\r
             }\r
 \r