## org.eclipse.emf.validation.model
Class ConstraintStatus

    java.lang.Object
      org.eclipse.core.runtime.Status
          org.eclipse.emf.validation.model.ConstraintStatus

All Implemented Interfaces:
  IStatus, IConstraintStatus

    public class ConstraintStatus

extends Status
implements IConstraintStatus

Indicates the result of evaluating a constraint on a model object. Any constraint which is met by the object results in an `IStatus.OK` status. Failure of a constraint results in a status severity matching the `severity` defined for the constraint.

As a special case of constraint failure, if the validation framework receives an uncaught exception from the constraint, then the constraint is disabled and the resulting `ConstraintStatus` is an `IStatus.INFO` indicating this fact and containing the exception that caused the failure. Once disabled, the constraint will not be evaluated again.

This class should not be extended outside of the validation framework. It may be instantiated by clients, especially using the `createStatus()` factory methods.

See Also:
  `IModelConstraint.validate(org.eclipse.emf.validation.IValidationContext)`, `createStatus(IValidationContext, Collection, String, Object[])`, `createMultiStatus(IValidationContext, Collection)`

Field Summary

Fields inherited from class org.eclipse.core.runtime.Status
`CANCEL_STATUS, OK_STATUS`

Fields inherited from interface org.eclipse.core.runtime.IStatus
`CANCEL, ERROR, INFO, OK, WARNING`

Constructor Summary
`ConstraintStatus(IModelConstraint constraint, EObject target)` Initializes me as a successful execution of the specified `constraint`.
`ConstraintStatus(IModelConstraint constraint, EObject target, int severity, int code, String message, Set<? extends EObject> resultLocus)` Constructor that explicitly initializes all of my parts.
`ConstraintStatus(IModelConstraint constraint, EObject target, String message, Set<? extends EObject> resultLocus)` Initializes me as a failure of the specified `constraint` with a `message` to be displayed somehow to the user.

Method Summary
`static IStatus` `createMultiStatus(IValidationContext ctx, Collection<? extends IStatus> statuses)` Creates a multi-status from the specified problem `statuses`.
`static IStatus` `createMultiStatus(IValidationContext ctx, String messagePattern, Object[] messageArguments, Collection<? extends IStatus> statuses)` Creates a multi-status from the specified problem `statuses`.
`static ConstraintStatus` `createStatus(IValidationContext ctx, Collection<? extends EObject> resultLocus, int severity, int errorCode, String messagePattern, Object... messageArguments)` Creates a status object indicating unsuccessful evaluation of the current constraint on the current target element, as indicated by the supplied validation context.
`static ConstraintStatus` `createStatus(IValidationContext ctx, Collection<? extends EObject> resultLocus, String messagePattern, Object... messageArguments)` Creates a status object indicating unsuccessful evaluation of the current constraint on the current target element, as indicated by the supplied validation context.
`static ConstraintStatus` `createStatus(IValidationContext ctx, EObject target, Collection<? extends EObject> resultLocus, int severity, int errorCode, String messagePattern, Object... messageArguments)` Creates a status object indicating unsuccessful evaluation of the current constraint on the provided target element.
`static ConstraintStatus` `createStatus(IValidationContext ctx, EObject target, Collection<? extends EObject> resultLocus, String messagePattern, Object... messageArguments)` Creates a status object indicating unsuccessful evaluation of the current constraint on the provided target element.
`static IStatus` `createSuccessStatus(IValidationContext ctx, EObject target, Collection<? extends EObject> resultLocus)` Creates a status object indicating successful evaluation of the current constraint on the provided target element.
`IModelConstraint` `getConstraint()` Obtains the constraint which either succeeded or failed, according to what I have to say.
`Set<EObject>` `getResultLocus()` Obtains the objects which are involved in the failure of the constraint.
`EObject` `getTarget()` Obtains the target object, on which the constraint was evaluated.

Methods inherited from class org.eclipse.core.runtime.Status
`getChildren, getCode, getException, getMessage, getPlugin, getSeverity, isMultiStatus, isOK, matches, setCode, setException, setMessage, setPlugin, setSeverity, toString`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface org.eclipse.core.runtime.IStatus
`getChildren, getCode, getException, getMessage, getPlugin, getSeverity, isMultiStatus, isOK, matches`

Constructor Detail

### ConstraintStatus

    public ConstraintStatus(IModelConstraint constraint,
                            EObject target,
                            String message,
                            Set<? extends EObject> resultLocus)

  Initializes me as a failure of the specified `constraint` with a `message` to be displayed somehow to the user.

  Parameters:
    `constraint` - the constraint that failed
    `target` - the target of the failed validation
    `message` - the message describing the failure
    `resultLocus` - the objects which caused the constraint to fail (at least the original target should be among these). May be `null` if there really is no result locus

