org.apache.wicket.validation.validator
Class AbstractRangeValidator<R extends Comparable<R> & Serializable,V extends Serializable>

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.apache.wicket.validation.validator.AbstractRangeValidator<R,V>
Type Parameters:
R - type of range value
V - type of validatable
All Implemented Interfaces:
Serializable, IComponentAwareEventSink, IComponentAwareHeaderContributor, IClusterable, IValidator<V>
Direct Known Subclasses:
RangeValidator, StringValidator

public abstract class AbstractRangeValidator<R extends Comparable<R> & Serializable,V extends 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 are null they are not checked.

Resource keys:

Error Message Variables:

Author:
igor
See Also:
Serialized Form

Nested Class Summary
static class AbstractRangeValidator.Mode
          Validator mode
 
Constructor Summary
protected AbstractRangeValidator()
          Constructor used for subclasses who want to set the range using setRange(Comparable, Comparable)
  AbstractRangeValidator(R minimum, R maximum)
          Constructor that sets the minimum and maximum values.
 
Method Summary
protected  ValidationError decorate(ValidationError error, IValidatable<V> validatable)
          Allows subclasses to decorate reported errors
 R getMaximum()
          Gets the maximum value.
 R getMinimum()
          Gets the minimum value.
 AbstractRangeValidator.Mode getMode()
          Gets validation mode which is determined by whether min, max, or both values are provided
protected abstract  R getValue(IValidatable<V> validatable)
          Gets the value that should be validated against the range
protected  void setRange(R minimum, R maximum)
          Sets validator range
 void validate(IValidatable<V> validatable)
          Validates the IValidatable instance.
 
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, bind, canCallListenerInterface, detach, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onEvent, onException, onRemove, renderHead, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRangeValidator

public AbstractRangeValidator(R minimum,
                              R maximum)
Constructor that sets the minimum and maximum values.

Parameters:
minimum - the minimum value
maximum - the maximum value

AbstractRangeValidator

protected AbstractRangeValidator()
Constructor used for subclasses who want to set the range using setRange(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: IValidator
Validates the IValidatable instance. Validation errors should be reported using the IValidatable.error(IValidationError) method.

Specified by:
validate in interface IValidator<V extends Serializable>
Parameters:
validatable - the IValidatable instance 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 ValidationError decorate(ValidationError 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


Copyright © 2006–2015 Apache Software Foundation. All rights reserved.