org.exolab.castor.xml.validators

Class PatternValidator

public abstract class PatternValidator extends Object

A simple abstract class used for validating types which allow the pattern facet

Version: $Revision: 1.2 $ $Date: 2004/12/11 09:13:45 $

Author: Keith Visco

Nested Class Summary
classPatternValidator.DefaultRegExpEvaluator
A simple implementation of a regular expression validator which always returns false.
Constructor Summary
PatternValidator()
Creates a new PatternValidator with no default regular expression
PatternValidator(String pattern)
Creates a new PatternValidator with the given regular expresion
Method Summary
StringgetPattern()
Returns the regular expression pattern for this PatternValidator, or null if no pattern has been set.
booleanhasPattern()
Returns true if a regular expression has been set for this PatternValidator
booleanisNillable()
Returns whether or not objects validated by this Validator are nillable (are allowed to be null).
voidsetNillable(boolean nillable)
Sets whether or not objects validated by this Validator are allowed to be null (nillable).
voidsetPattern(String pattern)
Sets the regular expression to validate against
voidvalidate(String str, ValidationContext context)
Validates the given String against the regular expression pattern of this PatternValidator.
voidvalidate(Object object, ValidationContext context)
Validates the given Object

Constructor Detail

PatternValidator

public PatternValidator()
Creates a new PatternValidator with no default regular expression

PatternValidator

public PatternValidator(String pattern)
Creates a new PatternValidator with the given regular expresion

Parameters: pattern the regular expression to validate against

Method Detail

getPattern

public String getPattern()
Returns the regular expression pattern for this PatternValidator, or null if no pattern has been set.

Returns: the regular expression pattern

See Also: PatternValidator

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

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

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

setPattern

public void setPattern(String pattern)
Sets the regular expression to validate against

Parameters: pattern the regular expression to use when validating

validate

public void validate(String str, ValidationContext context)
Validates the given String against the regular expression pattern of this PatternValidator.

Throws: ValidationException if the given String is not matched by the regular expression pattern

See Also: PatternValidator

validate

public void validate(Object object, ValidationContext context)
Validates the given Object

Parameters: object the Object to validate context the ValidationContext

Intalio Inc. (C) 1999-2004. All rights reserved http://www.intalio.com