jaxx.runtime.validator.field
Class CollectionUniqueKeyValidator
java.lang.Object
com.opensymphony.xwork2.validator.validators.ValidatorSupport
com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
com.opensymphony.xwork2.validator.validators.FieldExpressionValidator
jaxx.runtime.validator.field.CollectionUniqueKeyValidator
- All Implemented Interfaces:
- com.opensymphony.xwork2.validator.FieldValidator, com.opensymphony.xwork2.validator.ShortCircuitableValidator, com.opensymphony.xwork2.validator.Validator
public class CollectionUniqueKeyValidator
- extends com.opensymphony.xwork2.validator.validators.FieldExpressionValidator
Un validateur basé sur FieldExpressionValidator qui valide une clef
unique sur une collection.
Le FieldValidatorSupport.fieldName sert à récupérer la propriété de type de collection du
bean.
- Author:
- tchemit
|
Field Summary |
protected String |
againstIndexExpression
Lors de l'utilisation de la againstProperty et qu'un ne peut pas utiliser
le equals sur l'objet, on peut spécifier une expression pour exclure des
tests lors de la recherche de la violation de clef unique. |
protected String |
againstProperty
Une propriété optionnelle pour valider que l'objet reflétée par cette
propriété ne viole pas l'intégrité de la clef unique. |
protected String |
collectionFieldName
pour indiquer la propriété qui contient la liste à valider. |
protected String[] |
keys
la liste des propriétés d'une entrée de la collection qui définit la
clef unique. |
| Fields inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport |
defaultMessage, log, messageKey |
| Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldExpressionValidator |
getExpression, setExpression |
| Methods inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport |
getFieldName, setFieldName, setValidatorType |
| Methods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport |
addActionError, addFieldError, conditionalParse, getDefaultMessage, getFieldValue, getMessage, getMessageKey, getMessageParameters, getParse, getValidatorContext, isShortCircuit, setDefaultMessage, setMessageKey, setMessageParameters, setParse, setShortCircuit, setValidatorContext, setValueStack |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.opensymphony.xwork2.validator.Validator |
getDefaultMessage, getMessage, getMessageKey, getMessageParameters, getValidatorContext, setDefaultMessage, setMessageKey, setMessageParameters, setValidatorContext, setValueStack |
collectionFieldName
protected String collectionFieldName
- pour indiquer la propriété qui contient la liste à valider.
Si cette prorpiété n'est pas renseignée alors on utilise la
FieldValidatorSupport.getFieldName() pour obtenir la collection.
Cela permet d'effectuer une validation si une collection mais portant
en fait sur un autre champs
- Since:
- 1.5
keys
protected String[] keys
- la liste des propriétés d'une entrée de la collection qui définit la
clef unique.
againstProperty
protected String againstProperty
- Une propriété optionnelle pour valider que l'objet reflétée par cette
propriété ne viole pas l'intégrité de la clef unique.
Cela permet de valider l'unicité sans que l'objet soit dans la collection
againstIndexExpression
protected String againstIndexExpression
- Lors de l'utilisation de la againstProperty et qu'un ne peut pas utiliser
le equals sur l'objet, on peut spécifier une expression pour exclure des
tests lors de la recherche de la violation de clef unique.
CollectionUniqueKeyValidator
public CollectionUniqueKeyValidator()
getCollectionFieldName
public String getCollectionFieldName()
setCollectionFieldName
public void setCollectionFieldName(String collectionFieldName)
getKeys
public String[] getKeys()
setKeys
public void setKeys(String[] keys)
getAgainstProperty
public String getAgainstProperty()
setAgainstProperty
public void setAgainstProperty(String againstProperty)
getAgainstIndexExpression
public String getAgainstIndexExpression()
setAgainstIndexExpression
public void setAgainstIndexExpression(String againstIndexExpression)
validate
public void validate(Object object)
throws com.opensymphony.xwork2.validator.ValidationException
- Specified by:
validate in interface com.opensymphony.xwork2.validator.Validator- Overrides:
validate in class com.opensymphony.xwork2.validator.validators.FieldExpressionValidator
- Throws:
com.opensymphony.xwork2.validator.ValidationException
getUniqueKeyHashCode
protected Integer getUniqueKeyHashCode(Object o)
throws com.opensymphony.xwork2.validator.ValidationException
- Calcule pour une entrée donné, le hash de la clef unique
- Parameters:
o - l'entree de la collection dont on va calculer le hash de
la clef unique
- Returns:
- le hashCode calclé de la clef unique sur l'entrée donné
- Throws:
com.opensymphony.xwork2.validator.ValidationException - if any pb to retreave properties values
getCollection
protected Collection<?> getCollection(Object object)
throws com.opensymphony.xwork2.validator.ValidationException
- Parameters:
object - the incoming object containing the collection to test
- Returns:
- the collection of the incoming object given by the fieldName
property
- Throws:
com.opensymphony.xwork2.validator.ValidationException - if any pb to retreave the collection
getValidatorType
public String getValidatorType()
- Specified by:
getValidatorType in interface com.opensymphony.xwork2.validator.Validator- Overrides:
getValidatorType in class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
Copyright © 2008-2010 CodeLutin. All Rights Reserved.