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, setTitle
public 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 Constraint
getType
in class AbstractConstraint
public 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()
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(Object value)
AbstractConstraint
evaluateSingleValue
in class AbstractConstraint
Copyright © 2005–2020 Alfresco Software. All rights reserved.