|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.vaadin.data.validator.AbstractValidator
com.vaadin.data.validator.CompositeValidator
public class CompositeValidator
The CompositeValidator
allows you to chain (compose) many
validators to validate one field. The contained validators may be required to
all validate the value to validate or it may be enough that one contained
validator validates the value. This behaviour is controlled by the modes
AND
and OR
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface com.vaadin.data.Validator |
---|
Validator.EmptyValueException, Validator.InvalidValueException |
Field Summary | |
---|---|
static int |
MODE_AND
The validators are combined with AND clause: validity of the
composite implies validity of the all validators it is composed of must
be valid. |
static int |
MODE_DEFAULT
The validators are combined with and clause: validity of the composite implies validity of the all validators it is composed of |
static int |
MODE_OR
The validators are combined with OR clause: validity of the
composite implies that some of validators it is composed of must be
valid. |
Constructor Summary | |
---|---|
CompositeValidator()
Construct a composite validator in AND mode without error
message. |
|
CompositeValidator(int mode,
String errorMessage)
Constructs a composite validator in given mode. |
Method Summary | |
---|---|
void |
addValidator(Validator validator)
Adds validator to the interface. |
String |
getErrorMessage()
Gets the error message for the composite validator. |
int |
getMode()
Gets the mode of the validator. |
Collection<Validator> |
getSubValidators(Class validatorType)
Gets sub-validators by class. |
boolean |
isValid(Object value)
Checks the validity of the the given value. |
void |
removeValidator(Validator validator)
Removes a validator from the composite. |
void |
setMode(int mode)
Sets the mode of the validator. |
void |
validate(Object value)
Validates the given value. |
Methods inherited from class com.vaadin.data.validator.AbstractValidator |
---|
setErrorMessage |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int MODE_AND
AND
clause: validity of the
composite implies validity of the all validators it is composed of must
be valid.
public static final int MODE_OR
OR
clause: validity of the
composite implies that some of validators it is composed of must be
valid.
public static final int MODE_DEFAULT
Constructor Detail |
---|
public CompositeValidator()
AND
mode without error
message.
public CompositeValidator(int mode, String errorMessage)
Method Detail |
---|
public void validate(Object value) throws Validator.InvalidValueException
The value is valid, if:
MODE_AND
: All of the sub-validators are valid
MODE_OR
: Any of the sub-validators are valid
validate
in interface Validator
validate
in class AbstractValidator
value
- the value to check.
Validator.InvalidValueException
- if the value is not valid.public boolean isValid(Object value)
MODE_AND
: All of the sub-validators are valid
MODE_OR
: Any of the sub-validators are valid
value
- the value to check.
true
if the value is valid, false
otherwise.public final int getMode()
MODE_AND
or
MODE_OR
.public void setMode(int mode)
MODE_AND
(default)
MODE_OR
mode
- the mode to set.public String getErrorMessage()
getErrorMessage
in class AbstractValidator
AbstractValidator.setErrorMessage(String)
.public void addValidator(Validator validator)
validator
- the Validator object which performs validation checks on this
set of data field values.public void removeValidator(Validator validator)
validator
- the Validator object which performs validation checks on this
set of data field values.public Collection<Validator> getSubValidators(Class validatorType)
If the component contains directly or recursively (it contains another
composite containing the validator) validators compatible with given type
they are returned. This only applies to AND
mode composite
validators.
If the validator is in OR
mode or does not contain any
validators of given type null is returned.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |