Class CollectionFieldExpressionValidator
java.lang.Object
com.opensymphony.xwork2.validator.validators.ValidatorSupport
com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
com.opensymphony.xwork2.validator.validators.FieldExpressionValidator
org.nuiton.validator.xwork2.field.NuitonFieldExpressionValidator
org.nuiton.validator.xwork2.field.CollectionFieldExpressionValidator
- All Implemented Interfaces:
com.opensymphony.xwork2.validator.FieldValidator,com.opensymphony.xwork2.validator.ShortCircuitableValidator,com.opensymphony.xwork2.validator.Validator
public class CollectionFieldExpressionValidator extends NuitonFieldExpressionValidator
Un validateur basé sur
FieldExpressionValidator qui valide sur une
collection de propriéte.- Author:
- Tony Chemit - chemit@codelutin.com
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCollectionFieldExpressionValidator.ModeclassCollectionFieldExpressionValidator.WalkerContext -
Field Summary
Fields Modifier and Type Field Description protected CollectionFieldExpressionValidator.WalkerContextcle context de parcoursprotected java.lang.StringcollectionFieldNamepour indiquer la propriété qui contient la liste à valider.protected java.lang.StringexpressionForFirstexpression a valider sur la premiètre entrée de la collection.protected java.lang.StringexpressionForLastexpression a valider sur la dernière entrée de la collection.protected java.lang.String[]keysla liste des propriétés d'une entrée de la collection qui définit la clef unique (en mode UNIQUE_KEY).protected CollectionFieldExpressionValidator.Modemodele mode de validation sur la listeprotected com.opensymphony.xwork2.util.ValueStackstackprotected booleanuseSensitiveContextdrapeau pour utiliser le contexte de parcours pour valider l'expression, on dispose donc alors des variables previous, current, index, size et empty dans l'expression. -
Constructor Summary
Constructors Constructor Description CollectionFieldExpressionValidator() -
Method Summary
Modifier and Type Method Description protected booleanevaluateExpression(java.lang.String expression, java.lang.Object object)protected java.util.Collection<?>getCollection(java.lang.Object object)java.lang.StringgetCollectionFieldName()java.lang.StringgetExpressionForFirst()java.lang.StringgetExpressionForLast()java.lang.String[]getKeys()java.lang.StringgetMessage(java.lang.Object object)CollectionFieldExpressionValidator.ModegetMode()protected java.lang.ObjectgetPropertyValue(java.lang.String key, java.lang.Object o)protected java.lang.IntegergetUniqueKeyHashCode(java.lang.Object o)Calcule pour une entrée donné, le hash de la clef uniquejava.lang.StringgetValidatorType()booleanisUseSensitiveContext()voidsetCollectionFieldName(java.lang.String collectionFieldName)voidsetExpressionForFirst(java.lang.String expressionForFirst)voidsetExpressionForLast(java.lang.String expressionForLast)voidsetKeys(java.lang.String[] keys)voidsetMode(CollectionFieldExpressionValidator.Mode mode)voidsetUseSensitiveContext(boolean useSensitiveContext)voidsetValueStack(com.opensymphony.xwork2.util.ValueStack stack)protected java.lang.BooleanvalidateAllEntries(java.util.Collection<?> col)protected java.lang.BooleanvalidateAtLeastOneEntry(java.util.Collection<?> col)protected java.lang.BooleanvalidateExtacltyOneEntry(java.util.Collection<?> col)protected java.lang.BooleanvalidateNoneEntry(java.util.Collection<?> col)protected booleanvalidateOneEntry(java.lang.Object object)protected java.lang.BooleanvalidateUniqueKey(java.util.Collection<?> col)voidvalidateWhenNotSkip(java.lang.Object object)Method to be invoked when skip parameter was not evaludated totrue.Methods inherited from class org.nuiton.validator.xwork2.field.NuitonFieldExpressionValidator
evaluateSkipParameter, setSkip, validateMethods inherited from class com.opensymphony.xwork2.validator.validators.FieldExpressionValidator
getExpression, setExpressionMethods inherited from class com.opensymphony.xwork2.validator.validators.FieldValidatorSupport
getCurrentValue, getFieldName, setFieldName, setValidatorTypeMethods inherited from class com.opensymphony.xwork2.validator.validators.ValidatorSupport
addActionError, addFieldError, getDefaultMessage, getFieldValue, getMessageKey, getMessageParameters, getValidatorContext, isShortCircuit, parse, setDefaultMessage, setMessageKey, setMessageParameters, setShortCircuit, setTextProviderFactory, setValidatorContext
-
Field Details
-
mode
le mode de validation sur la liste -
collectionFieldName
protected java.lang.String collectionFieldNamepour indiquer la propriété qui contient la liste à valider. Si cette prorpiété n'est pas renseignée alors on utilise laFieldValidatorSupport.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
-
useSensitiveContext
protected boolean useSensitiveContextdrapeau pour utiliser le contexte de parcours pour valider l'expression, on dispose donc alors des variables previous, current, index, size et empty dans l'expression. Sinon l'expression s'applique directement sur l'entrée courant dans le parcours sans préfixe. -
expressionForFirst
protected java.lang.String expressionForFirstexpression a valider sur la premiètre entrée de la collection. Note : Pour le moment, on autorise uniquement cela en mode ALL. -
expressionForLast
protected java.lang.String expressionForLastexpression a valider sur la dernière entrée de la collection. Note : Pour le moment, on autorise uniquement cela en mode ALL. -
keys
protected java.lang.String[] keysla liste des propriétés d'une entrée de la collection qui définit la clef unique (en mode UNIQUE_KEY). -
c
le context de parcours -
stack
protected com.opensymphony.xwork2.util.ValueStack stack
-
-
Constructor Details
-
CollectionFieldExpressionValidator
public CollectionFieldExpressionValidator()
-
-
Method Details
-
getMode
-
setMode
-
getCollectionFieldName
public java.lang.String getCollectionFieldName() -
setCollectionFieldName
public void setCollectionFieldName(java.lang.String collectionFieldName) -
isUseSensitiveContext
public boolean isUseSensitiveContext() -
setUseSensitiveContext
public void setUseSensitiveContext(boolean useSensitiveContext) -
getExpressionForFirst
public java.lang.String getExpressionForFirst() -
setExpressionForFirst
public void setExpressionForFirst(java.lang.String expressionForFirst) -
getExpressionForLast
public java.lang.String getExpressionForLast() -
setExpressionForLast
public void setExpressionForLast(java.lang.String expressionForLast) -
getKeys
public java.lang.String[] getKeys() -
setKeys
public void setKeys(java.lang.String[] keys) -
validateWhenNotSkip
public void validateWhenNotSkip(java.lang.Object object) throws com.opensymphony.xwork2.validator.ValidationExceptionDescription copied from class:NuitonFieldExpressionValidatorMethod to be invoked when skip parameter was not evaludated totrue.- Overrides:
validateWhenNotSkipin classNuitonFieldExpressionValidator- Parameters:
object- the object to be validated.- Throws:
com.opensymphony.xwork2.validator.ValidationException- is thrown if there is validation error(s).
-
setValueStack
public void setValueStack(com.opensymphony.xwork2.util.ValueStack stack)- Specified by:
setValueStackin interfacecom.opensymphony.xwork2.validator.Validator- Overrides:
setValueStackin classcom.opensymphony.xwork2.validator.validators.ValidatorSupport
-
getMessage
public java.lang.String getMessage(java.lang.Object object)- Specified by:
getMessagein interfacecom.opensymphony.xwork2.validator.Validator- Overrides:
getMessagein classcom.opensymphony.xwork2.validator.validators.ValidatorSupport
-
validateAllEntries
protected java.lang.Boolean validateAllEntries(java.util.Collection<?> col) throws com.opensymphony.xwork2.validator.ValidationException- Throws:
com.opensymphony.xwork2.validator.ValidationException
-
validateNoneEntry
protected java.lang.Boolean validateNoneEntry(java.util.Collection<?> col) throws com.opensymphony.xwork2.validator.ValidationException- Throws:
com.opensymphony.xwork2.validator.ValidationException
-
validateAtLeastOneEntry
protected java.lang.Boolean validateAtLeastOneEntry(java.util.Collection<?> col) throws com.opensymphony.xwork2.validator.ValidationException- Throws:
com.opensymphony.xwork2.validator.ValidationException
-
validateExtacltyOneEntry
protected java.lang.Boolean validateExtacltyOneEntry(java.util.Collection<?> col) throws com.opensymphony.xwork2.validator.ValidationException- Throws:
com.opensymphony.xwork2.validator.ValidationException
-
validateUniqueKey
protected java.lang.Boolean validateUniqueKey(java.util.Collection<?> col) throws com.opensymphony.xwork2.validator.ValidationException- Throws:
com.opensymphony.xwork2.validator.ValidationException
-
validateOneEntry
protected boolean validateOneEntry(java.lang.Object object) throws com.opensymphony.xwork2.validator.ValidationException- Throws:
com.opensymphony.xwork2.validator.ValidationException
-
evaluateExpression
protected boolean evaluateExpression(java.lang.String expression, java.lang.Object object) throws com.opensymphony.xwork2.validator.ValidationException- Throws:
com.opensymphony.xwork2.validator.ValidationException
-
getCollection
protected java.util.Collection<?> getCollection(java.lang.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
-
getUniqueKeyHashCode
protected java.lang.Integer getUniqueKeyHashCode(java.lang.Object o) throws com.opensymphony.xwork2.validator.ValidationExceptionCalcule 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
-
getValidatorType
public java.lang.String getValidatorType()- Specified by:
getValidatorTypein interfacecom.opensymphony.xwork2.validator.Validator- Overrides:
getValidatorTypein classcom.opensymphony.xwork2.validator.validators.FieldValidatorSupport
-
getPropertyValue
protected java.lang.Object getPropertyValue(java.lang.String key, java.lang.Object o)
-