Browse Source

#8101 Renamed source type to presentation and target type to model for

clarity
tags/7.0.0.alpha1
Artur Signell 12 years ago
parent
commit
b8a5152089

+ 4
- 4
src/com/vaadin/data/util/converter/BooleanToStringConverter.java View File

@@ -27,7 +27,7 @@ public class BooleanToStringConverter implements Converter<Boolean, String> {
* 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<Boolean, String> {
* 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<Boolean, String> {
*
* @see com.vaadin.data.util.converter.Converter#getSourceType()
*/
public Class<Boolean> getSourceType() {
public Class<Boolean> getModelType() {
return Boolean.class;
}
@@ -87,7 +87,7 @@ public class BooleanToStringConverter implements Converter<Boolean, String> {
*
* @see com.vaadin.data.util.converter.Converter#getTargetType()
*/
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}

+ 25
- 28
src/com/vaadin/data/util/converter/Converter.java View File

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

+ 7
- 7
src/com/vaadin/data/util/converter/DateToStringConverter.java View File

@@ -28,8 +28,8 @@ public class DateToStringConverter implements Converter<Date, String> {
/**
* 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<Date, String> {
* 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, String> {
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<Date, String> {
* 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<Date, String> {
*
* @see com.vaadin.data.util.converter.Converter#getSourceType()
*/
public Class<Date> getSourceType() {
public Class<Date> getModelType() {
return Date.class;
}
@@ -102,7 +102,7 @@ public class DateToStringConverter implements Converter<Date, String> {
*
* @see com.vaadin.data.util.converter.Converter#getTargetType()
*/
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}

+ 7
- 7
src/com/vaadin/data/util/converter/DoubleToStringConverter.java View File

@@ -28,8 +28,8 @@ public class DoubleToStringConverter implements Converter<Double, String> {
/**
* 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<Double, String> {
* 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<Double, String> {
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<Double, String> {
* 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<Double, String> {
*
* @see com.vaadin.data.util.converter.Converter#getSourceType()
*/
public Class<Double> getSourceType() {
public Class<Double> getModelType() {
return Double.class;
}
@@ -98,7 +98,7 @@ public class DoubleToStringConverter implements Converter<Double, String> {
*
* @see com.vaadin.data.util.converter.Converter#getTargetType()
*/
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}
}

+ 7
- 7
src/com/vaadin/data/util/converter/IntegerToStringConverter.java View File

@@ -25,8 +25,8 @@ public class IntegerToStringConverter implements Converter<Integer, String> {
/**
* 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<Integer, String> {
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<Integer, String> {
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<Integer, String> {
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<Integer, String> {
return getFormat(locale).format(value);
}
public Class<Integer> getSourceType() {
public Class<Integer> getModelType() {
return Integer.class;
}
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}

+ 4
- 4
src/com/vaadin/data/util/converter/LongToDateConverter.java View File

@@ -24,7 +24,7 @@ public class LongToDateConverter implements Converter<Long, Date> {
* 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<Long, Date> {
* 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<Long, Date> {
*
* @see com.vaadin.data.util.converter.Converter#getSourceType()
*/
public Class<Long> getSourceType() {
public Class<Long> getModelType() {
return Long.class;
}
@@ -61,7 +61,7 @@ public class LongToDateConverter implements Converter<Long, Date> {
*
* @see com.vaadin.data.util.converter.Converter#getTargetType()
*/
public Class<Date> getTargetType() {
public Class<Date> getPresentationType() {
return Date.class;
}

+ 7
- 7
src/com/vaadin/data/util/converter/NumberToStringConverter.java View File

@@ -24,8 +24,8 @@ public class NumberToStringConverter implements Converter<Number, String> {
/**
* 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<Number, String> {
* 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, String> {
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<Number, String> {
* 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<Number, String> {
*
* @see com.vaadin.data.util.converter.Converter#getSourceType()
*/
public Class<Number> getSourceType() {
public Class<Number> getModelType() {
return Number.class;
}
@@ -101,7 +101,7 @@ public class NumberToStringConverter implements Converter<Number, String> {
*
* @see com.vaadin.data.util.converter.Converter#getTargetType()
*/
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}

+ 14
- 14
src/com/vaadin/data/util/converter/ReverseConverter.java View File

@@ -10,9 +10,9 @@ import java.util.Locale;
* A converter that wraps another {@link Converter} and reverses source and
* target types.
*
* @param <SOURCE>
* @param <MODEL>
* The source type
* @param <TARGET>
* @param <PRESENTATION>
* The target type
*
* @author Vaadin Ltd
@@ -20,10 +20,10 @@ import java.util.Locale;
* @VERSION@
* @since 7.0
*/
public class ReverseConverter<SOURCE, TARGET> implements
Converter<SOURCE, TARGET> {
public class ReverseConverter<MODEL, PRESENTATION> implements
Converter<MODEL, PRESENTATION> {
private Converter<TARGET, SOURCE> realConverter;
private Converter<PRESENTATION, MODEL> realConverter;
/**
* Creates a converter from source to target based on a converter that
@@ -32,7 +32,7 @@ public class ReverseConverter<SOURCE, TARGET> implements
* @param converter
* The converter to use in a reverse fashion
*/
public ReverseConverter(Converter<TARGET, SOURCE> converter) {
public ReverseConverter(Converter<PRESENTATION, MODEL> converter) {
this.realConverter = converter;
}
@@ -43,9 +43,9 @@ public class ReverseConverter<SOURCE, TARGET> 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<SOURCE, TARGET> 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<SOURCE, TARGET> implements
*
* @see com.vaadin.data.util.converter.Converter#getSourceType()
*/
public Class<SOURCE> getSourceType() {
return realConverter.getTargetType();
public Class<MODEL> getModelType() {
return realConverter.getPresentationType();
}
/*
@@ -74,8 +74,8 @@ public class ReverseConverter<SOURCE, TARGET> implements
*
* @see com.vaadin.data.util.converter.Converter#getTargetType()
*/
public Class<TARGET> getTargetType() {
return realConverter.getSourceType();
public Class<PRESENTATION> getPresentationType() {
return realConverter.getModelType();
}
}

+ 6
- 6
src/com/vaadin/ui/AbstractField.java View 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()));
}
}


+ 29
- 4
src/com/vaadin/ui/Table.java View 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);
}

+ 13
- 13
tests/server-side/com/vaadin/tests/server/component/abstractfield/AbstractFieldValueConversions.java View File

@@ -36,19 +36,19 @@ public class AbstractFieldValueConversions extends TestCase {
TextField tf = new TextField();
tf.setConverter(new Converter<String, String>() {
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<String> getSourceType() {
public Class<String> getModelType() {
return String.class;
}
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}
});
@@ -66,20 +66,20 @@ public class AbstractFieldValueConversions extends TestCase {
TextField tf = new TextField();
tf.setConverter(new Converter<Integer, String>() {
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<Integer> getSourceType() {
public Class<Integer> getModelType() {
// TODO Auto-generated method stub
return null;
}
public Class<String> getTargetType() {
public Class<String> 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<Boolean, Boolean>() {
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<Boolean> getSourceType() {
public Class<Boolean> getModelType() {
return Boolean.class;
}
public Class<Boolean> getTargetType() {
public Class<Boolean> 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);

+ 4
- 4
tests/testbench/com/vaadin/tests/components/abstractfield/Vaadin6ImplicitDoubleConverter.java View File

@@ -7,7 +7,7 @@ import com.vaadin.data.util.converter.Converter;
public class Vaadin6ImplicitDoubleConverter implements
Converter<Double, String> {
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<Double> getSourceType() {
public Class<Double> getModelType() {
return Double.class;
}
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}

+ 16
- 16
tests/testbench/com/vaadin/tests/components/table/DoublesInTable.java View File

@@ -145,14 +145,14 @@ public class DoublesInTable extends TestBase {
private void addConverters(Table t) {
t.setConverter("sex", new Converter<Sex, String>() {
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<Sex> getSourceType() {
public Class<Sex> getModelType() {
return Sex.class;
}
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}
});
t.setConverter("deceased", new Converter<Boolean, String>() {
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<Boolean> getSourceType() {
public Class<Boolean> getModelType() {
return Boolean.class;
}
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}
});
t.setConverter("age", new Converter<Integer, String>() {
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<Integer> getSourceType() {
public Class<Integer> getModelType() {
return Integer.class;
}
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}
});
t.setConverter("address", new Converter<Address, String>() {
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<Address> getSourceType() {
public Class<Address> getModelType() {
return Address.class;
}
public Class<String> getTargetType() {
public Class<String> getPresentationType() {
return String.class;
}

Loading…
Cancel
Save