Class AbstractRangeValidator<R extends java.lang.Comparable<? super R> & java.io.Serializable,V extends java.io.Serializable>
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.validation.validator.AbstractRangeValidator<R,V>
-
- Type Parameters:
R- type of range valueV- type of validatable
- All Implemented Interfaces:
java.io.Serializable,IComponentAwareEventSink,IComponentAwareHeaderContributor,org.apache.wicket.util.io.IClusterable,IValidator<V>
- Direct Known Subclasses:
RangeValidator,StringValidator
public abstract class AbstractRangeValidator<R extends java.lang.Comparable<? super R> & java.io.Serializable,V extends java.io.Serializable> extends Behavior implements IValidator<V>
Base class for validators that check if a given value falls within [min,max] range. If either min or max arenullthey are not checked.Resource keys:
<class.simpleName>.exactif min==max<class.simpleName>.rangeif both min and max are notnull<class.simpleName>.minimumif max isnull<class.simpleName>.maximumif min isnull
Error Message Variables:
name: the id ofComponentthat failedlabel: the label of theComponent(either comes fromFormComponent.labelModelor resource key<form-id>.<form-component-id>input: the input valueminimum: the minimum allowed valuemaximum: the maximum allowed value
- Author:
- igor
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractRangeValidator.ModeValidator mode
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRangeValidator()Constructor used for subclasses who want to set the range usingsetRange(Comparable, Comparable)AbstractRangeValidator(R minimum, R maximum)Constructor that sets the minimum and maximum values.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected IValidationErrordecorate(IValidationError error, IValidatable<V> validatable)Allows subclasses to decorate reported errorsRgetMaximum()Gets the maximum value.RgetMinimum()Gets the minimum value.AbstractRangeValidator.ModegetMode()Gets validation mode which is determined by whether min, max, or both values are providedprotected abstract RgetValue(IValidatable<V> validatable)Gets the value that should be validated against the rangeprotected voidsetRange(R minimum, R maximum)Sets validator rangevoidvalidate(IValidatable<V> validatable)Validates theIValidatableinstance.-
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, bind, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onComponentTag, onConfigure, onEvent, onException, onRemove, onTag, renderHead, unbind
-
-
-
-
Constructor Detail
-
AbstractRangeValidator
public AbstractRangeValidator(R minimum, R maximum)
Constructor that sets the minimum and maximum values.- Parameters:
minimum- the minimum valuemaximum- the maximum value
-
AbstractRangeValidator
protected AbstractRangeValidator()
Constructor used for subclasses who want to set the range usingsetRange(Comparable, Comparable)
-
-
Method Detail
-
setRange
protected final void setRange(R minimum, R maximum)
Sets validator range- Parameters:
minimum-maximum-
-
validate
public void validate(IValidatable<V> validatable)
Description copied from interface:IValidatorValidates theIValidatableinstance. Validation errors should be reported using theIValidatable.error(IValidationError)method.- Specified by:
validatein interfaceIValidator<R extends java.lang.Comparable<? super R> & java.io.Serializable>- Parameters:
validatable- theIValidatableinstance being validated
-
getValue
protected abstract R getValue(IValidatable<V> validatable)
Gets the value that should be validated against the range- Parameters:
validatable-- Returns:
- value to validate
-
getMinimum
public R getMinimum()
Gets the minimum value.- Returns:
- minimum value
-
getMaximum
public R getMaximum()
Gets the maximum value.- Returns:
- maximum value
-
decorate
protected IValidationError decorate(IValidationError error, IValidatable<V> validatable)
Allows subclasses to decorate reported errors- Parameters:
error-validatable-- Returns:
- decorated error
-
getMode
public final AbstractRangeValidator.Mode getMode()
Gets validation mode which is determined by whether min, max, or both values are provided- Returns:
- validation mode
-
-