org.alfresco.repo.dictionary.constraint
Class AbstractConstraint

java.lang.Object
  extended by org.alfresco.repo.dictionary.constraint.AbstractConstraint
All Implemented Interfaces:
Constraint
Direct Known Subclasses:
ListOfValuesConstraint, NumericRangeConstraint, RegexConstraint, StringLengthConstraint

public abstract class AbstractConstraint
extends java.lang.Object
implements Constraint

Base services for constraints.


Field Summary
static java.lang.String ERR_EVALUATE_EXCEPTION
           
static java.lang.String ERR_PROP_NOT_SET
           
 
Constructor Summary
AbstractConstraint()
           
 
Method Summary
protected  void checkPropertyNotNull(java.lang.String name, java.lang.Object value)
          Check that the given value is not null.
 void evaluate(java.lang.Object value)
          Evaluates a property value according to the implementation and initialization parameters provided.
protected  void evaluateCollection(java.util.Collection collection)
          Only override if there is some specific evaluation that needs to be performed on the collection as a whole.
protected abstract  void evaluateSingleValue(java.lang.Object value)
          Support for evaluation of properties.
 java.util.Map getParameters()
          Returns the parameters passed to the instance of the constraint.
 java.lang.String getShortName()
          Gets the constraint name.
 java.lang.String getTitle()
           
 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 set_shortName(java.lang.String shortName)
          Deprecated.  
 void setRegistry(ConstraintRegistry registry)
          Optionally specify the registry that will be used to register the constraint.
 void setShortName(java.lang.String name)
          Sets the constraint name
 void setTitle(java.lang.String title)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERR_PROP_NOT_SET

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

ERR_EVALUATE_EXCEPTION

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

AbstractConstraint

public AbstractConstraint()
Method Detail

set_shortName

public void set_shortName(java.lang.String shortName)
Deprecated. 

Sets the constraint name. Automatically called after construction. Please excuse the strange method name as we want the property name to begin with an underscore to avoid property name clashes.

Parameters:
shortName -

setShortName

public void setShortName(java.lang.String name)
Sets the constraint name

Parameters:
name -

getShortName

public java.lang.String getShortName()
Gets the constraint name.

Specified by:
getShortName in interface Constraint
Returns:
the constraint name.

setRegistry

public void setRegistry(ConstraintRegistry registry)
Optionally specify the registry that will be used to register the constraint. This is used when instantiating constraints outside the dictionary.

Parameters:
registry - the constraint registry

getType

public java.lang.String getType()
Description copied from interface: Constraint
Returns the 'type' of the constraint, this is the identifier given to constraint in the configuration.

Specified by:
getType in interface Constraint
Returns:
The type

setTitle

public void setTitle(java.lang.String title)

getTitle

public java.lang.String getTitle()
Specified by:
getTitle in interface Constraint
Returns:
the human-readable constraint title (optional)

getParameters

public java.util.Map getParameters()
Description copied from interface: Constraint
Returns the parameters passed to the instance of the constraint.

Specified by:
getParameters in interface Constraint
Returns:
Map of parameters or an empty Map if none exist

initialize

public void initialize()
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.

Registers the constraint with the registry, if present. Call this method if you want the constraint to be auto-registered.

Specified by:
initialize in interface Constraint

checkPropertyNotNull

protected void checkPropertyNotNull(java.lang.String name,
                                    java.lang.Object value)
Check that the given value is not null.

Parameters:
name - the name of the property
value - the value to check for null
Throws:
DictionaryException - if the the property is null

evaluate

public final void evaluate(java.lang.Object value)
Description copied from interface: Constraint
Evaluates a property value according to the implementation and initialization parameters provided.

Specified by:
evaluate in interface Constraint
Parameters:
value - the property value to check
See Also:
AbstractConstraint.evaluateSingleValue(Object), AbstractConstraint.evaluateCollection(Collection)

evaluateCollection

protected void evaluateCollection(java.util.Collection collection)
Only override if there is some specific evaluation that needs to be performed on the collection as a whole.

Parameters:
collection - the collection of values to evaluate
See Also:
AbstractConstraint.evaluateSingleValue(Object)

evaluateSingleValue

protected abstract void evaluateSingleValue(java.lang.Object value)
Support for evaluation of properties. The value passed in will never be a Collection and will never be null.

Throws:
ConstraintException - throw this when the evaluation fails


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