Package org.nuiton.validator.xwork2
Class XWork2NuitonValidatorProvider
java.lang.Object
org.nuiton.validator.AbstractNuitonValidatorProvider
org.nuiton.validator.xwork2.XWork2NuitonValidatorProvider
- All Implemented Interfaces:
NuitonValidatorProvider
public class XWork2NuitonValidatorProvider extends AbstractNuitonValidatorProvider
Provider of validator for the xworks nuiton validator.
- Since:
- 2.0
- Author:
- Tony Chemit - chemit@codelutin.com
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classXWork2NuitonValidatorProvider.ValidatorComparatorprotected static classXWork2NuitonValidatorProvider.ValidatorFilenameFilterNested classes/interfaces inherited from class org.nuiton.validator.AbstractNuitonValidatorProvider
AbstractNuitonValidatorProvider.ModelEntry<O> -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPROVIDER_NAME -
Constructor Summary
Constructors Constructor Description XWork2NuitonValidatorProvider() -
Method Summary
Modifier and Type Method Description java.util.SortedSet<NuitonValidator<?>>detectValidators(java.io.File sourceRoot, java.util.regex.Pattern contextFilter, NuitonValidatorScope[] scopes, java.lang.Class<?>... types)Detects in the given directory validators.protected java.io.FilegetClassDir(java.io.File sourceRoot, java.lang.Class<?> clazz)protected java.lang.String[]getContexts(java.lang.Class<?> clazz, java.io.File dir)protected java.lang.String[]getContextsWithoutScopes(java.lang.String[] contexts)protected java.lang.String[]getFilterContexts(java.util.regex.Pattern contextFilter, java.lang.String[] realContexts)protected <O> NuitonValidator<O>getValidator(java.lang.Class<O> klass, java.lang.String context, NuitonValidatorScope... scopes)Pour un context et un type d'entité donné, instancie un validateur et test si ce validateur est utilisable (i.e qu'il admet des champs à valider).<O> NuitonValidatorModel<O>newModel(java.lang.Class<O> type, java.lang.String context, NuitonValidatorScope... scopes)Instanciate a new validator model for the given parameters.<O> XWork2NuitonValidator<O>newValidator(NuitonValidatorModel<O> model)Obtains a new validator for the givenmodel.Methods inherited from class org.nuiton.validator.AbstractNuitonValidatorProvider
getModel, getModels, getName
-
Field Details
-
PROVIDER_NAME
public static final java.lang.String PROVIDER_NAME- See Also:
- Constant Field Values
-
-
Constructor Details
-
XWork2NuitonValidatorProvider
public XWork2NuitonValidatorProvider()
-
-
Method Details
-
newModel
public <O> NuitonValidatorModel<O> newModel(java.lang.Class<O> type, java.lang.String context, NuitonValidatorScope... scopes)Description copied from interface:NuitonValidatorProviderInstanciate a new validator model for the given parameters.- Type Parameters:
O- type of the class to validate- Parameters:
type- type of the class to validatecontext- context of validation (nullif no context)scopes- filtered scope (if nothing given, then use all scopes)- Returns:
- the new instanciated model of validation
-
newValidator
Description copied from interface:NuitonValidatorProviderObtains a new validator for the givenmodel.- Type Parameters:
O- type of class to validate- Parameters:
model- the model of validator to use- Returns:
- the new validator
-
detectValidators
public java.util.SortedSet<NuitonValidator<?>> detectValidators(java.io.File sourceRoot, java.util.regex.Pattern contextFilter, NuitonValidatorScope[] scopes, java.lang.Class<?>... types)Description copied from interface:NuitonValidatorProviderDetects in the given directory validators.- Parameters:
sourceRoot- root directory where to seek for validatorscontextFilter- the pattern of context to seekscopes- scopes to seek (if none given, will seek for all scopes)types- types of class to seek- Returns:
- the set of validators found
-
getValidator
protected <O> NuitonValidator<O> getValidator(java.lang.Class<O> klass, java.lang.String context, NuitonValidatorScope... scopes)Pour un context et un type d'entité donné, instancie un validateur et test si ce validateur est utilisable (i.e qu'il admet des champs à valider). Si aucun champ n'est trouvé dans le validateur, alors on retourne null.- Type Parameters:
O- le type du bean- Parameters:
klass- le type du beancontext- le context du validateurscopes- les scopes a utiliser (sinullalors pas de filtre sur les scopes)- Returns:
- le validateur initialisé, ou
nullsi aucun scope détecté dans le validateur.
-
getClassDir
protected java.io.File getClassDir(java.io.File sourceRoot, java.lang.Class<?> clazz) -
getContexts
protected java.lang.String[] getContexts(java.lang.Class<?> clazz, java.io.File dir) -
getContextsWithoutScopes
protected java.lang.String[] getContextsWithoutScopes(java.lang.String[] contexts) -
getFilterContexts
protected java.lang.String[] getFilterContexts(java.util.regex.Pattern contextFilter, java.lang.String[] realContexts)
-