|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjaxx.runtime.validator.BeanValidator<B>
B - type of the bean to validate.public class BeanValidator<B>
A customized validator for a given bean.
Note: The bean must be listenable on properyChange events (means must have public addPropertychangeListener and removePropertyChangeListener methods).
| Field Summary | |
|---|---|
protected B |
bean
bean to be watched |
static String |
BEAN_PROERTY
la nom de la propriété bean |
protected Class<B> |
beanClass
the type of bean to watch |
protected EventSetDescriptor |
beanEventDescriptor
to add and remove PropertyChangeListener on watched beans |
protected boolean |
changed
state to indicate that validator has changed since the last time bean was setted |
static String |
CHANGED_PROERTY
la nom de l'état changed |
static String |
CONTEXT_NAME_PROPERTY
la nom de la propriété contextName |
protected String |
contextName
the validation named context (can be null) |
protected Map<String,String> |
conversionErrors
map of conversion errors detected by this validator |
protected Set<BeanValidatorField<B>> |
fields
list of fields watched by this validator |
protected static BeanValidatorScope[] |
FILTER_SCOPES_EMPTY
|
protected BeanValidatorScope[] |
filterScopes
filter scopes (if null, no filter on scopes) |
protected PropertyChangeListener |
l
listener that listens on bean modification |
protected EventListenerList |
listenerList
A list of event listeners for this validators |
protected static org.apache.commons.logging.Log |
log
Logger |
protected BeanValidator<?> |
parentValidator
to chain to a prent validator |
protected PropertyChangeSupport |
pcs
delegate property change support |
protected boolean |
valid
state of the validator (is true if no errors of error scope is found) |
static String |
VALID_PROERTY
la nom de l'état valid |
protected EnumMap<BeanValidatorScope,XWorkBeanValidator<B>> |
validators
xworks scope validator * |
| Constructor Summary | |
|---|---|
BeanValidator(Class<B> beanClass,
String contextName)
|
|
BeanValidator(Class<B> beanClass,
String contextName,
BeanValidatorScope... filterScopes)
|
|
| Method Summary | ||
|---|---|---|
void |
addBeanValidatorListener(BeanValidatorListener listener)
|
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
|
|
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
|
|
protected boolean |
canValidate()
|
|
boolean |
containsField(String fieldName)
Test a the validator contains the field given his name |
|
|
convert(String fieldName,
String value,
Class<T> valueClass)
Convert a value. |
|
void |
doValidate()
Methode pour forcer la revalidation d'un bean en mettant a jour les etats internes. |
|
protected void |
fireFieldChanged(BeanValidatorField<B> field,
BeanValidatorScope scope,
String[] toAdd,
String[] toDelete)
|
|
B |
getBean()
|
|
Class<B> |
getBeanClass()
|
|
protected EventSetDescriptor |
getBeanEventDescriptor(B bean)
|
|
BeanValidatorListener[] |
getBeanValidatorListeners()
|
|
String |
getContextName()
|
|
BeanValidatorField<B> |
getField(String fieldName)
|
|
Set<BeanValidatorField<B>> |
getFields()
|
|
BeanValidator<?> |
getParentValidator()
|
|
Set<BeanValidatorScope> |
getScopes()
|
|
boolean |
hasErrors()
|
|
boolean |
hasInfos()
|
|
boolean |
hasWarnings()
|
|
protected void |
initFields()
|
|
boolean |
isChanged()
Retourne vrai si l'objet bean a ete modifie depuis le dernier setBean(B) |
|
boolean |
isValid()
|
|
boolean |
isValid(String fieldName)
|
|
void |
removeBeanValidatorListener(BeanValidatorListener listener)
|
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
|
|
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
|
|
void |
setBean(B bean)
|
|
void |
setChanged(boolean changed)
Permet de force la remise a false de l'etat de changement du bean |
|
void |
setContextName(String contextName)
|
|
void |
setFilterScopes(BeanValidatorScope... filterScopes)
Sets the filter scopes. |
|
void |
setParentValidator(BeanValidator<?> parentValidator)
|
|
void |
setValid(boolean valid)
|
|
String |
toString()
|
|
protected void |
validate()
il faut eviter le code re-intrant (durant une validation, une autre est demandee). |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final String BEAN_PROERTY
public static final String CONTEXT_NAME_PROPERTY
public static final String VALID_PROERTY
public static final String CHANGED_PROERTY
protected static final org.apache.commons.logging.Log log
protected static final BeanValidatorScope[] FILTER_SCOPES_EMPTY
protected final Class<B> beanClass
protected String contextName
protected BeanValidator<?> parentValidator
protected boolean changed
protected boolean valid
protected B bean
protected EventSetDescriptor beanEventDescriptor
protected Set<BeanValidatorField<B>> fields
protected Map<String,String> conversionErrors
protected EnumMap<BeanValidatorScope,XWorkBeanValidator<B>> validators
protected BeanValidatorScope[] filterScopes
null, no filter on scopes)
protected PropertyChangeListener l
protected PropertyChangeSupport pcs
protected EventListenerList listenerList
| Constructor Detail |
|---|
public BeanValidator(Class<B> beanClass,
String contextName)
public BeanValidator(Class<B> beanClass,
String contextName,
BeanValidatorScope... filterScopes)
| Method Detail |
|---|
public Class<B> getBeanClass()
public BeanValidator<?> getParentValidator()
public String getContextName()
public Set<BeanValidatorField<B>> getFields()
public Set<BeanValidatorScope> getScopes()
public boolean isChanged()
setBean(B)
true if bean was modify since last setBean(Object) invocationpublic boolean isValid()
public B getBean()
public BeanValidatorField<B> getField(String fieldName)
public boolean hasErrors()
public boolean hasWarnings()
public boolean hasInfos()
public boolean containsField(String fieldName)
fieldName - the name of the searched field
true if validator contaisn this field,
false otherwisepublic boolean isValid(String fieldName)
public void setChanged(boolean changed)
changed - flag to force reset of property changedpublic void setValid(boolean valid)
public void setBean(B bean)
public void setContextName(String contextName)
public void setFilterScopes(BeanValidatorScope... filterScopes)
filterScopes - the scopes to usedpublic void setParentValidator(BeanValidator<?> parentValidator)
public <T> T convert(String fieldName,
String value,
Class<T> valueClass)
T - the type of conversionfieldName - the name of the bean propertyvalue - the value to convertvalueClass - the type of converted value
public void doValidate()
validate() puis met à jour les etats internes
valid et changed.
protected void validate()
PropertyChangeListener
Note: la methode est protected et on utilise la methode
doValidate() car la méthode ne modifie pas les etats
internes et cela en rend son utilisation delicate (le validateur entre
dans un etat incoherent par rapport aux messages envoyés).
public String toString()
toString in class Objectpublic void addBeanValidatorListener(BeanValidatorListener listener)
public void removeBeanValidatorListener(BeanValidatorListener listener)
public BeanValidatorListener[] getBeanValidatorListeners()
public void addPropertyChangeListener(PropertyChangeListener listener)
public void addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
public void removePropertyChangeListener(PropertyChangeListener listener)
public void removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
protected boolean canValidate()
true if validation is enabled, false
otherwise.
protected void fireFieldChanged(BeanValidatorField<B> field,
BeanValidatorScope scope,
String[] toAdd,
String[] toDelete)
protected void initFields()
protected EventSetDescriptor getBeanEventDescriptor(B bean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||