From: Artur Signell Date: Mon, 10 May 2010 15:05:00 +0000 (+0000) Subject: Updated javadoc (#4680) X-Git-Tag: 6.7.0.beta1~1678 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=096d6d628abc5cd0420ac9c5a228bb3a2772bdfd;p=vaadin-framework.git Updated javadoc (#4680) svn changeset:13123/svn branch:6.4 --- diff --git a/src/com/vaadin/data/validator/AbstractStringValidator.java b/src/com/vaadin/data/validator/AbstractStringValidator.java index 42dc5f25d9..359d83ef10 100644 --- a/src/com/vaadin/data/validator/AbstractStringValidator.java +++ b/src/com/vaadin/data/validator/AbstractStringValidator.java @@ -1,57 +1,71 @@ /* @ITMillApache2LicenseForJavaFiles@ */ -package com.vaadin.data.validator; - -/** - * Validator base class for validating strings. See - * {@link com.vaadin.data.validator.AbstractValidator} for more information. - * - *

- * If the validation fails, the exception thrown contains the error message with - * its argument 0 replaced with the string being validated. - *

- * - * @author IT Mill Ltd. - * @version - * @VERSION@ - * @since 5.4 - */ -@SuppressWarnings("serial") -public abstract class AbstractStringValidator extends AbstractValidator { - - /** - * Constructs a validator for strings. - *

- * Null and empty string values are always accepted. To disallow empty - * values, set the field being validated as required. - *

- * - * @param errorMessage - * the message included in the exception (with its parameter {0} - * replaced by the string to be validated) in case the validation - * fails - */ - public AbstractStringValidator(String errorMessage) { - super(errorMessage); - } - - public boolean isValid(Object value) { - if (value == null) { - return true; - } - if (!(value instanceof String)) { - return false; - } - return isValidString((String) value); - } - - /** - * Checks if the given string is valid. - * - * @param value - * String to check. Can never be null. - * @return true if the string is valid, false otherwise - */ - protected abstract boolean isValidString(String value); -} +package com.vaadin.data.validator; + +/** + * Validator base class for validating strings. See + * {@link com.vaadin.data.validator.AbstractValidator} for more information. + * + *

+ * To include the value that failed validation in the exception message you can + * use "{0}" in the error message. This will be replaced with the failed value + * (converted to string using {@link #toString()}) or "null" if the value is + * null. + *

+ * + * @author IT Mill Ltd. + * @version + * @VERSION@ + * @since 5.4 + */ +@SuppressWarnings("serial") +public abstract class AbstractStringValidator extends AbstractValidator { + + /** + * Constructs a validator for strings. + * + *

+ * Null and empty string values are always accepted. To reject empty values, + * set the field being validated as required. + *

+ * + * @param errorMessage + * the message to be included in an {@link InvalidValueException} + * (with "{0}" replaced by the value that failed validation). + * */ + public AbstractStringValidator(String errorMessage) { + super(errorMessage); + } + + /** + * Tests if the given value is a valid string. + *

+ * Null values are always accepted. Values that are not {@link String}s are + * always rejected. Uses {@link #isValidString(String)} to validate the + * value. + *

+ * + * @param value + * the value to check + * @return true if the value is a valid string, false otherwise + */ + public boolean isValid(Object value) { + if (value == null) { + return true; + } + if (!(value instanceof String)) { + return false; + } + return isValidString((String) value); + } + + /** + * Checks if the given string is valid. + * + * @param value + * String to check. Can never be null. + * @return true if the string is valid, false otherwise + */ + protected abstract boolean isValidString(String value); +}