|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
T
- the kind of target element validated by the validatorpublic interface IValidator<T>
A validator validates model elements on behalf of the validation service's clients. The validator supports a variety of controls determining how the validation is done; for example, whether only validation problems are reported or also which constraints are satisfied, whether batch validation is recursive, etc.
The different specializations of this interface evaluate constraints for the
various modes
of
validation, and are obtained from the ModelValidationService
.
Typically, a client will obtain a new validator and retain it for repeated
use (probably for the lifetime of the client object). In general, validators
are not thread-safe.
The result of the validate(T)
method is
an IStatus
containing the results (as individual status objects)
of every constraint that failed and, if enabled
,
also those that passed. The validator guarantees that the
same constraint is not evaluated twice on the same model object for the same
trigger.
Validation clients are encouraged to put information into the validators that
they create, that will help validation
listeners to know how to interpret
validation results. This information can be provided by the
putClientData(String, Object)
method. As an example, a client may
wish to publish the marker type ID under which a listener should create or
look for validation problem markers, especially for batch validation.
As of the 1.3 release, some of the customizations of the validator behaviour are also implemented as validation options. This provides a unified approach to this extensible mechanism, simplifying the configuration of a validator by enabling separation of the configuration step from the construction of the validator.
In the future, the validator may provide additional services, such as statistics, diagnostics, and other meta-data about the validation operation.
Note that clients are not intended to implement this interface.
ModelValidationService.newValidator(EvaluationMode)
Nested Class Summary | |
---|---|
static class |
IValidator.Option<V>
The definition of a validator option. |
Field Summary | |
---|---|
static IValidator.Option<Boolean> |
OPTION_REPORT_SUCCESSES
A boolean-valued option indicating whether to report the success evaluation of constraints on target elements. |
Method Summary | ||
---|---|---|
void |
addConstraintFilter(IConstraintFilter filter)
Adds a constraint filter to this validator. |
|
Object |
getClientData(String key)
Allows a client to retrieve "client data" that it had previously put . |
|
Collection<IConstraintFilter> |
getConstraintFilters()
Obtains a collection of IConstraintFilter s that define
which constraints should be excluded for validation. |
|
EvaluationMode<T> |
getEvaluationMode()
Indicates the evaluation mode that I support. |
|
|
getOption(IValidator.Option<V> option)
Convenience for querying an option. |
|
Map<IValidator.Option<?>,?> |
getOptions()
Obtains the options applied to me that customize my operation. |
|
boolean |
isReportSuccesses()
Queries whether successful constraint evaluations are reported, in addition to validation problems. |
|
void |
putClientData(String key,
Object data)
Makes the specified named particle of information available to listeners who will receiver validation events from this validator. |
|
void |
removeConstraintFilter(IConstraintFilter filter)
Removes a constraint filter from this validator. |
|
|
setOption(IValidator.Option<? super V> option,
V value)
Convenience for setting an option. |
|
void |
setOptions(Map<IValidator.Option<?>,?> options)
Sets options to apply to me, that customize my operation. |
|
void |
setReportSuccesses(boolean reportSuccesses)
Indicates whether successful constraint evaluations are to be reported, in addition to validation problems. |
|
IStatus |
validate(Collection<? extends T> objects)
Validates multiple objects, all in the same validation context . |
|
IStatus |
validate(T object)
Validates an object. |
Field Detail |
---|
static final IValidator.Option<Boolean> OPTION_REPORT_SUCCESSES
false
.
setOptions(Map)
Method Detail |
---|
EvaluationMode<T> getEvaluationMode()
validate()
methods to process.
boolean isReportSuccesses()
Queries whether successful constraint evaluations are reported, in addition to validation problems.
Since the 1.3 release, this method is equivalent to checking whether
the OPTION_REPORT_SUCCESSES
validation option is applied.
setReportSuccesses(boolean)
,
getOptions()
,
OPTION_REPORT_SUCCESSES
void setReportSuccesses(boolean reportSuccesses)
Indicates whether successful constraint evaluations are to be reported,
in addition to validation problems. If false
, then the
status reported by the validate()
methods will not
contain sub-statuses representing the constraints that passed, but will
only have sub-statuses for the constraints (if any) that failed.
Since the 1.3 release, this method is equivalent to applying the
OPTION_REPORT_SUCCESSES
validation option.
reportSuccesses
- true
to report successes;
false
to ignore themisReportSuccesses()
,
setOptions(Map)
,
OPTION_REPORT_SUCCESSES
void putClientData(String key, Object data)
key
- identifies an entry in the data map; must not be
null
data
- the associated data, or null
to remove itObject getClientData(String key)
put
.
key
- the key under which the data object was put
null
if none was
put under this key
putClientData(String, Object)
IStatus validate(T object)
object
- the object to validate
severity
of the result indicates whether
validation passed or (how badly it) failed. Normally, the result is
a multi-status
whose children are
the results of individual constraint evaluations
ClassCastException
- if the object
is not of
the correct type for this validatorIStatus validate(Collection<? extends T> objects)
validation context
.
This method is preferable to repeated invocations of
validate(Object)
because it avoids repetition of constraints
(as well as results) and other performance optimizations.
objects
- the objects to be validated
multi-status
of individual results
ClassCastException
- if any of the objects
is
not of the correct type for this validatorvalidate(Object)
void addConstraintFilter(IConstraintFilter filter)
filter
- the constraint filter to addvoid removeConstraintFilter(IConstraintFilter filter)
filter
- the constraint filter to removeaddConstraintFilter(IConstraintFilter)
Collection<IConstraintFilter> getConstraintFilters()
IConstraintFilter
s that define
which constraints should be excluded for validation.
addConstraintFilter(IConstraintFilter)
,
removeConstraintFilter(IConstraintFilter)
Map<IValidator.Option<?>,?> getOptions()
setOptions(Map)
,
#getOption(Object, Object)
void setOptions(Map<IValidator.Option<?>,?> options)
options
- my options, or null
to set the defaultsgetOptions()
,
#setOption(Object, Object, Object)
<V> V getOption(IValidator.Option<V> option)
V
- the value type of the optionoption
- the option key
getOptions()
<V> void setOption(IValidator.Option<? super V> option, V value)
V
- the value type of the optionoption
- the option keyvalue
- the new value to setsetOptions(Map)
|
Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |