blob: db639f385623435155a82ec272457da06fd7b240 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*
@ITMillApache2LicenseForJavaFiles@
*/
package com.vaadin.data.validator;
/**
* String validator for a double precision floating point number. See
* {@link com.vaadin.data.validator.AbstractStringValidator} for more
* information.
*
* @author IT Mill Ltd.
* @version
* @VERSION@
* @since 5.4
*/
@SuppressWarnings("serial")
public class DoubleValidator extends AbstractStringValidator {
/**
* Creates a validator for checking that a string can be parsed as an
* double.
*
* @param errorMessage
* the message to display in case the value does not validate.
*/
public DoubleValidator(String errorMessage) {
super(errorMessage);
}
@Override
protected boolean isValidString(String value) {
try {
Double.parseDouble(value);
return true;
} catch (Exception e) {
return false;
}
}
}
|