Class RegexConstraint
- java.lang.Object
-
- org.alfresco.repo.dictionary.constraint.AbstractConstraint
-
- org.alfresco.repo.dictionary.constraint.RegexConstraint
-
- All Implemented Interfaces:
Constraint
public class RegexConstraint extends AbstractConstraint
Constraint implementation that performs regular expression comparisons. Where possible, thetype converterwill be used to first convert the value to aString, so the evaluation will be against the value'sStringequivalent.The failure condition can be changed to occur either on a match or on a non-match by using the
requiresMatchproperty. The default is true, i.e. failures will occur if the object value does not match the given expression.- Author:
- Derek Hulley
- See Also:
String.matches(java.lang.String),Pattern
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONSTRAINT_REGEX_MATCHstatic StringCONSTRAINT_REGEX_MSG_PREFIXstatic StringCONSTRAINT_REGEX_NO_MATCH-
Fields inherited from class org.alfresco.repo.dictionary.constraint.AbstractConstraint
ERR_EVALUATE_EXCEPTION, ERR_PROP_NOT_SET
-
-
Constructor Summary
Constructors Constructor Description RegexConstraint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidevaluateSingleValue(Object value)Support for evaluation of properties.StringgetExpression()Map<String,Object>getParameters()Returns the parameters passed to the instance of the constraint.booleangetRequiresMatch()StringgetType()Returns the 'type' of the constraint, this is the identifier given to constraint in the configuration.voidinitialize()Initializes the constraint with appropriate values, which will depend on the implementation itself.voidsetExpression(String expression)Set the regular expression used to evaluate String valuesvoidsetRequiresMatch(boolean requiresMatch)Set whether the regular expression must be matched or notStringtoString()-
Methods inherited from class org.alfresco.repo.dictionary.constraint.AbstractConstraint
checkPropertyNotNull, evaluate, evaluateCollection, getShortName, getTitle, set_shortName, setRegistry, setShortName, setTitle
-
-
-
-
Field Detail
-
CONSTRAINT_REGEX_NO_MATCH
public static final String CONSTRAINT_REGEX_NO_MATCH
- See Also:
- Constant Field Values
-
CONSTRAINT_REGEX_MATCH
public static final String CONSTRAINT_REGEX_MATCH
- See Also:
- Constant Field Values
-
CONSTRAINT_REGEX_MSG_PREFIX
public static final String CONSTRAINT_REGEX_MSG_PREFIX
- See Also:
- Constant Field Values
-
-
Method Detail
-
getType
public String getType()
Returns the 'type' of the constraint, this is the identifier given to constraint in the configuration.- Specified by:
getTypein interfaceConstraint- Overrides:
getTypein classAbstractConstraint- Returns:
- The type
-
getExpression
public String getExpression()
- Returns:
- Returns the regular expression similar to the
String.matches(java.lang.String)
-
setExpression
public void setExpression(String expression)
Set the regular expression used to evaluate String values- Parameters:
expression- regular expression similar to theString.matches(java.lang.String)argument
-
getRequiresMatch
public boolean getRequiresMatch()
- Returns:
- Returns true if the value must match the regular expression or false if the value must not match the regular expression
-
setRequiresMatch
public void setRequiresMatch(boolean requiresMatch)
Set whether the regular expression must be matched or not- Parameters:
requiresMatch- Set to true if the value must match the regular expression or false if the value must not match the regular expression
-
getParameters
public Map<String,Object> getParameters()
Description copied from interface:ConstraintReturns the parameters passed to the instance of the constraint.- Specified by:
getParametersin interfaceConstraint- Overrides:
getParametersin classAbstractConstraint- Returns:
- Map of parameters or an empty Map if none exist
-
initialize
public void initialize()
Description copied from class:AbstractConstraintInitializes the constraint with appropriate values, which will depend on the implementation itself. This method can be implemented as a once-off, i.e. reinitialization does not have to be supported.Registers the constraint with the registry, if present. Call this method if you want the constraint to be auto-registered.
- Specified by:
initializein interfaceConstraint- Overrides:
initializein classAbstractConstraint
-
evaluateSingleValue
protected void evaluateSingleValue(Object value)
Description copied from class:AbstractConstraintSupport for evaluation of properties. The value passed in will never be a Collection and will never be null.- Specified by:
evaluateSingleValuein classAbstractConstraint
-
-