com.vaadin.data.validator
Class RegexpValidator

java.lang.Object
  extended by com.vaadin.data.validator.AbstractValidator<String>
      extended by com.vaadin.data.validator.AbstractStringValidator
          extended by com.vaadin.data.validator.RegexpValidator
All Implemented Interfaces:
Validator, Serializable
Direct Known Subclasses:
EmailValidator

public class RegexpValidator
extends AbstractStringValidator

String validator comparing the string against a Java regular expression. Both complete matches and substring matches are supported.

For the Java regular expression syntax, see java.util.regex.Pattern#sum

See AbstractStringValidator for more information.

Since:
5.4
Version:
7.0.0.alpha3
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.data.Validator
Validator.EmptyValueException, Validator.InvalidValueException
 
Constructor Summary
RegexpValidator(String regexp, boolean complete, String errorMessage)
          Creates a validator for checking that the regular expression matches the string to validate.
RegexpValidator(String regexp, String errorMessage)
          Creates a validator for checking that the regular expression matches the complete string to validate.
 
Method Summary
protected  boolean isValidValue(String value)
          Internally check the validity of a value.
 
Methods inherited from class com.vaadin.data.validator.AbstractStringValidator
getType
 
Methods inherited from class com.vaadin.data.validator.AbstractValidator
getErrorMessage, isValid, isValidType, setErrorMessage, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexpValidator

public RegexpValidator(String regexp,
                       String errorMessage)
Creates a validator for checking that the regular expression matches the complete string to validate.

Parameters:
regexp - a Java regular expression
errorMessage - the message to display in case the value does not validate.

RegexpValidator

public RegexpValidator(String regexp,
                       boolean complete,
                       String errorMessage)
Creates a validator for checking that the regular expression matches the string to validate.

Parameters:
regexp - a Java regular expression
complete - true to use check for a complete match, false to look for a matching substring
errorMessage - the message to display in case the value does not validate.
Method Detail

isValidValue

protected boolean isValidValue(String value)
Description copied from class: AbstractValidator
Internally check the validity of a value. This method can be used to perform validation in subclasses if customization of the error message is not needed. Otherwise, subclasses should override AbstractValidator.validate(Object) and the return value of this method is ignored. This method should not be called from outside the validator class itself.

Specified by:
isValidValue in class AbstractValidator<String>
Returns:


Copyright © 2000-2011 Vaadin Ltd. All Rights Reserved.