org.eclipse.ocl.examples.pivot.uml
Class UMLOCLEValidator

java.lang.Object
  extended by org.eclipse.ocl.examples.pivot.uml.UMLOCLEValidator
All Implemented Interfaces:
org.eclipse.emf.ecore.EValidator

public class UMLOCLEValidator
extends java.lang.Object
implements org.eclipse.emf.ecore.EValidator

UMLOCLEValidator provides the validation support for UML elements that exploit OCL.

Typically used with a Diagnostician as:

        EValidatorRegistryImpl registry = new EValidatorRegistryImpl();
        registry.put(UMLPackage.eINSTANCE, UMLOCLEValidator.INSTANCE);
        Diagnostician diagnostician = new Diagnostician(registry);
        Diagnostic diagnostic = dignostician.validate(eObject, validationContext);
 


Nested Class Summary
static class UMLOCLEValidator.ConstraintEvaluatorWithDiagnostics
          ConstraintEvaluatorWithoutDiagnostics provides the richer ConstraintEvaluator support for use when diagnostics are required.
static class UMLOCLEValidator.ConstraintEvaluatorWithoutDiagnostics
          ConstraintEvaluatorWithoutDiagnostics provides the minimal ConstraintEvaluator support for use when no diagnostics are required.
protected static class UMLOCLEValidator.WeakOCLReference
          WeakOCLReference maintains the reference to the OCL context within the Diagnostician context and disposes of it once the Diagnostician is done.
 
Nested classes/interfaces inherited from interface org.eclipse.emf.ecore.EValidator
org.eclipse.emf.ecore.EValidator.Descriptor, org.eclipse.emf.ecore.EValidator.PatternMatcher, org.eclipse.emf.ecore.EValidator.Registry, org.eclipse.emf.ecore.EValidator.SubstitutionLabelProvider, org.eclipse.emf.ecore.EValidator.ValidationDelegate
 
Field Summary
static UMLOCLEValidator INSTANCE
           
protected  boolean mayUseNewLines
           
static UMLOCLEValidator NO_NEW_LINES
           
static TracingOption VALIDATE_INSTANCE
           
static TracingOption VALIDATE_OPAQUE_ELEMENT
           
 
Fields inherited from interface org.eclipse.emf.ecore.EValidator
MARKER, RELATED_URIS_ATTRIBUTE, URI_ATTRIBUTE
 
Constructor Summary
UMLOCLEValidator(boolean mayUseNewLines)
           
 
Method Summary
protected static void gatherClassifiers(java.util.Set<org.eclipse.uml2.uml.Classifier> allClassifiers, java.util.Set<org.eclipse.uml2.uml.Constraint> allConstraints, org.eclipse.uml2.uml.Classifier newClassifier)
           
protected static void gatherTypes(java.util.Set<Type> allTypes, java.util.Set<DomainConstraint> allConstraints, Type newType)
           
