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
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

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

  




 

 


org.eclipse.emf.validation.ocl
Class AbstractOCLModelConstraint<C,CT,CLS,E>

java.lang.Object
  extended by 
org.eclipse.emf.validation.ocl.AbstractOCLModelConstraint<C,CT,CLS,E>
Type Parameters:
C - The metaclass corresponding to the UML Classifier in the environment provided by subclasses.
CT - The metaclass corresponding to the UML Constraint in the environment provided by subclasses.
CLS - The metaclass corresponding to the UML Class in the environment provided by subclasses.
E - The metaclass of run-time instances in the environment provided by subclasses.
All Implemented Interfaces:
IModelConstraint

public abstract class AbstractOCLModelConstraint<C,CT,CLS,E>
extends Object
implements IModelConstraint

An OCL-language implementation of the IModelConstraint interface. This class considers the OCL constraint text as a context-free expression, possibly targeting multiple model types (because the validation framework permits declaration of any number of targets). A separate OCL Query is created and cached for each of these target types as required.

Any problems in parsing or executing the OCL will result in the constraint being disabled at run-time.

This class is intended to be used by clients of the validation framework that need to customize the OCL parsing environment for their constraints.

The generic type parameters declared by this class correspond to the like-named parameters of the EnvironmentFactory interface.


Field Summary
 
Fields inherited from interface org.eclipse.emf.validation.model. IModelConstraint
STATUS_CODE_SUCCESS
 
Constructor Summary
AbstractOCLModelConstraint ( IConstraintDescriptor descriptor)
          Initializes me with the descriptor which contains my OCL body.
 
Method Summary
protected   EnvironmentFactory createEnvironmentFactory ()
          Deprecated. Override the createOCLEnvironmentFactory() method, instead.
protected   EnvironmentFactory<?, C,?,?,?,?,?,?,?, CT, CLS, E> createOCLEnvironmentFactory ()
          Creates an Environment Factory suitable for the parsing of the client's OCL constraints.
  Query getCondition ( EClass eClass)
          Deprecated. Use the getConstraintCondition(EObject) method, instead.
  Query< C, CLS, E> getConstraintCondition ( EObject target)
          Obtains the cached OCL query/constraint that implements me for the specified element's metaclass.
  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.
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractOCLModelConstraint

public AbstractOCLModelConstraint(
IConstraintDescriptor descriptor)
Initializes me with the descriptor which contains my OCL body.

Parameters:
descriptor - the descriptor, which must contain an OCL expression in its body
Method Detail

createOCLEnvironmentFactory

protected 
EnvironmentFactory<?,
C,?,?,?,?,?,?,?,
CT,
CLS,
E> createOCLEnvironmentFactory()
Creates an Environment Factory suitable for the parsing of the client's OCL constraints. This default implementation returns null, signalling that compatibility with the OCL 1.0 API is required. In such case, the result of the createEnvironmentFactory() method is used.

Returns:
an environment factory for parsing OCL constraints, or null to use the result of the createEnvironmentFactory() method
Since:
1.1

createEnvironmentFactory



@Deprecated
protected 
EnvironmentFactory createEnvironmentFactory()
Deprecated. Override the createOCLEnvironmentFactory() method, instead.

Creates an environment factory for compatibility with the OCL 1.0 API.


getConstraintCondition

public 
Query<
C,
CLS,
E> getConstraintCondition(
EObject target)
Obtains the cached OCL query/constraint that implements me for the specified element's metaclass.

Parameters:
target - a model element
Returns:
the corresponding OCL query

getCondition



@Deprecated
public 
Query getCondition(
EClass eClass)
Deprecated. Use the getConstraintCondition(EObject) method, instead.

Obtains the cached OCL query/constraint that implements me for the specified EMF type.

Parameters:
eClass - an EMF model object type
Returns:
the corresponding OCL query

validate

public 
IStatus validate(
IValidationContext ctx)
Description copied from interface: IModelConstraint

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(
                 ctx,
                 problemElements,
                 "Problem with {0}",
                 new Object[] {problemElements});
     }
     
     private IStatus checkSecondCondition(IValidationContext ctx) ...
 

Specified by:
validate in interface IModelConstraint
Parameters:
ctx - the validation context that provides access to the current constraint evaluation environment. The framework will never pass a null value
Returns:
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[])

getDescriptor

public 
IConstraintDescriptor getDescriptor()
Description copied from interface: IModelConstraint
Obtains my descriptor, which provides a variety of meta-data about me.

Specified by:
getDescriptor in interface IModelConstraint
Returns:
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