### ConstraintStatus

    public ConstraintStatus(IModelConstraint constraint,
                            EObject target)

  Initializes me as a successful execution of the specified `constraint`.

  Parameters:
    `constraint` - the constraint that succeeded
    `target` - the target of the successful validation

### ConstraintStatus

    public ConstraintStatus(IModelConstraint constraint,
                            EObject target,
                            int severity,
                            int code,
                            String message,
                            Set<? extends EObject> resultLocus)

  Constructor that explicitly initializes all of my parts.

  This constructor should not be used outside of the validation framework.

  Parameters:
    `constraint` - the constraint that was evaluated
    `target` - the object on which validation was performed
    `severity` - the severity of the constraint evaluation result
    `code` - the error code (if the constraint failed)
    `message` - the error message (if the constraint failed)
    `resultLocus` - the result locus (if the constraint failed)

Method Detail

### createStatus

    public static ConstraintStatus createStatus(IValidationContext ctx,
                                                EObject target,
                                                Collection<? extends EObject> resultLocus,
                                                String messagePattern,
                                                Object... messageArguments)

  Creates a status object indicating unsuccessful evaluation of the current constraint on the provided target element. The status will have the severity and error code defined in the constraint meta-data (its descriptor), and a message composed from the specified pattern and arguments.

  This is useful in the case that a single constraint object reports multiple distinct problems, with different messages, at the same severity.

  Parameters:
    `ctx` - the calling constraint's validation context. Must not be `null`
    `target` - the target for the status. If the target is `null`, the target from the validation context is used
    `resultLocus` - the objects involved in the problem that this status is to report. If this collection does not contain the target object of the validation, then it is considered to contain it implicitly. Thus, this parameter may be `null` if only the target object is in the result locus
    `messagePattern` - the message pattern (with optional {0} etc. parameters)
    `messageArguments` - the positional {0}, {1}, etc. arguments to replace in the message pattern (may by `null` if none are needed)
  Returns:
    the status indicating a constraint violation
  Since:
    1.1
  See Also:
    `createStatus(IValidationContext, Collection, int, int, String, Object[])`

### createStatus

    public static ConstraintStatus createStatus(IValidationContext ctx,
                                                EObject target,
                                                Collection<? extends EObject> resultLocus,
                                                int severity,
                                                int errorCode,
                                                String messagePattern,
                                                Object... messageArguments)

  Creates a status object indicating unsuccessful evaluation of the current constraint on the provided target element.

  This is useful in the case that a single constraint object reports multiple distinct problems, with different messages and severities.

  Parameters:
    `ctx` - the calling constraint's validation context. Must not be `null`
    `target` - the target for the status. If the target is `null`, the target from the validation context is used
    `resultLocus` - the objects involved in the problem that this status is to report. If this collection does not contain the target object of the validation, then it is considered to contain it implicitly. Thus, this parameter may be `null` if only the target object is in the result locus
    `severity` - the severity of the problem (one of the constants defined in the `IStatus` interface; should not be `OK`)
    `errorCode` - the error code. A constraint may wish to use different error codes for different conditions, or just supply the `status code` provided by its is constraint descriptor
    `messagePattern` - the message pattern (with optional {0} etc. parameters)
    `messageArguments` - the positional {0}, {1}, etc. arguments to replace in the message pattern (may by `null` if none are needed)
  Returns:
    the status indicating a constraint violation
  Since:
    1.1
  See Also:
    `createStatus(IValidationContext, Collection, String, Object[])`

### createStatus

    public static ConstraintStatus createStatus(IValidationContext ctx,
                                                Collection<? extends EObject> resultLocus,
                                                String messagePattern,
                                                Object... messageArguments)

  Creates a status object indicating unsuccessful evaluation of the current constraint on the current target element, as indicated by the supplied validation context. The status will have the severity and error code defined in the constraint meta-data (its descriptor), and a message composed from the specified pattern and arguments.

  This is useful in the case that a single constraint object reports multiple distinct problems, with different messages, at the same severity.

  Parameters:
    `ctx` - the calling constraint's validation context. Must not be `null`
    `resultLocus` - the objects involved in the problem that this status is to report. If this collection does not contain the target object of the validation, then it is considered to contain it implicitly. Thus, this parameter may be `null` if only the target object is in the result locus
    `messagePattern` - the message pattern (with optional {0} etc. parameters)
    `messageArguments` - the positional {0}, {1}, etc. arguments to replace in the message pattern (may by `null` if none are needed)
  Returns:
    the status indicating a constraint violation
  Since:
    1.1
  See Also:
    `createStatus(IValidationContext, Collection, int, int, String, Object[])`

