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, setTitlepublic 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 ConstraintgetType in class AbstractConstraintpublic java.lang.String toString()
toString in class java.lang.Objectpublic 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()
ConstraintgetParameters in interface ConstraintgetParameters in class AbstractConstraintpublic void initialize()
AbstractConstraintRegisters the constraint with the registry, if present. Call this method if you want the constraint to be auto-registered.
initialize in interface Constraintinitialize in class AbstractConstraintprotected void evaluateSingleValue(java.lang.Object value)
AbstractConstraintevaluateSingleValue in class AbstractConstraintCopyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.