From: Artur Signell Date: Wed, 21 Dec 2011 17:08:08 +0000 (+0200) Subject: #8101 Renamed source type to presentation and target type to model for X-Git-Tag: 7.0.0.alpha1~45 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b8a5152089990aa2b2454bc11dadbfd1d5362709;p=vaadin-framework.git #8101 Renamed source type to presentation and target type to model for clarity --- diff --git a/src/com/vaadin/data/util/converter/BooleanToStringConverter.java b/src/com/vaadin/data/util/converter/BooleanToStringConverter.java index 466f0f3b79..9c6add7c99 100644 --- a/src/com/vaadin/data/util/converter/BooleanToStringConverter.java +++ b/src/com/vaadin/data/util/converter/BooleanToStringConverter.java @@ -27,7 +27,7 @@ public class BooleanToStringConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java * .lang.Object, java.util.Locale) */ - public Boolean convertFromTargetToSource(String value, Locale locale) + public Boolean convertToModel(String value, Locale locale) throws ConversionException { if (value == null) { return null; @@ -61,7 +61,7 @@ public class BooleanToStringConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java * .lang.Object, java.util.Locale) */ - public String convertFromSourceToTarget(Boolean value, Locale locale) + public String convertToPresentation(Boolean value, Locale locale) throws ConversionException { if (value == null) { return null; @@ -78,7 +78,7 @@ public class BooleanToStringConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getSourceType() */ - public Class getSourceType() { + public Class getModelType() { return Boolean.class; } @@ -87,7 +87,7 @@ public class BooleanToStringConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getTargetType() */ - public Class getTargetType() { + public Class getPresentationType() { return String.class; } diff --git a/src/com/vaadin/data/util/converter/Converter.java b/src/com/vaadin/data/util/converter/Converter.java index 943d6ec76a..2a2c3025d9 100644 --- a/src/com/vaadin/data/util/converter/Converter.java +++ b/src/com/vaadin/data/util/converter/Converter.java @@ -8,13 +8,13 @@ import java.io.Serializable; import java.util.Locale; /** - * Interface that implements conversion between objects of one type to another - * and back. + * Interface that implements conversion between objects between model and + * presentation types. *

