org.alfresco.repo.dictionary.constraint
Class RegexConstraint

java.lang.Object
  extended by org.alfresco.repo.dictionary.constraint.AbstractConstraint
      extended by org.alfresco.repo.dictionary.constraint.RegexConstraint
All Implemented Interfaces:
Constraint

public class RegexConstraint
extends AbstractConstraint

Constraint implementation that performs regular expression comparisons. Where possible, the 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.

See Also:
String.matches(java.lang.String), Pattern

Field Summary
static java.lang.String CONSTRAINT_REGEX_MATCH
           
static java.lang.String CONSTRAINT_REGEX_NO_MATCH
           
 
Fields inherited from class org.alfresco.repo.dictionary.constraint.AbstractConstraint
ERR_EVALUATE_EXCEPTION, ERR_PROP_NOT_SET
 
Constructor Summary
RegexConstraint()
           
 
Method Summary
protected  void evaluateSingleValue(java.lang.Object value)
          Support for evaluation of properties.
 java.lang.String getExpression()
           
 boolean getRequiresMatch()
           
 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()
           
 
Methods inherited from class org.alfresco.repo.dictionary.constraint.AbstractConstraint
checkPropertyNotNull, evaluate, evaluateCollection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CONSTRAINT_REGEX_NO_MATCH

public static final java.lang.String CONSTRAINT_REGEX_NO_MATCH
See Also:
Constant Field Values

CONSTRAINT_REGEX_MATCH

public static final java.lang.String CONSTRAINT_REGEX_MATCH
See Also:
Constant Field Values
Constructor Detail

RegexConstraint

public RegexConstraint()
Method Detail

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getExpression

public java.lang.String getExpression()
Returns:
Returns the regular expression similar to the String.matches(java.lang.String)

setExpression

public void setExpression(java.lang.String expression)
Set the regular expression used to evaluate String values

Parameters:
regular - expression similar to the String.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

initialize

public void initialize()
Description copied from interface: Constraint
Initializes 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.


evaluateSingleValue

protected void evaluateSingleValue(java.lang.Object value)
Description copied from class: AbstractConstraint
Support for evaluation of properties. The value passed in will never be a Collection and will never be null.

Specified by:
evaluateSingleValue in class AbstractConstraint


Copyright © 2005 - 2008 Alfresco Software, Inc. All Rights Reserved.