Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Interface IModelConstraint

All Known Implementing Classes:
AbstractOCLModelConstraint, ModelConstraint

public interface IModelConstraint

Interface implemented by all constraint objects in the EMF model validation framework, providing the validate request.

Field Summary
          The status code reported in the IStatus when a constraint succeeds.
Method Summary
  IConstraintDescriptor getDescriptor ()
          Obtains my descriptor, which provides a variety of meta-data about me.
  IStatus validate ( IValidationContext ctx)
           Validates an object in the specified context.

Field Detail


static final int STATUS_CODE_SUCCESS
The status code reported in the IStatus when a constraint succeeds.

See Also:
Constant Field Values
Method Detail


IStatus validate(
IValidationContext ctx)

Validates an object in the specified context. The target of the validation operation is available from the context object.

Note that it is best to use the IValidationContext.createSuccessStatus() and IValidationContext.createFailureStatus(Object...) methods of the context object to create the status object returned from this method, to ensure that the status object returned is correctly handled by the validation system.

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, org.eclipse.emf.ecore.EObject, Collection, String, Object...) method. In these cases, also, each resulting status can store a distinct result locus. For example:

     public IStatus validate(IValidationContext ctx) {
         List problems = new java.util.ArrayList();
         // check the first condition.  This method adds results to the
         //    ctx's result locus if it finds a problem
         IStatus problem = checkFirstCondition(ctx);
         if (problem != null) problems.add(problem);
         // check another condition, involving different objects
         problem = checkSecondCondition(ctx);
         if (problem != null) problems.add(problem);
         return problems.isEmpty()? ctx.createSuccessStatus() :
             ConstraintStatus.createMultiStatus(ctx, problems);
     private IStatus checkFirstCondition(IValidationContext ctx) {
         EObject target = ctx.getTarget();
         Collection problemElements = ...; // collect problem elements
         boolean ok = ... ;  // check the target and some related objects
         return ok? null : ConstraintStatus.createStatus(
                 "Problem with {0}",
                 new Object[] {problemElements});
     private IStatus checkSecondCondition(IValidationContext ctx) ...

ctx - the validation context that provides access to the current constraint evaluation environment. The framework will never pass a null value
the status of validation of the target object. The IStatus.getSeverity() of the record is either IStatus.OK to indicate success, or some other value to indicate that validation failed. Must not return null
See Also:
IValidationContext.createSuccessStatus(), IValidationContext.createFailureStatus(Object...), ConstraintStatus.createStatus(IValidationContext, org.eclipse.emf.ecore.EObject, Collection, String, Object[])


IConstraintDescriptor getDescriptor()
Obtains my descriptor, which provides a variety of meta-data about me.

my constraint descriptor

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

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire