Package org.exolab.castor.xml.validators
Class PatternValidator
java.lang.Object
org.exolab.castor.xml.validators.PatternValidator
- Direct Known Subclasses:
BigIntegerValidator
,BooleanValidator
,ByteValidator
,DateTimeValidator
,DecimalValidator
,DoubleValidator
,DurationValidator
,FloatValidator
,IntegerValidator
,IntValidator
,LongValidator
,ShortValidator
,StringValidator
A simple abstract class used for validating types which allow the pattern
facet.
- Version:
- $Revision: 8617 $ $Date: 2004-12-11 02:13:52 -0700 (Sat, 11 Dec 2004) $
- Author:
- Keith Visco, Edward Kuns
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCreates a newPatternValidator
with no initial regular expression.PatternValidator
(String pattern) Creates a newPatternValidator
with the given initial regular expression. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPattern
(String pattern) Sets the regular expression to validate against.void
Clear all configured patterns.Returns the collection of regular expression patterns.boolean
Returns true if a regular expression has been set for this PatternValidator.boolean
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.
-
Field Details
-
resourceBundle
-
-
Constructor Details
-
PatternValidator
public PatternValidator()Creates a newPatternValidator
with no initial regular expression. -
PatternValidator
Creates a newPatternValidator
with the given initial regular expression.- Parameters:
pattern
- the regular expression to validate against
-
-
Method Details
-
getPatterns
Returns the collection of regular expression patterns.- Returns:
- the collection of regular expression patterns.
- See Also:
-
isNillable
public boolean isNillable()Returns whether or not objects validated by this Validator are nillable (are allowed to be null).- Returns:
- true if null is a valid value
-
hasPattern
public boolean hasPattern()Returns true if a regular expression has been set for this PatternValidator.- Returns:
- true if a regular expression has been set for this PatternValidator
-
setNillable
public void setNillable(boolean nillable) Sets whether or not objects validated by this Validator are allowed to be null (nillable).- Parameters:
nillable
- a boolean that when true indicates null values pass validation
-
addPattern
Sets the regular expression to validate against.- Parameters:
pattern
- the regular expression to use when validating
-
clearPatterns
public void clearPatterns()Clear all configured patterns. -
validate
Validates the given String against the regular expression pattern of this PatternValidator.- Parameters:
str
- the string to validatecontext
- the validation context- Throws:
ValidationException
- if the given String is not matched by the regular expression pattern- See Also:
-
validate
Validates the given Object.- Parameters:
object
- the Object to validatecontext
- the ValidationContext- Throws:
ValidationException
- if the given String is not matched by the regular expression pattern
-