- * Typically {@link #convertFromSourceToTarget(Object, Locale)} and - * {@link #convertFromTargetToSource(Object, Locale)} should be symmetric so - * that chaining these together returns the original result for all input but - * this is not a requirement. + * Typically {@link #convertToPresentation(Object, Locale)} and + * {@link #convertToModel(Object, Locale)} should be symmetric so that chaining + * these together returns the original result for all input but this is not a + * requirement. *

*

* Converters must not have any side effects (never update UI from inside a @@ -27,18 +27,18 @@ import java.util.Locale; * If conversion of a value fails, a {@link ConversionException} is thrown. *

* - * @param - * The source type. Must be compatible with what - * {@link #getSourceType()} returns. - * @param - * The target type. Must be compatible with what - * {@link #getTargetType()} returns. + * @param + * The model type. Must be compatible with what + * {@link #getModelType()} returns. + * @param + * The presentation type. Must be compatible with what + * {@link #getPresentationType()} returns. * @author Vaadin Ltd. * @version * @VERSION@ * @since 7.0 */ -public interface Converter extends Serializable { +public interface Converter extends Serializable { /** * Converts the given value from target type to source type. @@ -46,9 +46,8 @@ public interface Converter extends Serializable { * A converter can optionally use locale to do the conversion. *

* A converter should in most cases be symmetric so chaining - * {@link #convertFromSourceToTarget(Object, Locale)} and - * {@link #convertFromTargetToSource(Object, Locale)} should return the - * original value. + * {@link #convertToPresentation(Object, Locale)} and + * {@link #convertToModel(Object, Locale)} should return the original value. * * @param value * The value to convert, compatible with the target type. Can be @@ -59,7 +58,7 @@ public interface Converter extends Serializable { * @throws ConversionException * If the value could not be converted */ - public SOURCE convertFromTargetToSource(TARGET value, Locale locale) + public MODEL convertToModel(PRESENTATION value, Locale locale) throws ConversionException; /** @@ -68,9 +67,8 @@ public interface Converter extends Serializable { * A converter can optionally use locale to do the conversion. *

* A converter should in most cases be symmetric so chaining - * {@link #convertFromSourceToTarget(Object, Locale)} and - * {@link #convertFromTargetToSource(Object, Locale)} should return the - * original value. + * {@link #convertToPresentation(Object, Locale)} and + * {@link #convertToModel(Object, Locale)} should return the original value. * * @param value * The value to convert, compatible with the target type. Can be @@ -81,34 +79,33 @@ public interface Converter extends Serializable { * @throws ConversionException * If the value could not be converted */ - public TARGET convertFromSourceToTarget(SOURCE value, Locale locale) + public PRESENTATION convertToPresentation(MODEL value, Locale locale) throws ConversionException; /** * The source type of the converter. * * Values of this type can be passed to - * {@link #convertFromSourceToTarget(Object, Locale)}. + * {@link #convertToPresentation(Object, Locale)}. * * @return The source type */ - public Class getSourceType(); + public Class getModelType(); /** * The target type of the converter. * * Values of this type can be passed to - * {@link #convertFromTargetToSource(Object, Locale)}. + * {@link #convertToModel(Object, Locale)}. * * @return The target type */ - public Class getTargetType(); + public Class getPresentationType(); /** * An exception that signals that the value passed to - * {@link Converter#convertFromSourceToTarget(Object, Locale)} or - * {@link Converter#convertFromTargetToSource(Object, Locale)} could not be - * converted. + * {@link Converter#convertToPresentation(Object, Locale)} or + * {@link Converter#convertToModel(Object, Locale)} could not be converted. * * @author Vaadin Ltd * @version diff --git a/src/com/vaadin/data/util/converter/DateToStringConverter.java b/src/com/vaadin/data/util/converter/DateToStringConverter.java index 56405b776a..947a426db6 100644 --- a/src/com/vaadin/data/util/converter/DateToStringConverter.java +++ b/src/com/vaadin/data/util/converter/DateToStringConverter.java @@ -28,8 +28,8 @@ public class DateToStringConverter implements Converter { /** * Returns the format used by - * {@link #convertFromSourceToTarget(Date, Locale)} and - * {@link #convertFromTargetToSource(String, Locale)}. + * {@link #convertToPresentation(Date, Locale)} and + * {@link #convertToModel(String, Locale)}. * * @param locale * The locale to use @@ -53,7 +53,7 @@ public class DateToStringConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java * .lang.Object, java.util.Locale) */ - public Date convertFromTargetToSource(String value, Locale locale) + public Date convertToModel(String value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { if (value == null) { return null; @@ -66,7 +66,7 @@ public class DateToStringConverter implements Converter { Date parsedValue = getFormat(locale).parse(value, parsePosition); if (parsePosition.getIndex() != value.length()) { throw new ConversionException("Could not convert '" + value - + "' to " + getTargetType().getName()); + + "' to " + getPresentationType().getName()); } return parsedValue; @@ -79,7 +79,7 @@ public class DateToStringConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java * .lang.Object, java.util.Locale) */ - public String convertFromSourceToTarget(Date value, Locale locale) + public String convertToPresentation(Date value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { if (value == null) { return null; @@ -93,7 +93,7 @@ public class DateToStringConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getSourceType() */ - public Class getSourceType() { + public Class getModelType() { return Date.class; } @@ -102,7 +102,7 @@ public class DateToStringConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getTargetType() */ - public Class getTargetType() { + public Class getPresentationType() { return String.class; } diff --git a/src/com/vaadin/data/util/converter/DoubleToStringConverter.java b/src/com/vaadin/data/util/converter/DoubleToStringConverter.java index e548936e2f..a6bebaddd3 100644 --- a/src/com/vaadin/data/util/converter/DoubleToStringConverter.java +++ b/src/com/vaadin/data/util/converter/DoubleToStringConverter.java @@ -28,8 +28,8 @@ public class DoubleToStringConverter implements Converter { /** * Returns the format used by - * {@link #convertFromSourceToTarget(Double, Locale)} and - * {@link #convertFromTargetToSource(String, Locale)}. + * {@link #convertToPresentation(Double, Locale)} and + * {@link #convertToModel(String, Locale)}. * * @param locale * The locale to use @@ -50,7 +50,7 @@ public class DoubleToStringConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java * .lang.Object, java.util.Locale) */ - public Double convertFromTargetToSource(String value, Locale locale) + public Double convertToModel(String value, Locale locale) throws ConversionException { if (value == null) { return null; @@ -63,7 +63,7 @@ public class DoubleToStringConverter implements Converter { Number parsedValue = getFormat(locale).parse(value, parsePosition); if (parsePosition.getIndex() != value.length()) { throw new ConversionException("Could not convert '" + value - + "' to " + getTargetType().getName()); + + "' to " + getPresentationType().getName()); } return parsedValue.doubleValue(); } @@ -75,7 +75,7 @@ public class DoubleToStringConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java * .lang.Object, java.util.Locale) */ - public String convertFromSourceToTarget(Double value, Locale locale) + public String convertToPresentation(Double value, Locale locale) throws ConversionException { if (value == null) { return null; @@ -89,7 +89,7 @@ public class DoubleToStringConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getSourceType() */ - public Class getSourceType() { + public Class getModelType() { return Double.class; } @@ -98,7 +98,7 @@ public class DoubleToStringConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getTargetType() */ - public Class getTargetType() { + public Class getPresentationType() { return String.class; } } diff --git a/src/com/vaadin/data/util/converter/IntegerToStringConverter.java b/src/com/vaadin/data/util/converter/IntegerToStringConverter.java index afd63b88c4..5c0d6761c0 100644 --- a/src/com/vaadin/data/util/converter/IntegerToStringConverter.java +++ b/src/com/vaadin/data/util/converter/IntegerToStringConverter.java @@ -25,8 +25,8 @@ public class IntegerToStringConverter implements Converter { /** * Returns the format used by - * {@link #convertFromSourceToTarget(Integer, Locale)} and - * {@link #convertFromTargetToSource(String, Locale)}. + * {@link #convertToPresentation(Integer, Locale)} and + * {@link #convertToModel(String, Locale)}. * * @param locale * The locale to use @@ -39,7 +39,7 @@ public class IntegerToStringConverter implements Converter { return NumberFormat.getIntegerInstance(locale); } - public Integer convertFromTargetToSource(String value, Locale locale) + public Integer convertToModel(String value, Locale locale) throws ConversionException { if (value == null) { return null; @@ -54,7 +54,7 @@ public class IntegerToStringConverter implements Converter { Number parsedValue = getFormat(locale).parse(value, parsePosition); if (parsePosition.getIndex() != value.length()) { throw new ConversionException("Could not convert '" + value - + "' to " + getSourceType().getName()); + + "' to " + getModelType().getName()); } if (parsedValue == null) { @@ -64,7 +64,7 @@ public class IntegerToStringConverter implements Converter { return parsedValue.intValue(); } - public String convertFromSourceToTarget(Integer value, Locale locale) + public String convertToPresentation(Integer value, Locale locale) throws ConversionException { if (value == null) { return null; @@ -73,11 +73,11 @@ public class IntegerToStringConverter implements Converter { return getFormat(locale).format(value); } - public Class getSourceType() { + public Class getModelType() { return Integer.class; } - public Class getTargetType() { + public Class getPresentationType() { return String.class; } diff --git a/src/com/vaadin/data/util/converter/LongToDateConverter.java b/src/com/vaadin/data/util/converter/LongToDateConverter.java index c7d2a33c76..c22e8af16e 100644 --- a/src/com/vaadin/data/util/converter/LongToDateConverter.java +++ b/src/com/vaadin/data/util/converter/LongToDateConverter.java @@ -24,7 +24,7 @@ public class LongToDateConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java * .lang.Object, java.util.Locale) */ - public Long convertFromTargetToSource(Date value, Locale locale) { + public Long convertToModel(Date value, Locale locale) { if (value == null) { return null; } @@ -39,7 +39,7 @@ public class LongToDateConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java * .lang.Object, java.util.Locale) */ - public Date convertFromSourceToTarget(Long value, Locale locale) { + public Date convertToPresentation(Long value, Locale locale) { if (value == null) { return null; } @@ -52,7 +52,7 @@ public class LongToDateConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getSourceType() */ - public Class getSourceType() { + public Class getModelType() { return Long.class; } @@ -61,7 +61,7 @@ public class LongToDateConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getTargetType() */ - public Class getTargetType() { + public Class getPresentationType() { return Date.class; } diff --git a/src/com/vaadin/data/util/converter/NumberToStringConverter.java b/src/com/vaadin/data/util/converter/NumberToStringConverter.java index 227751dbfd..cd4c1363b7 100644 --- a/src/com/vaadin/data/util/converter/NumberToStringConverter.java +++ b/src/com/vaadin/data/util/converter/NumberToStringConverter.java @@ -24,8 +24,8 @@ public class NumberToStringConverter implements Converter { /** * Returns the format used by - * {@link #convertFromSourceToTarget(Number, Locale)} and - * {@link #convertFromTargetToSource(String, Locale)}. + * {@link #convertToPresentation(Number, Locale)} and + * {@link #convertToModel(String, Locale)}. * * @param locale * The locale to use @@ -46,7 +46,7 @@ public class NumberToStringConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java * .lang.Object, java.util.Locale) */ - public Number convertFromTargetToSource(String value, Locale locale) + public Number convertToModel(String value, Locale locale) throws ConversionException { if (value == null) { return null; @@ -61,7 +61,7 @@ public class NumberToStringConverter implements Converter { Number parsedValue = getFormat(locale).parse(value, parsePosition); if (parsePosition.getIndex() != value.length()) { throw new ConversionException("Could not convert '" + value - + "' to " + getTargetType().getName()); + + "' to " + getPresentationType().getName()); } if (parsedValue == null) { @@ -78,7 +78,7 @@ public class NumberToStringConverter implements Converter { * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java * .lang.Object, java.util.Locale) */ - public String convertFromSourceToTarget(Number value, Locale locale) + public String convertToPresentation(Number value, Locale locale) throws ConversionException { if (value == null) { return null; @@ -92,7 +92,7 @@ public class NumberToStringConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getSourceType() */ - public Class getSourceType() { + public Class getModelType() { return Number.class; } @@ -101,7 +101,7 @@ public class NumberToStringConverter implements Converter { * * @see com.vaadin.data.util.converter.Converter#getTargetType() */ - public Class getTargetType() { + public Class getPresentationType() { return String.class; } diff --git a/src/com/vaadin/data/util/converter/ReverseConverter.java b/src/com/vaadin/data/util/converter/ReverseConverter.java index d3e2540b57..c86ba72395 100644 --- a/src/com/vaadin/data/util/converter/ReverseConverter.java +++ b/src/com/vaadin/data/util/converter/ReverseConverter.java @@ -10,9 +10,9 @@ import java.util.Locale; * A converter that wraps another {@link Converter} and reverses source and * target types. * - * @param + * @param * The source type - * @param + * @param * The target type * * @author Vaadin Ltd @@ -20,10 +20,10 @@ import java.util.Locale; * @VERSION@ * @since 7.0 */ -public class ReverseConverter implements - Converter { +public class ReverseConverter implements + Converter { - private Converter realConverter; + private Converter realConverter; /** * Creates a converter from source to target based on a converter that @@ -32,7 +32,7 @@ public class ReverseConverter implements * @param converter * The converter to use in a reverse fashion */ - public ReverseConverter(Converter converter) { + public ReverseConverter(Converter converter) { this.realConverter = converter; } @@ -43,9 +43,9 @@ public class ReverseConverter implements * com.vaadin.data.util.converter.Converter#convertFromTargetToSource(java * .lang.Object, java.util.Locale) */ - public SOURCE convertFromTargetToSource(TARGET value, Locale locale) + public MODEL convertToModel(PRESENTATION value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { - return realConverter.convertFromSourceToTarget(value, locale); + return realConverter.convertToPresentation(value, locale); } /* @@ -55,9 +55,9 @@ public class ReverseConverter implements * com.vaadin.data.util.converter.Converter#convertFromSourceToTarget(java * .lang.Object, java.util.Locale) */ - public TARGET convertFromSourceToTarget(SOURCE value, Locale locale) + public PRESENTATION convertToPresentation(MODEL value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { - return realConverter.convertFromTargetToSource(value, locale); + return realConverter.convertToModel(value, locale); } /* @@ -65,8 +65,8 @@ public class ReverseConverter implements * * @see com.vaadin.data.util.converter.Converter#getSourceType() */ - public Class getSourceType() { - return realConverter.getTargetType(); + public Class getModelType() { + return realConverter.getPresentationType(); } /* @@ -74,8 +74,8 @@ public class ReverseConverter implements * * @see com.vaadin.data.util.converter.Converter#getTargetType() */ - public Class getTargetType() { - return realConverter.getSourceType(); + public Class getPresentationType() { + return realConverter.getModelType(); } } diff --git a/src/com/vaadin/ui/AbstractField.java b/src/com/vaadin/ui/AbstractField.java index d6ce545096..9e4bdde064 100644 --- a/src/com/vaadin/ui/AbstractField.java +++ b/src/com/vaadin/ui/AbstractField.java @@ -726,7 +726,7 @@ public abstract class AbstractField 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 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 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 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())); } } diff --git a/src/com/vaadin/ui/Table.java b/src/com/vaadin/ui/Table.java index fabb632494..5ab0fb9029 100644 --- a/src/com/vaadin/ui/Table.java +++ b/src/com/vaadin/ui/Table.java @@ -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. + *

+ * The converter is used to format the the data for the given property id + * before displaying it in the table. + *

+ * + * @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 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 getConverter(Object propertyId) { return propertyValueConverters.get(propertyId); } diff --git a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java index f39b479943..9de7425423 100644 --- a/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java +++ b/tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java @@ -36,19 +36,19 @@ public class AbstractFieldValueConversions extends TestCase { TextField tf = new TextField(); tf.setConverter(new Converter() { - public String convertFromTargetToSource(String value, Locale locale) { + public String convertToModel(String value, Locale locale) { return value; } - public String convertFromSourceToTarget(String value, Locale locale) { + public String convertToPresentation(String value, Locale locale) { return value; } - public Class getSourceType() { + public Class getModelType() { return String.class; } - public Class getTargetType() { + public Class getPresentationType() { return String.class; } }); @@ -66,20 +66,20 @@ public class AbstractFieldValueConversions extends TestCase { TextField tf = new TextField(); tf.setConverter(new Converter() { - public Integer convertFromTargetToSource(String value, Locale locale) { + public Integer convertToModel(String value, Locale locale) { throw new ConversionException("Failed"); } - public String convertFromSourceToTarget(Integer value, Locale locale) { + public String convertToPresentation(Integer value, Locale locale) { throw new ConversionException("Failed"); } - public Class getSourceType() { + public Class getModelType() { // TODO Auto-generated method stub return null; } - public Class getTargetType() { + public Class getPresentationType() { // TODO Auto-generated method stub return null; } @@ -111,7 +111,7 @@ public class AbstractFieldValueConversions extends TestCase { CheckBox cb = new CheckBox(); cb.setConverter(new Converter() { - public Boolean convertFromTargetToSource(Boolean value, + public Boolean convertToModel(Boolean value, Locale locale) { // value from a CheckBox should never be null as long as it is // not set to null (handled by conversion below). @@ -119,7 +119,7 @@ public class AbstractFieldValueConversions extends TestCase { return value; } - public Boolean convertFromSourceToTarget(Boolean value, + public Boolean convertToPresentation(Boolean value, Locale locale) { // Datamodel -> field if (value == null) { @@ -129,11 +129,11 @@ public class AbstractFieldValueConversions extends TestCase { return value; } - public Class getSourceType() { + public Class getModelType() { return Boolean.class; } - public Class getTargetType() { + public Class getPresentationType() { return Boolean.class; } @@ -143,7 +143,7 @@ public class AbstractFieldValueConversions extends TestCase { cb.setPropertyDataSource(property); assertEquals(Boolean.FALSE, property.getValue()); assertEquals(Boolean.FALSE, cb.getValue()); - Boolean newDmValue = cb.getConverter().convertFromSourceToTarget( + Boolean newDmValue = cb.getConverter().convertToPresentation( cb.getValue(), new Locale("fi", "FI")); assertEquals(Boolean.FALSE, newDmValue); diff --git a/tests/testbench/com/vaadin/tests/components/abstractfield/Vaadin6ImplicitDoubleConverter.java b/tests/testbench/com/vaadin/tests/components/abstractfield/Vaadin6ImplicitDoubleConverter.java index 1d00fea17e..9ef42cf4b0 100644 --- a/tests/testbench/com/vaadin/tests/components/abstractfield/Vaadin6ImplicitDoubleConverter.java +++ b/tests/testbench/com/vaadin/tests/components/abstractfield/Vaadin6ImplicitDoubleConverter.java @@ -7,7 +7,7 @@ import com.vaadin.data.util.converter.Converter; public class Vaadin6ImplicitDoubleConverter implements Converter { - public Double convertFromTargetToSource(String value, Locale locale) + public Double convertToModel(String value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { if (null == value) { return null; @@ -15,7 +15,7 @@ public class Vaadin6ImplicitDoubleConverter implements return new Double(value.toString()); } - public String convertFromSourceToTarget(Double value, Locale locale) + public String convertToPresentation(Double value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { if (value == null) { return null; @@ -24,11 +24,11 @@ public class Vaadin6ImplicitDoubleConverter implements } - public Class getSourceType() { + public Class getModelType() { return Double.class; } - public Class getTargetType() { + public Class getPresentationType() { return String.class; } diff --git a/tests/testbench/com/vaadin/tests/components/table/DoublesInTable.java b/tests/testbench/com/vaadin/tests/components/table/DoublesInTable.java index 273114d2ea..e92c1ab17a 100644 --- a/tests/testbench/com/vaadin/tests/components/table/DoublesInTable.java +++ b/tests/testbench/com/vaadin/tests/components/table/DoublesInTable.java @@ -145,14 +145,14 @@ public class DoublesInTable extends TestBase { private void addConverters(Table t) { t.setConverter("sex", new Converter() { - public Sex convertFromTargetToSource(String value, Locale locale) + public Sex convertToModel(String value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { // not used in this test - Table only converts from source to // target return null; } - public String convertFromSourceToTarget(Sex value, Locale locale) + public String convertToPresentation(Sex value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { if (value == null) { value = Sex.UNKNOWN; @@ -160,23 +160,23 @@ public class DoublesInTable extends TestBase { return value.getStringRepresentation(); } - public Class getSourceType() { + public Class getModelType() { return Sex.class; } - public Class getTargetType() { + public Class getPresentationType() { return String.class; } }); t.setConverter("deceased", new Converter() { - public Boolean convertFromTargetToSource(String value, Locale locale) { + public Boolean convertToModel(String value, Locale locale) { // not used in this test - Table only converts from source to // target return null; } - public String convertFromSourceToTarget(Boolean value, Locale locale) { + public String convertToPresentation(Boolean value, Locale locale) { if (value == null || value) { return "YES, DEAD!"; } else { @@ -184,24 +184,24 @@ public class DoublesInTable extends TestBase { } } - public Class getSourceType() { + public Class getModelType() { return Boolean.class; } - public Class getTargetType() { + public Class getPresentationType() { return String.class; } }); t.setConverter("age", new Converter() { - public Integer convertFromTargetToSource(String value, Locale locale) + public Integer convertToModel(String value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { // not used in this test - Table only converts from source to // target return null; } - public String convertFromSourceToTarget(Integer value, Locale locale) + public String convertToPresentation(Integer value, Locale locale) throws com.vaadin.data.util.converter.Converter.ConversionException { if (value == null) { return null; @@ -217,34 +217,34 @@ public class DoublesInTable extends TestBase { } } - public Class getSourceType() { + public Class getModelType() { return Integer.class; } - public Class getTargetType() { + public Class getPresentationType() { return String.class; } }); t.setConverter("address", new Converter() { - public Address convertFromTargetToSource(String value, Locale locale) + public Address convertToModel(String value, Locale locale) throws ConversionException { // not used in this test - Table only converts from source to // target return null; } - public String convertFromSourceToTarget(Address value, Locale locale) + public String convertToPresentation(Address value, Locale locale) throws ConversionException { return value.getStreetAddress() + ", " + value.getCity() + " (" + value.getCountry() + ")"; } - public Class
getSourceType() { + public Class
getModelType() { return Address.class; } - public Class getTargetType() { + public Class getPresentationType() { return String.class; }