## org.eclipse.emf.validation.service
Interface IConstraintDescriptor

All Known Subinterfaces:
  IParameterizedConstraintDescriptor, IXmlConstraintDescriptor

All Known Implementing Classes:
  AbstractConstraintDescriptor, AbstractXmlConstraintDescriptor

    public interface IConstraintDescriptor

A constraint descriptor provides information about a constraint's role and status in the system. This includes such information as what categories the constraint is a member of and whether it is enabled, disabled, or even broken because of a run-time fault, in addition to a variety of meta-data declared about severity, evaluation mode, and triggers.

This interface is intended to be implemented by clients that have constraintProviders that are contributing `IModelConstraint` that are not described in standard XML. Note that the specialization `IParameterizedConstraintDescriptor` may be of particular value in describing constraints that are configurable and indicate their language.

Method Summary
`void` `addCategory(Category category)` Adds a category to me.
`String` `getBody()` If I represent an in-line constraint (whose algorithm is implemented in an XML file, script, or some other source than Java), then this method obtains its body.
`Set<Category>` `getCategories()` Queries the categories that I am a member of.
`String` `getDescription()` Obtains a description of my purpose, if any.
`EvaluationMode<?>` `getEvaluationMode()` Queries the mode (or modes) in which I can be evaluated.
`Throwable` `getException()` If I am an `error` constraint, obtains the exception that caused me not to be initialized.
`String` `getId()` Gets my ID.
`String` `getMessagePattern()` Obtains the localized message pattern configured in the XML for my constraint.
`String` `getName()` Gets my name.
`String` `getPluginId()` Queries the ID of the plugin which defines me.
`ConstraintSeverity` `getSeverity()` Queries the severity, as enumerated by the `ConstraintSeverity` class, of the problem indicated by a violation of my constraint.
`int` `getStatusCode()` Obtains a status code (unique integer within the scope of the `plugin`which defines me, useful for logging.
`boolean` `isBatch()` Queries whether I may be applied in "batch" mode, i.e., outside of any particular editing action context.
`boolean` `isEnabled()` Queries whether the constraint is enabled.
`boolean` `isError()` Queries whether the constraint is errored, i.e., not executable because of some error in initializing it.
`boolean` `isLive()` Queries whether I may be applied in "live" mode, i.e., within some particular editing action context.
`void` `removeCategory(Category category)` Removes a category from me.
`void` `setEnabled(boolean enabled)` Sets whether the constraint is enabled.
`void` `setError(Throwable exception)` Sets my error status.
`boolean` `targetsEvent(Notification notification)` Queries whether I apply to the specified EMF `notification`.
`boolean` `targetsTypeOf(EObject eObject)` Queries whether I target the type (or any supertype) of the specified `eObject`.

Method Detail

### getName

    String getName()

  Gets my name. This needs not be unique in any sense, and should be localized.

  Returns:
    my name

### getId

    String getId()

  Gets my ID. This must be unique. It is recommended that the ID be prefixed by the contributing plugin ID, as is usual for IDs in Eclipse.

  Returns:
    my unique identifier

### getPluginId

    String getPluginId()

  Queries the ID of the plugin which defines me.

  Returns:
    my plugin's ID

### getDescription

    String getDescription()

  Obtains a description of my purpose, if any.

  Returns:
    my description, or `null` if I have none

### getSeverity

    ConstraintSeverity getSeverity()

  Queries the severity, as enumerated by the `ConstraintSeverity` class, of the problem indicated by a violation of my constraint.

  Returns:
    my severity code

### getStatusCode

    int getStatusCode()

  Obtains a status code (unique integer within the scope of the `plugin`which defines me, useful for logging.

  Returns:
    a status code which is unique amongst all constraints contributed by the plug-in that defines me
  See Also:
    `getPluginId()`

### getEvaluationMode

    EvaluationMode<?> getEvaluationMode()

  Queries the mode (or modes) in which I can be evaluated. If I have the `EvaluationMode.NULL`mode, then I am never evaluated at all.

  Returns:
    my evaluation mode

### targetsTypeOf

    boolean targetsTypeOf(EObject eObject)

  Queries whether I target the type (or any supertype) of the specified `eObject`.

  Parameters:
    `eObject` - an EMF object which is to be validated
  Returns:
    `true` if I can be applied to the specified `eObject`;`false`, otherwise

### targetsEvent

    boolean targetsEvent(Notification notification)

  Queries whether I apply to the specified EMF `notification`. Note that it is OK if I indiscriminately return `true`; this method merely enables an optimization that skips constraints that are known not to apply to the notification in question.

  This method is only invoked on `live` constraints, because `batch`constraints are not invoked in a live context.

  Parameters:
    `notification` - a notification of some change in an EMF model object
  Returns:
    `false` if I need not be executed on this `notification`; `true`, otherwise

### isBatch

    boolean isBatch()

  Queries whether I may be applied in "batch" mode, i.e., outside of any particular editing action context.

  Returns:
    `true` if I support "batch" (contextless) invocation; `false`, otherwise
  See Also:
    `getEvaluationMode()`

### isLive

    boolean isLive()

  Queries whether I may be applied in "live" mode, i.e., within some particular editing action context.

  Returns:
    `true` if I support "live" (contextful) invocation; `false`, otherwise
  See Also:
    `getEvaluationMode()`

### isError

    boolean isError()

  Queries whether the constraint is errored, i.e., not executable because of some error in initializing it.

  Returns:
    whether I represent an errored constraint

### getException

    Throwable getException()

  If I am an `error` constraint, obtains the exception that caused me not to be initialized.

  Returns:
    my exception

### isEnabled

    boolean isEnabled()

  Queries whether the constraint is enabled. `Errored` constraints are never enabled; other constraints may be disabled by the user.

  Returns:
    whether the constraint that I represent is enabled

### setEnabled

    void setEnabled(boolean enabled)

  Sets whether the constraint is enabled. Note that this only has any effect on constraints that are not `errored` and are not in a `mandatory` category.

  Parameters:
    `enabled` - whether the constraint that I represent is enabled
  See Also:
    `isEnabled()`

### setError

    void setError(Throwable exception)

  Sets my error status.

  This method should not be called outside of the validation framework.

  Parameters:
    `exception` - the exception that causes me to be an error constraint

### getCategories

    Set<Category> getCategories()

  Queries the categories that I am a member of.

  Returns:
    an unmodifiable set of `Category`s

### addCategory

    void addCategory(Category category)

  Adds a category to me. If, previously, I was in the default category, then I will no longer be in the default category when this method returns.

  Parameters:
    `category` - my category
  Throws:
    `IllegalArgumentException` - if `category` is the default category, as this is not allowed to be set explicitly

### removeCategory

    void removeCategory(Category category)

  Removes a category from me.

  Parameters:
    `category` - a category

### getMessagePattern

    String getMessagePattern()

  Obtains the localized message pattern configured in the XML for my constraint. It must conform to the conventions of the `NLS` class.

  Returns:
    my message pattern
  See Also:
    `NLS`

### getBody

    String getBody()

  If I represent an in-line constraint (whose algorithm is implemented in an XML file, script, or some other source than Java), then this method obtains its body.

  Returns:
    the constraint body, if appropriate to the language

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