|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.data.validator.AbstractValidator<T>
T - The typepublic abstract class AbstractValidator<T>
Abstract Validator implementation that
provides a basic Validator implementation except the
isValidValue(Object) method.
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 Object.toString()) or "null" if the value is
null.
The default implementation of AbstractValidator does not support HTML in
error messages. To enable HTML support, override
InvalidValueException#getHtmlMessage() and throw such exceptions from
validate(Object).
Since Vaadin 7, subclasses can either implement validate(Object)
directly or implement isValidValue(Object) when migrating legacy
applications. To check validity, validate(Object) should be used.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.vaadin.data.Validator |
|---|
Validator.EmptyValueException, Validator.InvalidValueException |
| Constructor Summary | |
|---|---|
AbstractValidator(java.lang.String errorMessage)
Constructs a validator with the given error message. |
|
| Method Summary | |
|---|---|
java.lang.String |
getErrorMessage()
Returns the message to be included in the exception in case the value does not validate. |
abstract java.lang.Class<T> |
getType()
|
boolean |
isValid(java.lang.Object value)
Since Vaadin 7, subclasses of AbstractValidator should override isValidValue(Object) or validate(Object) instead of
isValid(Object). |
protected boolean |
isValidType(java.lang.Object value)
Checks the type of the value to validate to ensure it conforms with getType. |
protected abstract boolean |
isValidValue(T value)
Internally check the validity of a value. |
void |
setErrorMessage(java.lang.String errorMessage)
Sets the message to be included in the exception in case the value does not validate. |
void |
validate(java.lang.Object value)
Checks the given value against this validator. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public AbstractValidator(java.lang.String errorMessage)
errorMessage - the message to be included in an InvalidValueException
(with "{0}" replaced by the value that failed validation).| Method Detail |
|---|
public boolean isValid(java.lang.Object value)
isValidValue(Object) or validate(Object) instead of
isValid(Object). validate(Object) should normally be
used to check values.
value -
protected abstract boolean isValidValue(T value)
validate(Object) and the return value of this method is ignored.
This method should not be called from outside the validator class itself.
value -
public void validate(java.lang.Object value)
throws Validator.InvalidValueException
ValidatorValidator.InvalidValueException is thrown.
validate in interface Validatorvalue - the value to check
Validator.InvalidValueException - if the value is invalidprotected boolean isValidType(java.lang.Object value)
value - The value to check
getType()public java.lang.String getErrorMessage()
setErrorMessage(String).public void setErrorMessage(java.lang.String errorMessage)
errorMessage - the error message. "{0}" is automatically replaced by the
value that did not validate.public abstract java.lang.Class<T> getType()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||