org.springframework.rules.constraint
Class RegexpConstraint

java.lang.Object
  extended by org.springframework.rules.reporting.TypeResolvableSupport
      extended by org.springframework.rules.constraint.RegexpConstraint
All Implemented Interfaces:
MessageSourceResolvable, Constraint, TypeResolvable

public class RegexpConstraint
extends TypeResolvableSupport
implements Constraint

A constraint based on a regular expression pattern.

Author:
Keith Donald
See Also:
TypeResolvable, Pattern

Constructor Summary
RegexpConstraint(String regex)
          Creates a RegexpConstraint with the provided regular expression pattern string.
RegexpConstraint(String regex, String type)
          Creates a RegexpConstraint with the provided regular expression pattern string and sets the type of the constraint to provide specific messages.
 
Method Summary
 boolean test(Object argument)
          Test if the argument matches the pattern.
 String toString()
           
 
Methods inherited from class org.springframework.rules.reporting.TypeResolvableSupport
getArguments, getCodes, getDefaultMessage, getType, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RegexpConstraint

public RegexpConstraint(String regex)
Creates a RegexpConstraint with the provided regular expression pattern string.

Parameters:
regex - The regular expression

RegexpConstraint

public RegexpConstraint(String regex,
                        String type)
Creates a RegexpConstraint with the provided regular expression pattern string and sets the type of the constraint to provide specific messages.

Parameters:
regex - the regular expression.
type - id used to fetch the message.
Method Detail

test

public boolean test(Object argument)
Test if the argument matches the pattern.

Specified by:
test in interface Constraint
Parameters:
argument - the argument value
Returns:
true if the condition was satisfied, false otherwise

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2004-2008 The Spring Framework. All Rights Reserved.