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 String |
CONSTRAINT_REGEX_MATCH |
static String |
CONSTRAINT_REGEX_MSG_PREFIX |
static 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(Object value)
Support for evaluation of properties.
|
String |
getExpression() |
Map<String,Object> |
getParameters()
Returns the parameters passed to the instance of the constraint.
|
boolean |
getRequiresMatch() |
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(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
|
String |
toString() |
checkPropertyNotNull, evaluate, evaluateCollection, getShortName, getTitle, set_shortName, setRegistry, setShortName, setTitlepublic static final String CONSTRAINT_REGEX_NO_MATCH
public static final String CONSTRAINT_REGEX_MATCH
public static final String CONSTRAINT_REGEX_MSG_PREFIX
public String getType()
getType in interface ConstraintgetType in class AbstractConstraintpublic String getExpression()
String.matches(java.lang.String)public void setExpression(String expression)
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 Map<String,Object> 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(Object value)
AbstractConstraintevaluateSingleValue in class AbstractConstraintCopyright © 2005–2019 Alfresco Software. All rights reserved.