aboutsummaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
Diffstat (limited to 'server/src')
-rw-r--r--server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java1
-rw-r--r--server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java7
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToBigIntegerConverter.java11
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToByteConverter.java2
-rw-r--r--server/src/com/vaadin/data/util/converter/StringToShortConverter.java2
5 files changed, 18 insertions, 5 deletions
diff --git a/server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java b/server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java
index 9054f258c7..81f1a85f89 100644
--- a/server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java
+++ b/server/src/com/vaadin/data/util/converter/AbstractStringToNumberConverter.java
@@ -88,6 +88,7 @@ public abstract class AbstractStringToNumberConverter<T> implements
// Convert "" to null
return null;
}
+
return parsedValue;
}
diff --git a/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java b/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
index 26613c5d02..3a1f1a4252 100644
--- a/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
+++ b/server/src/com/vaadin/data/util/converter/DefaultConverterFactory.java
@@ -17,6 +17,7 @@
package com.vaadin.data.util.converter;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.util.Date;
import java.util.logging.Logger;
@@ -112,6 +113,12 @@ public class DefaultConverterFactory implements ConverterFactory {
return new StringToDateConverter();
} else if (Enum.class.isAssignableFrom(sourceType)) {
return new StringToEnumConverter();
+ } else if (BigInteger.class.isAssignableFrom(sourceType)) {
+ return new StringToBigIntegerConverter();
+ } else if (Short.class.isAssignableFrom(sourceType)) {
+ return new StringToShortConverter();
+ } else if (Byte.class.isAssignableFrom(sourceType)) {
+ return new StringToByteConverter();
} else {
return null;
}
diff --git a/server/src/com/vaadin/data/util/converter/StringToBigIntegerConverter.java b/server/src/com/vaadin/data/util/converter/StringToBigIntegerConverter.java
index 1e830c1fd2..d176ac2e0d 100644
--- a/server/src/com/vaadin/data/util/converter/StringToBigIntegerConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToBigIntegerConverter.java
@@ -15,6 +15,7 @@
*/
package com.vaadin.data.util.converter;
+import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.text.NumberFormat;
@@ -32,7 +33,7 @@ import java.util.Locale;
* </p>
*
* @author Vaadin Ltd
- * @since 7.3.1
+ * @since
*/
public class StringToBigIntegerConverter extends
AbstractStringToNumberConverter<BigInteger> {
@@ -41,7 +42,7 @@ public class StringToBigIntegerConverter extends
protected NumberFormat getFormat(Locale locale) {
NumberFormat numberFormat = super.getFormat(locale);
if (numberFormat instanceof DecimalFormat) {
- ((DecimalFormat) numberFormat).setParseIntegerOnly(true);
+ ((DecimalFormat) numberFormat).setParseBigDecimal(true);
}
return numberFormat;
@@ -51,7 +52,11 @@ public class StringToBigIntegerConverter extends
public BigInteger convertToModel(String value,
Class<? extends BigInteger> targetType, Locale locale)
throws com.vaadin.data.util.converter.Converter.ConversionException {
- return (BigInteger) convertToNumber(value, BigInteger.class, locale);
+
+ BigDecimal bigDecimalValue = (BigDecimal) convertToNumber(value,
+ BigDecimal.class, locale);
+
+ return (bigDecimalValue != null) ? bigDecimalValue.toBigInteger() : null;
}
@Override
diff --git a/server/src/com/vaadin/data/util/converter/StringToByteConverter.java b/server/src/com/vaadin/data/util/converter/StringToByteConverter.java
index b14182dc3f..26f52d108a 100644
--- a/server/src/com/vaadin/data/util/converter/StringToByteConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToByteConverter.java
@@ -28,7 +28,7 @@ import java.util.Locale;
* </p>
*
* @author Vaadin Ltd
- * @since 7.3.1
+ * @since
*/
public class StringToByteConverter extends
AbstractStringToNumberConverter<Byte> {
diff --git a/server/src/com/vaadin/data/util/converter/StringToShortConverter.java b/server/src/com/vaadin/data/util/converter/StringToShortConverter.java
index 3761d11227..4ee085286f 100644
--- a/server/src/com/vaadin/data/util/converter/StringToShortConverter.java
+++ b/server/src/com/vaadin/data/util/converter/StringToShortConverter.java
@@ -28,7 +28,7 @@ import java.util.Locale;
* </p>
*
* @author Vaadin Ltd
- * @since 7.3.1
+ * @since
*/
public class StringToShortConverter extends
AbstractStringToNumberConverter<Short> {