protected  OCL getOCL(java.util.Map<java.lang.Object,java.lang.Object> context)
          Return the OCL context for the validation, caching the created value in the validation context for re-use by further validations.
 boolean validate(org.eclipse.emf.ecore.EClass eClass, org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
           
 boolean validate(org.eclipse.emf.ecore.EDataType eDataType, java.lang.Object value, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
           
 boolean validate(org.eclipse.emf.ecore.EObject eObject, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
           
protected  boolean validateInstance(org.eclipse.emf.ecore.EObject instanceSpecification, org.eclipse.uml2.uml.OpaqueExpression opaqueExpression, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
          Perform the validation of an instanceSpecification against the bodies defined in opaqueExpression.
 boolean validateInstanceSpecification(org.eclipse.uml2.uml.InstanceSpecification instanceSpecification, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
          Validate the OCL aspects of a UML InstanceSpecification, by evaluating all OCL Constraints defined by any of the InstanceSpecification's classifiers on the InstanceSpecification.
 boolean validateOpaqueAction(org.eclipse.uml2.uml.OpaqueAction opaqueAction, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
          Validate the syntax and semantics of any OCL body.
 boolean validateOpaqueBehavior(org.eclipse.uml2.uml.OpaqueBehavior opaqueBehavior, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
          Validate the syntax and semantics of any OCL body.
protected  boolean validateOpaqueElement(java.util.List<java.lang.String> languages, java.util.List<java.lang.String> bodies, org.eclipse.uml2.uml.Element opaqueElement, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
          Perform the semantic validation of the bodies of an opaqueElement using the corresponding languages support.
 boolean validateOpaqueExpression(org.eclipse.uml2.uml.OpaqueExpression opaqueExpression, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
          Validate the syntax and semantics of any OCL bofy.
protected  boolean validateSyntax(org.eclipse.emf.ecore.EObject instance, java.lang.String body, org.eclipse.uml2.uml.Element opaqueElement, org.eclipse.emf.common.util.DiagnosticChain diagnostics, java.util.Map<java.lang.Object,java.lang.Object> context)
          Perform the validation of the body text for an opaqueElement and if instance is non-null use the body to validate the instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INSTANCE

@NonNull
public static final UMLOCLEValidator INSTANCE

NO_NEW_LINES

@NonNull
public static final UMLOCLEValidator NO_NEW_LINES

VALIDATE_INSTANCE

@NonNull
public static final TracingOption VALIDATE_INSTANCE

VALIDATE_OPAQUE_ELEMENT

@NonNull
public static final TracingOption VALIDATE_OPAQUE_ELEMENT

mayUseNewLines

protected final boolean mayUseNewLines
Constructor Detail

UMLOCLEValidator

public UMLOCLEValidator(boolean mayUseNewLines)
Method Detail

gatherClassifiers

protected static void gatherClassifiers(@NonNull
                                        java.util.Set<org.eclipse.uml2.uml.Classifier> allClassifiers,
                                        @NonNull
                                        java.util.Set<org.eclipse.uml2.uml.Constraint> allConstraints,
                                        @NonNull
                                        org.eclipse.uml2.uml.Classifier newClassifier)

gatherTypes

protected static void gatherTypes(@NonNull
                                  java.util.Set<Type> allTypes,
                                  @NonNull
                                  java.util.Set<DomainConstraint> allConstraints,
                                  @NonNull
                                  Type newType)

getOCL

protected OCL getOCL(@NonNull
                     java.util.Map<java.lang.Object,java.lang.Object> context)
Return the OCL context for the validation, caching the created value in the validation context for re-use by further validations. The cached reference is weak to ensure that the OCL context is disposed once no longer in use.


validate

public boolean validate(org.eclipse.emf.ecore.EObject eObject,
                        org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                        java.util.Map<java.lang.Object,java.lang.Object> context)
Specified by:
validate in interface org.eclipse.emf.ecore.EValidator

validate

public boolean validate(org.eclipse.emf.ecore.EClass eClass,
                        org.eclipse.emf.ecore.EObject eObject,
                        org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                        java.util.Map<java.lang.Object,java.lang.Object> context)
Specified by:
validate in interface org.eclipse.emf.ecore.EValidator

validate

public boolean validate(org.eclipse.emf.ecore.EDataType eDataType,
                        java.lang.Object value,
                        org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                        java.util.Map<java.lang.Object,java.lang.Object> context)
Specified by:
validate in interface org.eclipse.emf.ecore.EValidator

validateInstance

protected boolean validateInstance(@NonNull
                                   org.eclipse.emf.ecore.EObject instanceSpecification,
                                   @NonNull
                                   org.eclipse.uml2.uml.OpaqueExpression opaqueExpression,
                                   @Nullable
                                   org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                                   java.util.Map<java.lang.Object,java.lang.Object> context)
Perform the validation of an instanceSpecification against the bodies defined in opaqueExpression.


validateInstanceSpecification

public boolean validateInstanceSpecification(@NonNull
                                             org.eclipse.uml2.uml.InstanceSpecification instanceSpecification,
                                             org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                                             java.util.Map<java.lang.Object,java.lang.Object> context)
Validate the OCL aspects of a UML InstanceSpecification, by evaluating all OCL Constraints defined by any of the InstanceSpecification's classifiers on the InstanceSpecification.

Returns true if all OCL constraints pass.


validateOpaqueAction

public boolean validateOpaqueAction(@NonNull
                                    org.eclipse.uml2.uml.OpaqueAction opaqueAction,
                                    org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                                    java.util.Map<java.lang.Object,java.lang.Object> context)
Validate the syntax and semantics of any OCL body.

Returns true if all OCL bodies are valid.


validateOpaqueBehavior

public boolean validateOpaqueBehavior(@NonNull
                                      org.eclipse.uml2.uml.OpaqueBehavior opaqueBehavior,
                                      org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                                      java.util.Map<java.lang.Object,java.lang.Object> context)
Validate the syntax and semantics of any OCL body.

Returns true if all OCL bodies are valid.


validateOpaqueExpression

public boolean validateOpaqueExpression(@NonNull
                                        org.eclipse.uml2.uml.OpaqueExpression opaqueExpression,
                                        org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                                        java.util.Map<java.lang.Object,java.lang.Object> context)
Validate the syntax and semantics of any OCL bofy.

Returns true if all OCL bodies are valid.


validateOpaqueElement

protected boolean validateOpaqueElement(java.util.List<java.lang.String> languages,
                                        java.util.List<java.lang.String> bodies,
                                        @NonNull
                                        org.eclipse.uml2.uml.Element opaqueElement,
                                        org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                                        java.util.Map<java.lang.Object,java.lang.Object> context)
Perform the semantic validation of the bodies of an opaqueElement using the corresponding languages support.


validateSyntax

protected boolean validateSyntax(@Nullable
                                 org.eclipse.emf.ecore.EObject instance,
                                 @NonNull
                                 java.lang.String body,
                                 @NonNull
                                 org.eclipse.uml2.uml.Element opaqueElement,
                                 @Nullable
                                 org.eclipse.emf.common.util.DiagnosticChain diagnostics,
                                 @NonNull
                                 java.util.Map<java.lang.Object,java.lang.Object> context)
Perform the validation of the body text for an opaqueElement and if instance is non-null use the body to validate the instance. If diagnostics is non-null, problems should be identified by Diagnostic instances added to diagnostics. context may be used to pass additional options from a calling context to the validation, and may be used to pass cached results between successive validations. Returns true if successful, false otherwise.