org.exolab.castor.xml.validators

Class PatternValidator

Known Direct Subclasses:
ByteValidator, DoubleValidator, FloatValidator, IntegerValidator, LongValidator, ShortValidator, StringValidator

public abstract class PatternValidator
extends java.lang.Object

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

Version:
$Revision: 1.1.1.1 $ $Date: 2003/03/03 07:09:52 $

Author:
Keith Visco

Nested Class Summary

(package private) class
PatternValidator.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

String
getPattern()
Returns the regular expression pattern for this PatternValidator, or null if no pattern has been set.
boolean
hasPattern()
Returns true if a regular expression has been set for this PatternValidator
void
setPattern(String pattern)
Sets the regular expression to validate against
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.

Constructor Details

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 Details

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:
setPattern(String)


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


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(Object object,
                     ValidationContext context)
            throws ValidationException
Validates the given Object

Parameters:
object - the Object to validate
context - the ValidationContext


validate

public void validate(String str,
                     ValidationContext context)
            throws ValidationException
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:
setPattern(String)


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