|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.bval.BeanValidationContext<T>
public class BeanValidationContext<T extends ValidationListener>
Description: Context during validation to help the Validation
and the BeanValidator
do their jobs.
Used to bundle BeanValidationContext
and ValidationListener
together
This class is NOT thread-safe: a new instance will be created for each
validation
processing per thread.
Field Summary | |
---|---|
protected Map |
validatedObjects
set of objects already validated to avoid endless loops. |
Constructor Summary | |
---|---|
|
BeanValidationContext(T listener)
Create a new BeanValidationContext instance. |
protected |
BeanValidationContext(T listener,
Map validatedMap)
Create a new BeanValidationContext instance. |
Method Summary | |
---|---|
boolean |
collectValidated()
Avoid recursion by recording the current state of this context as having been validated. |
AccessStrategy |
getAccess()
Get the current access strategy. |
Object |
getBean()
Get the bean. |
T |
getListener()
Get the ValidationListener . |
FeaturesCapable |
getMeta()
Depending on whether we have a metaProperty or not, this returns the metaProperty or otherwise the metaBean. |
MetaBean |
getMetaBean()
Get the model meta-bean. |
MetaProperty |
getMetaProperty()
Get the model meta-property. |
String |
getPropertyName()
Convenience method to access metaProperty.name |
Object |
getPropertyValue()
Get the cached value or access it somehow (via field or method) you should prefer getPropertyValue(AccessStrategy) instead of this method |
Object |
getPropertyValue(AccessStrategy access)
Get the value by using the given access strategy. |
boolean |
isFixed()
Learn whether the current property value is "fixed." |
boolean |
isValidated(Object object)
Learn whether a particular object has been validated. |
void |
moveDown(MetaProperty prop,
AccessStrategy access)
Step deeper into association at 'prop' |
void |
moveUp(Object bean,
MetaBean aMetaBean)
Step out from a validation of associated objects. |
void |
resetValidated()
Clear map of validated objects (invoke when you want to 'reuse' the context for different validations) |
void |
setBean(Object bean)
Set the bean. |
void |
setBean(Object aBean,
MetaBean aMetaBean)
Set the current bean/metabean. |
void |
setCurrentIndex(Integer index)
Set the index of the object currently validated into the context. |
void |
setCurrentKey(Object key)
set the key of the object in a map currently validated into the context. |
void |
setFixed(boolean fixed)
Potentially declare the current property value as being "fixed." If true , the context will reuse any not-UNKNOWN
propertyValue regardless of the AccessStrategy by which it is requested. |
void |
setFixedValue(Object value)
Set the property value, fixed. |
void |
setListener(T listener)
Set the listener. |
void |
setMetaBean(MetaBean metaBean)
Set the model meta-bean. |
void |
setMetaProperty(MetaProperty metaProperty)
Set the current meta-property. |
void |
setPropertyValue(Object propertyValue)
Set the current property value. |
String |
toString()
|
void |
unknownValue()
Drop cached value, marking the internal cachedValue as UNKNOWN . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected Map validatedObjects
Constructor Detail |
---|
public BeanValidationContext(T listener)
listener
- protected BeanValidationContext(T listener, Map validatedMap)
listener
- validatedMap
- Method Detail |
---|
public T getListener()
ValidationListener
.
getListener
in interface ValidationContext<T extends ValidationListener>
public void setListener(T listener)
listener
- Tpublic boolean collectValidated()
collectValidated
in interface ValidationContext<T extends ValidationListener>
public boolean isValidated(Object object)
object
-
public void resetValidated()
public void setBean(Object aBean, MetaBean aMetaBean)
setBean
in interface ValidationContext<T extends ValidationListener>
public Object getPropertyValue()
getPropertyValue
in interface ValidationContext<T extends ValidationListener>
IllegalArgumentException
- - error accessing attribute (config error, reflection problem)
IllegalStateException
- - when no property is currently set in the context (application logic bug)public Object getPropertyValue(AccessStrategy access) throws IllegalArgumentException, IllegalStateException
getPropertyValue
in interface ValidationContext<T extends ValidationListener>
Object
IllegalArgumentException
IllegalStateException
public String getPropertyName()
getPropertyName
in interface ValidationContext<T extends ValidationListener>
public void setPropertyValue(Object propertyValue)
propertyValue
- public void setFixedValue(Object value)
value
- public boolean isFixed()
public void setFixed(boolean fixed)
true
, the context will reuse any not-UNKNOWN
propertyValue regardless of the AccessStrategy
by which it is requested.
fixed
- public FeaturesCapable getMeta()
public void unknownValue()
UNKNOWN
.
This forces the BeanValidationContext to recompute the value
the next time it is accessed.
Use this method inside tests or when the propertyValue has been
changed during validation.
public MetaBean getMetaBean()
getMetaBean
in interface ValidationContext<T extends ValidationListener>
MetaBean
public Object getBean()
getBean
in interface ValidationContext<T extends ValidationListener>
Object
public MetaProperty getMetaProperty()
getMetaProperty
in interface ValidationContext<T extends ValidationListener>
MetaProperty
public void setMetaBean(MetaBean metaBean)
setMetaBean
in interface ValidationContext<T extends ValidationListener>
public void setBean(Object bean)
setBean
in interface ValidationContext<T extends ValidationListener>
public void setMetaProperty(MetaProperty metaProperty)
setMetaProperty
in interface ValidationContext<T extends ValidationListener>
public String toString()
toString
in class Object
public void moveDown(MetaProperty prop, AccessStrategy access)
moveDown
in interface ValidationContext<T extends ValidationListener>
public void moveUp(Object bean, MetaBean aMetaBean)
moveUp
in interface ValidationContext<T extends ValidationListener>
public void setCurrentIndex(Integer index)
setCurrentIndex
in interface ValidationContext<T extends ValidationListener>
public void setCurrentKey(Object key)
setCurrentKey
in interface ValidationContext<T extends ValidationListener>
public AccessStrategy getAccess()
getAccess
in interface ValidationContext<T extends ValidationListener>
AccessStrategy
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |