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 class
XWork2NuitonValidatorProvider.ValidatorComparator
protected static class
XWork2NuitonValidatorProvider.ValidatorFilenameFilter
-
Nested classes/interfaces inherited from class org.nuiton.validator.AbstractNuitonValidatorProvider
AbstractNuitonValidatorProvider.ModelEntry<O>
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROVIDER_NAME
-
Fields inherited from class org.nuiton.validator.AbstractNuitonValidatorProvider
models, name
-
-
Constructor Summary
Constructors Constructor Description XWork2NuitonValidatorProvider()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description SortedSet<NuitonValidator<?>>
detectValidators(File sourceRoot, Pattern contextFilter, NuitonValidatorScope[] scopes, Class<?>... types)
Detects in the given directory validators.protected File
getClassDir(File sourceRoot, Class<?> clazz)
protected String[]
getContexts(Class<?> clazz, File dir)
protected String[]
getContextsWithoutScopes(String[] contexts)
protected String[]
getFilterContexts(Pattern contextFilter, String[] realContexts)
protected <O> NuitonValidator<O>
getValidator(Class<O> klass, 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(Class<O> type, 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 Detail
-
PROVIDER_NAME
public static final String PROVIDER_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
newModel
public <O> NuitonValidatorModel<O> newModel(Class<O> type, String context, NuitonValidatorScope... scopes)
Description copied from interface:NuitonValidatorProvider
Instanciate 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 (null
if no context)scopes
- filtered scope (if nothing given, then use all scopes)- Returns:
- the new instanciated model of validation
-
newValidator
public <O> XWork2NuitonValidator<O> newValidator(NuitonValidatorModel<O> model)
Description copied from interface:NuitonValidatorProvider
Obtains 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 SortedSet<NuitonValidator<?>> detectValidators(File sourceRoot, Pattern contextFilter, NuitonValidatorScope[] scopes, Class<?>... types)
Description copied from interface:NuitonValidatorProvider
Detects 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(Class<O> klass, 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 (sinull
alors pas de filtre sur les scopes)- Returns:
- le validateur initialisé, ou
null
si aucun scope détecté dans le validateur.
-
-