### createStatus

    public static ConstraintStatus createStatus(IValidationContext ctx,
                                                Collection<? extends EObject> resultLocus,
                                                int severity,
                                                int errorCode,
                                                String messagePattern,
                                                Object... messageArguments)

  Creates a status object indicating unsuccessful evaluation of the current constraint on the current target element, as indicated by the supplied validation context.

  This is useful in the case that a single constraint object reports multiple distinct problems, with different messages and severities.

  Parameters:
    `ctx` - the calling constraint's validation context. Must not be `null`
    `resultLocus` - the objects involved in the problem that this status is to report. If this collection does not contain the target object of the validation, then it is considered to contain it implicitly. Thus, this parameter may be `null` if only the target object is in the result locus
    `severity` - the severity of the problem (one of the constants defined in the `IStatus` interface; should not be `OK`)
    `errorCode` - the error code. A constraint may wish to use different error codes for different conditions, or just supply the `status code` provided by its is constraint descriptor
    `messagePattern` - the message pattern (with optional {0} etc. parameters)
    `messageArguments` - the positional {0}, {1}, etc. arguments to replace in the message pattern (may by `null` if none are needed)
  Returns:
    the status indicating a constraint violation
  Since:
    1.1
  See Also:
    `createStatus(IValidationContext, Collection, String, Object[])`

### createSuccessStatus

    public static IStatus createSuccessStatus(IValidationContext ctx,
                                              EObject target,
                                              Collection<? extends EObject> resultLocus)

  Creates a status object indicating successful evaluation of the current constraint on the provided target element. The status will have the severity and error code defined in by `ConstraintStatus(IModelConstraint, EObject)`

  This method will only return a `ConstraintStatus` when the validation context's `IValidationContext.createSuccessStatus()` method returns an `IConstraintStatus`, otherwise it simply returns the success created by the validation context

  Parameters:
    `ctx` - the calling constraint's validation context. Must not be `null`
    `target` - the target for the status. Must not be `null`
    `resultLocus` - the objects involved in the success that this status is to report. If this collection does not contain the target object of the validation, then it is considered to contain it implicitly. Thus, this parameter may be `null` if only the target object is in the result locus
  Returns:
    the status indicating a success
  Since:
    1.1
  See Also:
    `createStatus(IValidationContext, Collection, int, int, String, Object[])`

### createMultiStatus

    public static IStatus createMultiStatus(IValidationContext ctx,
                                            Collection<? extends IStatus> statuses)

  Creates a multi-status from the specified problem `statuses`. The resulting status has a generic message and the error code defined by the constraint's metadata. The severity is, as with all multi-statuses, the maximum of the severities of the supplied `statuses`.

  This is useful in the case that a single constraint object reports multiple distinct problems. A constraint may choose to compose and return a `MultiStatus` if it wants different values for some of the status properties.

  Parameters:
    `ctx` - the calling constraint's current validation context
    `statuses` - the statuses to combine into a multi-status. Must not be `null` or empty
  Returns:
    a multi-status aggregating the supplied statuses
  Throws:
    `IllegalArgumentException` - if the `statuses` is `null` or empty
  Since:
    1.1
  See Also:
    `createMultiStatus(IValidationContext, String, Object[], Collection)`

### createMultiStatus

    public static IStatus createMultiStatus(IValidationContext ctx,
                                            String messagePattern,
                                            Object[] messageArguments,
                                            Collection<? extends IStatus> statuses)

  Creates a multi-status from the specified problem `statuses`. The resulting status has a message composed from the specified pattern and arguments, and the error code defined by the constraint's metadata. The severity is, as with all multi-statuses, the maximum of the severities of the supplied `statuses`.

  This is useful in the case that a single constraint object reports multiple distinct problems. A constraint may choose to compose and return a `MultiStatus` if it wants different values for some of the status properties.

  Parameters:
    `ctx` - the calling constraint's current validation context
    `messagePattern` - the message pattern (with optional {0} etc. parameters)
    `messageArguments` - the positional {0}, {1}, etc. arguments to replace in the message pattern (may by `null` if none are needed)
    `statuses` - the statuses to combine into a multi-status. Must not be `null` or empty
  Returns:
    a multi-status aggregating the supplied statuses
  Throws:
    `IllegalArgumentException` - if the `statuses` is `null` or empty
  Since:
    1.1
  See Also:
    `createMultiStatus(IValidationContext, Collection)`

### getConstraint

    public final IModelConstraint getConstraint()

  Obtains the constraint which either succeeded or failed, according to what I have to say.

  Specified by:
    `getConstraint` in interface `IConstraintStatus`
  Returns:
    my constraint

### getTarget

    public final EObject getTarget()

  Obtains the target object, on which the constraint was evaluated.

  Specified by:
    `getTarget` in interface `IConstraintStatus`
  Returns:
    the target of the validation operation

### getResultLocus

    public final Set<EObject> getResultLocus()

  Obtains the objects which are involved in the failure of the constraint. These are objects which caused the constraint to fail, and would be useful to link to from some display of the error message.

  Specified by:
    `getResultLocus` in interface `IConstraintStatus`
  Returns:
    the objects which caused the constraint to fail. In cases of successful validation, the result is an empty collection. The result is never `null`

Copyright 2002, 2007 IBM Corporation and others. All Rights Reserved.