You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DoubleValidator.java 963B

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