public abstract class PatternValidator extends Object
Modifier and Type | Field and Description |
---|---|
protected static ResourceBundle |
resourceBundle |
Constructor and Description |
---|
PatternValidator()
Creates a new
PatternValidator with no initial regular expression. |
PatternValidator(String pattern)
Creates a new
PatternValidator with the given initial regular expression. |
Modifier and Type | Method and Description |
---|---|
void |
addPattern(String pattern)
Sets the regular expression to validate against.
|
void |
clearPatterns()
Clear all configured patterns.
|
List<String> |
getPatterns()
Returns the collection of regular expression patterns.
|
boolean |
hasPattern()
Returns true if a regular expression has been set for this
PatternValidator.
|
boolean |
isNillable()
Returns whether or not objects validated by this Validator are nillable
(are allowed to be null).
|
void |
setNillable(boolean nillable)
Sets whether or not objects validated by this Validator are allowed to be
null (nillable).
|
void |
validate(Object object,
ValidationContext context)
Validates the given Object.
|
void |
validate(String str,
ValidationContext context)
Validates the given String against the regular expression pattern of this
PatternValidator.
|
protected static ResourceBundle resourceBundle
public PatternValidator()
PatternValidator
with no initial regular expression.public PatternValidator(String pattern)
PatternValidator
with the given initial regular expression.pattern
- the regular expression to validate againstpublic List<String> getPatterns()
#setPattern
public boolean isNillable()
public boolean hasPattern()
public void setNillable(boolean nillable)
nillable
- a boolean that when true indicates null values pass validationpublic void addPattern(String pattern)
pattern
- the regular expression to use when validatingpublic void clearPatterns()
public void validate(String str, ValidationContext context) throws ValidationException
str
- the string to validatecontext
- the validation contextValidationException
- if the given String is not matched by the regular expression
pattern#setPattern
public void validate(Object object, ValidationContext context) throws ValidationException
object
- the Object to validatecontext
- the ValidationContextValidationException
- if the given String is not matched by the regular expression
patternCopyright © 2019. All rights reserved.