|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IValidationContext
Interface providing contextual information to
AbstractModelConstraint
s about the validation currently in progress.
Also provides some useful services to manipulate a constraint's environment.
The context knows at any point in time what constraint is currently being evaluated on which model element. Thus, the context will seem to know what constraint implementation is calling it, but this is just a consequence of the fact that constraints are invoked strictly one at a time by the context, itself.
A single constraint implementation may check multiple conditions. In such
cases, it can return a
multi-status
of
multiple results created by the overloaded variants of the
ConstraintStatus.createStatus(IValidationContext, Collection, String, Object[])
method.
Note that the results of any method calls on the context object are
only valid during the invocation of the constraint's
validate()
method. The results
should not be retained by a constraint implementation.
This interface should not be implemented outside of the validation framework.
Method Summary | |
---|---|
void |
addResult(EObject eObject)
Adds a result to the result locus of the current constraint. |
void |
addResults(Collection<? extends EObject> eObjects)
Adds all of the specified model elements to the result locus of the current constraint. |
IStatus |
createFailureStatus(Object... messageArgument)
Creates a status object indicating unsuccessful evaluation of the current constraint on the current target element. |
IStatus |
createSuccessStatus()
Creates a status object indicating successful evaluation of the current constraint on the current target element. |
void |
disableCurrentConstraint(Throwable exception)
Causes the current constraint to be disabled for the remainder of the Eclipse session, because it is no longer viable due to some run-time exception. |
List<Notification> |
getAllEvents()
Gets all of the Notification s that are currently being validated. |
Object |
getCurrentConstraintData()
Gets the current constraint's private working data. |
String |
getCurrentConstraintId()
Obtains the ID of the constraint currently being evaluated. |
EMFEventType |
getEventType()
In the case of a live constraint evaluation, obtains the type of event which is currently being validated. |
EStructuralFeature |
getFeature()
In the case of a live constraint evaluation, obtains the particular feature on which the constraint is triggered. |
Object |
getFeatureNewValue()
In the case of live constraint evaluation that is triggered by a particular feature, obtains the new value of the feature that is being validated. |
Set<EObject> |
getResultLocus()
Obtains the result locus of this evaluation of the current constraint. |
EObject |
getTarget()
Obtains the EMF object currently being validated. |
Object |
putCurrentConstraintData(Object newData)
Puts into this context some working data that is to be cached for the current constraint. |
void |
skipCurrentConstraintFor(EObject eObject)
Causes the current constraint to be skipped in any subsequent validation of the specified eObject in the current validation
operation. |
void |
skipCurrentConstraintForAll(Collection<?> eObjects)
Causes the current constraint to be skipped in any subsequent validation of any of the specified eObjects in the current validation
operation. |
Method Detail |
---|
String getCurrentConstraintId()
AbstractModelConstraint
EObject getTarget()
EMFEventType getEventType()
EMFEventType.NULL
if the constraint is being evaluated in
batch modeList<Notification> getAllEvents()
Notification
s that are currently being validated.
This is useful for live constraints that need more contextual information
about the changes being validated than is available in a single
notification.
Notification
s being validated, or an empty
list if this is a batch validation. This list is not modifiableEStructuralFeature getFeature()
null
if the constraint does not specify any
feature triggers in the XML meta-data.
null
if the constraint is not triggered by a particular
featuregetFeatureNewValue()
Object getFeatureNewValue()
In the case of live constraint evaluation that is triggered by a particular feature, obtains the new value of the feature that is being validated. The exact contents of the result are as follows:
target
Collection
), or null
if the
constraint is not triggered by a particular featuregetFeature()
void skipCurrentConstraintFor(EObject eObject)
Causes the current constraint to be skipped in any subsequent validation
of the specified eObject
in the current validation
operation. Constraints can use this facility to short-circuit
processing, especially in a recursive batch validation, of objects that
they have already checked in processing the current
target
.
For example, checking for dependency cycles in a UML model requires traversing the dependency relationships from an element as far as they reach throughout the model. Every element thus traversed can subsequently be ignored by the constraint, as ground that needs not be trodden again, whether a cycle was found or not.
Note that there is no need to invoke this method for the
current target
object; the validation system
guarantees that it will not be revisited.
eObject
- the model object to be skipped by the current constraintvoid skipCurrentConstraintForAll(Collection<?> eObjects)
eObjects
in the current validation
operation.
eObjects
- the model objects to be skipped by the current constraintskipCurrentConstraintFor(EObject)
void disableCurrentConstraint(Throwable exception)
Causes the current constraint to be disabled for the remainder of the Eclipse session, because it is no longer viable due to some run-time exception.
Note how this differs from the
skipCurrentConstraintFor(EObject)
method: the current constraint
is skipped for all model elements and even in subsequent validation
operations.
exception
- the exception that has caused the current constraint to
be non-viable. Must not be null
Object getCurrentConstraintData()
Gets the current constraint's private working data. This object can be
anything that the caller defines. The value is null
until it is set by this same constraint using the
putCurrentConstraintData(java.lang.Object)
method. The working data persists
only for the duration of the validation operation.
The constraint may use this to cache any data that may be of use to it in optimizing the processing of multiple objects, reporting information to the user, etc.
putCurrentConstraintData(Object)
Object putCurrentConstraintData(Object newData)
getCurrentConstraintData()
method during the same validation
operation.
newData
- the new working data
newData
is displacingSet<EObject> getResultLocus()
addResult(EObject)
void addResult(EObject eObject)
current target
is implicitly
added to the result locus if the constraint evaluation fails.
eObject
- the model element to add to the result locusgetResultLocus()
void addResults(Collection<? extends EObject> eObjects)
eObjects
- the model elements to add to the result locus. Must
contain elements of type EObject
addResult(EObject)
IStatus createSuccessStatus()
IStatus createFailureStatus(Object... messageArgument)
messageArgument
- the positional {0}, {1}, etc. arguments to
replace in the message pattern (may by null
if none
are needed)
|
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 |