public class RegexConstraint extends AbstractConstraint
type converter
will be used to first convert the value to a String
, so the evaluation
will be against the value's String
equivalent.
The failure condition can be changed to occur either on a match or on a non-match by using
the requiresMatch
property. The default is true, i.e.
failures will occur if the object value does not match the given expression.
String.matches(java.lang.String)
,
Pattern
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CONSTRAINT_REGEX_MATCH |
static java.lang.String |
CONSTRAINT_REGEX_MSG_PREFIX |
static java.lang.String |
CONSTRAINT_REGEX_NO_MATCH |
ERR_EVALUATE_EXCEPTION, ERR_PROP_NOT_SET
Constructor and Description |
---|
RegexConstraint() |
Modifier and Type | Method and Description |
---|---|
protected void |
evaluateSingleValue(java.lang.Object value)
Support for evaluation of properties.
|
java.lang.String |
getExpression() |
java.util.Map |
getParameters()
Returns the parameters passed to the instance of the constraint.
|
boolean |
getRequiresMatch() |
java.lang.String |
getType()
Returns the 'type' of the constraint, this is the identifier given to
constraint in the configuration.
|
void |
initialize()
Initializes the constraint with appropriate values, which will depend
on the implementation itself.
|
void |
setExpression(java.lang.String expression)
Set the regular expression used to evaluate String values
|
void |
setRequiresMatch(boolean requiresMatch)
Set whether the regular expression must be matched or not
|
java.lang.String |
toString() |
checkPropertyNotNull, evaluate, evaluateCollection, getShortName, getTitle, set_shortName, setRegistry, setShortName, setTitle
public static final java.lang.String CONSTRAINT_REGEX_NO_MATCH
public static final java.lang.String CONSTRAINT_REGEX_MATCH
public static final java.lang.String CONSTRAINT_REGEX_MSG_PREFIX
public java.lang.String getType()
getType
in interface Constraint
getType
in class AbstractConstraint
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getExpression()
String.matches(java.lang.String)
public void setExpression(java.lang.String expression)
regular
- expression similar to the String.matches(java.lang.String)
argumentpublic boolean getRequiresMatch()
public void setRequiresMatch(boolean requiresMatch)
requiresMatch
- Set to true if the value must match the regular expression
or false if the value must not match the regular expressionpublic java.util.Map getParameters()
Constraint
getParameters
in interface Constraint
getParameters
in class AbstractConstraint
public void initialize()
AbstractConstraint
Registers the constraint with the registry, if present. Call this method if you want the constraint to be auto-registered.
initialize
in interface Constraint
initialize
in class AbstractConstraint
protected void evaluateSingleValue(java.lang.Object value)
AbstractConstraint
evaluateSingleValue
in class AbstractConstraint
Copyright © 2005 - 2013 Alfresco Software, Inc. All Rights Reserved.