Describes validation messages as used by the JGoodies Validation framework.
All validation messages provide a formatted text (
ValidationMessage.formattedText() )
and are categorized into types of different severity (@link #severity()}).
Validation messages are collected during the validation process and
are held by instances of
com.jgoodies.validation.ValidationResult .
This class has been designed to be decoupled from user interface components
(views) that present and edit the validated data. The design goal is to be
able to use the same validation mechanism on the server side, in the domain
layer, in a view-less model layer, and in the presentation layer.
And we want to ensure that multiple views can present the same model,
and so we typically don't store a view in the validation message.
On the other hand we want to detect which validation messages belongs
to a given user interface component, for example to let the component
paint a warning indication.
This association between message and view is established by the message key
that can be shared between messages, validators, views, and other parties.
It can be requested using the
ValidationMessage.key() method. The association is
checked using #equals ; implementors that use rich objects
as keys may consider overriding #equals .
For example, a validator validates an address object and reports
that the zip code is invalid. You may choose the association key
as "address.zipCode" . All views that present the zip code
can now check and verify whether a validation result contains messages
with this key and may paint a special warning background.
If the validated data contains two different address objects, let's say
a shipping address and a physical address, the address validator may
add a prefix and create keys like physical.address.zipCode
and shipping.address.zipCode . A view can now differentiate
between the two zip codes.
We've choosen to let the ValidationMessage check whether
an association key matches or not. This way, an implementation of this
interface can choose to provide special checks. The default behavior
in class
com.jgoodies.validation.message.AbstractValidationMessage just checks whether a given association key equals a stored key.
Implementors may hold additional objects, for example the validation target,
a description of the target, or a description of the validated property.
Implementors are encouraged to implement #equals and
#hashCode to prevent unnecessary change notifications
for the result property when a ValidationResultModel
gets a new ValidationResult. See for example the implementation of method
com.jgoodies.validation.message.PropertyValidationMessage.equals(Object) .
author: Karsten Lentzsch version: $Revision: 1.5 $ See Also: com.jgoodies.validation.ValidationResult See Also: com.jgoodies.validation.message.AbstractValidationMessage |