org.nuiton.validator.xwork2
Class XWork2NuitonValidatorProvider

java.lang.Object
  extended by org.nuiton.validator.AbstractNuitonValidatorProvider
      extended by 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:
tchemit

Nested Class Summary
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
static String PROVIDER_NAME
           
 
Fields inherited from class org.nuiton.validator.AbstractNuitonValidatorProvider
models, name
 
Constructor Summary
XWork2NuitonValidatorProvider()
           
 
Method Summary
 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 given model.
 
Methods inherited from class org.nuiton.validator.AbstractNuitonValidatorProvider
getModel, getModels, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROVIDER_NAME

public static final String PROVIDER_NAME
See Also:
Constant Field Values
Constructor Detail

XWork2NuitonValidatorProvider

public XWork2NuitonValidatorProvider()
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 validate
context - 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 given model.

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 validators
contextFilter - the pattern of context to seek
scopes - 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 bean
context - le context du validateur
scopes - les scopes a utiliser (si null alors pas de filtre sur les scopes)
Returns:
le validateur initialisé, ou null si aucun scope détecté dans le validateur.

getClassDir

protected File getClassDir(File sourceRoot,
                           Class<?> clazz)

getContexts

protected String[] getContexts(Class<?> clazz,
                               File dir)

getContextsWithoutScopes

protected String[] getContextsWithoutScopes(String[] contexts)

getFilterContexts

protected String[] getFilterContexts(Pattern contextFilter,
                                     String[] realContexts)


Copyright © 2011-2012 CodeLutin. All Rights Reserved.