SimpleBeanValidator.@Deprecated public class BeanValidator<O> extends Object
bean.
A such validator is also a JavaBean and you can listen his states
modifications via the classic java bean api.
Note: The BeanValidator should never be used for
validation in a service approch since it needs to keep a reference to the
bean to validate.BeanValidatorListener| Modifier and Type | Field and Description |
|---|---|
protected O |
bean
Deprecated.
The bean to validate.
|
static String |
BEAN_PROPERTY
Deprecated.
Name of the bounded property
bean. |
protected boolean |
canValidate
Deprecated.
State to know if the validator can be used (we keep this state for
performance reasons : do not want to compute this value each time a
validation is asked...).
|
protected boolean |
changed
Deprecated.
State to indicate that validator has changed since the last time bean was
setted.
|
static String |
CHANGED_PROPERTY
Deprecated.
Name of the bounded property
changed. |
static String |
CONTEXT_PROPERTY
Deprecated.
Name of the bounded property
context. |
protected Map<String,String> |
conversionErrors
Deprecated.
map of conversion errors detected by this validator
|
protected NuitonValidator<O> |
delegate
Deprecated.
The delegate validator used to validate the bean.
|
protected PropertyChangeListener |
l
Deprecated.
Listener that listens on bean modification.
|
protected EventListenerList |
listenerList
Deprecated.
A list of event listeners for this validators
|
protected static org.apache.commons.logging.Log |
log
Deprecated.
Logger.
|
protected NuitonValidatorResult |
messages
Deprecated.
State of validation (keep all messages of validation for the filled
bean).
|
protected BeanValidator<?> |
parentValidator
Deprecated.
To chain to another validator (acting as parent of this one).
|
protected PropertyChangeSupport |
pcs
Deprecated.
delegate property change support
|
static String |
SCOPES_PROPERTY
Deprecated.
Name of the bounded property
scopes. |
protected boolean |
valid
Deprecated.
State of the validator (is true if no errors of error scope is found).
|
static String |
VALID_PROPERTY
Deprecated.
Name of the bounded property
valid. |
protected NuitonValidatorProvider |
validatorProvider
Deprecated.
The provider of delegate validators.
|
| Constructor and Description |
|---|
BeanValidator(NuitonValidatorProvider validatorProvider,
Class<O> beanClass,
String context)
Deprecated.
|
BeanValidator(NuitonValidatorProvider validatorProvider,
Class<O> beanClass,
String context,
NuitonValidatorScope... scopes)
Deprecated.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addBeanValidatorListener(BeanValidatorListener listener)
Deprecated.
|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Deprecated.
|
void |
addPropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Deprecated.
|
boolean |
containsField(String fieldName)
Deprecated.
Test a the validator contains the field given his name
|
<T> T |
convert(String fieldName,
String value,
Class<T> valueClass)
Deprecated.
Convert a value.
|
protected BeanValidatorEvent |
createEvent(String field,
NuitonValidatorScope scope,
String[] toAdd,
String[] toDelete)
Deprecated.
|
void |
doValidate()
Deprecated.
|
protected void |
fireFieldChanged(BeanValidatorEvent evt)
Deprecated.
|
protected void |
fireFieldChanged(String field,
NuitonValidatorScope scope,
String[] toAdd,
String[] toDelete)
Deprecated.
|
void |
firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
Deprecated.
|
O |
getBean()
Deprecated.
Obtain the actual bean attached to the validator.
|
BeanValidatorListener[] |
getBeanValidatorListeners()
Deprecated.
|
String |
getContext()
Deprecated.
|
protected NuitonValidator<O> |
getDelegate()
Deprecated.
|
Set<String> |
getEffectiveFields()
Deprecated.
|
Set<String> |
getEffectiveFields(NuitonValidatorScope scope)
Deprecated.
|
Set<NuitonValidatorScope> |
getEffectiveScopes()
Deprecated.
|
NuitonValidatorScope |
getHighestScope(String field)
Deprecated.
|
BeanValidator<?> |
getParentValidator()
Deprecated.
|
Set<NuitonValidatorScope> |
getScopes()
Deprecated.
|
Class<O> |
getType()
Deprecated.
|
boolean |
hasErrors()
Deprecated.
|
boolean |
hasFatalErrors()
Deprecated.
|
boolean |
hasInfos()
Deprecated.
|
boolean |
hasWarnings()
Deprecated.
|
boolean |
isCanValidate()
Deprecated.
|
boolean |
isChanged()
Deprecated.
Obtain the
changed property value. |
boolean |
isValid()
Deprecated.
Obtain the
valid property value. |
boolean |
isValid(String fieldName)
Deprecated.
|
protected void |
mergeMessages(NuitonValidatorResult newMessages)
Deprecated.
|
protected void |
mergeMessages(NuitonValidatorScope scope,
NuitonValidatorResult newMessages,
List<BeanValidatorEvent> events)
Deprecated.
|
protected void |
rebuildDelegateValidator(Class<O> beanType,
String context,
NuitonValidatorScope... scopes)
Deprecated.
|
void |
removeBeanValidatorListener(BeanValidatorListener listener)
Deprecated.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Deprecated.
|
void |
removePropertyChangeListener(String propertyName,
PropertyChangeListener listener)
Deprecated.
|
void |
setBean(O bean)
Deprecated.
Change the attached bean.
|
void |
setCanValidate(boolean canValidate)
Deprecated.
|
void |
setChanged(boolean changed)
Deprecated.
To force the value of the property
changed. |
void |
setContext(String context)
Deprecated.
|
void |
setParentValidator(BeanValidator<?> parentValidator)
Deprecated.
|
void |
setScopes(NuitonValidatorScope... scopes)
Deprecated.
|
void |
setValid(boolean valid)
Deprecated.
Change the value of the
valid property. |
String |
toString()
Deprecated.
|
void |
validate()
Deprecated.
il faut eviter le code re-intrant (durant une validation, une autre est
demandee).
|
public static final String BEAN_PROPERTY
bean.bean,
getBean(),
setBean(Object),
Constant Field Valuespublic static final String CONTEXT_PROPERTY
context.getContext(),
setContext(String),
Constant Field Valuespublic static final String SCOPES_PROPERTY
scopes.public static final String VALID_PROPERTY
valid.valid,
isValid(),
setValid(boolean),
Constant Field Valuespublic static final String CHANGED_PROPERTY
changed.changed,
isChanged(),
setChanged(boolean),
Constant Field Valuesprotected static final org.apache.commons.logging.Log log
protected O bean
protected BeanValidator<?> parentValidator
protected NuitonValidator<O> delegate
protected NuitonValidatorResult messages
protected boolean changed
protected boolean valid
protected boolean canValidate
protected Map<String,String> conversionErrors
protected PropertyChangeListener l
protected PropertyChangeSupport pcs
protected EventListenerList listenerList
protected final NuitonValidatorProvider validatorProvider
NuitonValidatorProviderpublic BeanValidator(NuitonValidatorProvider validatorProvider, Class<O> beanClass, String context)
public BeanValidator(NuitonValidatorProvider validatorProvider, Class<O> beanClass, String context, NuitonValidatorScope... scopes)
public boolean isChanged()
changed property value.
Returns true if bean was modified since last
time a bean was attached.true if bean was modified since last attachement of
a bean.public void setChanged(boolean changed)
changed.changed - flag to force reset of property changedpublic boolean isCanValidate()
public void setCanValidate(boolean canValidate)
public boolean isValid()
valid property value.true if attached bean is valid (no error or fatal messages)public void setValid(boolean valid)
valid property.valid - the new value of the propertypublic O getBean()
null if no bean
is attachedpublic void setBean(O bean)
messages will be reset.bean - the bean to attach (can be null to reset the
validator).public String getContext()
public void setContext(String context)
public Set<NuitonValidatorScope> getScopes()
public Set<NuitonValidatorScope> getEffectiveScopes()
public Set<String> getEffectiveFields(NuitonValidatorScope scope)
public void setScopes(NuitonValidatorScope... scopes)
protected void rebuildDelegateValidator(Class<O> beanType, String context, NuitonValidatorScope... scopes)
public BeanValidator<?> getParentValidator()
public void setParentValidator(BeanValidator<?> parentValidator)
public boolean hasFatalErrors()
public boolean hasErrors()
public boolean hasWarnings()
public boolean hasInfos()
public boolean containsField(String fieldName)
fieldName - the name of the searched fieldtrue if validator contaisn this field,
false otherwisepublic boolean isValid(String fieldName)
public NuitonValidatorScope getHighestScope(String field)
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 valuepublic void doValidate()
public 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 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)
public void firePropertyChange(String propertyName, Object oldValue, Object newValue)
protected BeanValidatorEvent createEvent(String field, NuitonValidatorScope scope, String[] toAdd, String[] toDelete)
protected void fireFieldChanged(String field, NuitonValidatorScope scope, String[] toAdd, String[] toDelete)
protected void fireFieldChanged(BeanValidatorEvent evt)
protected void mergeMessages(NuitonValidatorResult newMessages)
protected void mergeMessages(NuitonValidatorScope scope, NuitonValidatorResult newMessages, List<BeanValidatorEvent> events)
protected NuitonValidator<O> getDelegate()
Copyright © 2011-2012 CodeLutin. All Rights Reserved.