blob: fe05fecff0fa76b1760cee1364beef9d7dd5723d [file] [log] [blame]
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Validators</title>
<link href="book.css" rel="stylesheet" type="text/css">
<meta content="DocBook XSL Stylesheets V1.75.1" name="generator">
<link rel="home" href="index.html" title="OCL Documentation">
<link rel="up" href="PivotProgrammersGuide.html" title="Unified or Pivot Programmers Guide">
<link rel="prev" href="PivotProgrammersGuide.html" title="Unified or Pivot Programmers Guide">
<link rel="next" href="PivotEvaluator.html" title="The Pivot Evaluator">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">Validators</h1>
<div class="section" title="Validators">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="Validators"></a>Validators</h2>
</div>
</div>
</div>
<p>When using the Pivot metamodel, there are two specialized validators available to support integration of OCL in to a larger Ecore environment. </p>
<div class="section" title="OCLinEcoreEObjectValidator">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="OCLinEcoreEObjectValidator"></a>OCLinEcoreEObjectValidator</h3>
</div>
</div>
</div>
<p>Unfortunately, in the Indigo release, EMF does not support this customization and so must be activated by explicitly using an EValidator that is aware of the ValidationDelegateExtension extended API. This is available by using the OCLinEcoreEObjectValidator, which you may install globally by:</p>
<div class="literallayout">
<p>
<code class="code">EValidator.Registry.INSTANCE.put(null,&nbsp;new&nbsp;OCLinEcoreEObjectValidator());<br>
</code>
</p>
</div>
<p></p>
<p>or more selectively by adjusting the inheritance of the Validator class generated by EMF from (for a model of a Company):</p>
<div class="literallayout">
<p>
<code class="code">import&nbsp;org.eclipse.emf.ecore.util.EObjectValidator;<br>
<br>
/**<br>
&nbsp;*&nbsp;&lt;!--&nbsp;begin-user-doc&nbsp;--&gt;<br>
&nbsp;*&nbsp;The&nbsp;&lt;b&gt;Validator&lt;/b&gt;&nbsp;for&nbsp;the&nbsp;model.<br>
&nbsp;*&nbsp;&lt;!--&nbsp;end-user-doc&nbsp;--&gt;<br>
&nbsp;*&nbsp;@see&nbsp;company.CompanyPackage<br>
&nbsp;*/<br>
public&nbsp;class&nbsp;CompanyValidator&nbsp;extends&nbsp;EObjectValidator&nbsp;{<br>
</code>
</p>
</div>
<p></p>
<p>to</p>
<div class="literallayout">
<p>
<code class="code">import&nbsp;org.eclipse.ocl.xtext.oclinecore.validation.OCLinEcoreEObjectValidator;<br>
<br>
/**<br>
&nbsp;*&nbsp;&lt;!--&nbsp;begin-user-doc&nbsp;--&gt;<br>
&nbsp;*&nbsp;The&nbsp;&lt;b&gt;Validator&lt;/b&gt;&nbsp;for&nbsp;the&nbsp;model.<br>
&nbsp;*&nbsp;&lt;!--&nbsp;end-user-doc&nbsp;--&gt;<br>
&nbsp;*&nbsp;@see&nbsp;company.CompanyPackage<br>
&nbsp;*&nbsp;@generated&nbsp;not<br>
&nbsp;*/<br>
public&nbsp;class&nbsp;CompanyValidator&nbsp;extends&nbsp;OCLinEcoreEObjectValidator&nbsp;{<br>
</code>
</p>
</div>
<p></p>
<p>Note the
<span class="bold"><strong>@generated not</strong></span> that indicates that the class interface is manually defined. Do not use
<span class="bold"><strong>@generated NOT</strong></span> since that indicates that the whole class is manually defined.
</p>
</div>
<div class="section" title="CompleteOCLEObjectValidator">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="CompleteOCLEObjectValidator"></a>CompleteOCLEObjectValidator</h3>
</div>
</div>
</div>
<p>The CompleteOCLEObjectValidator is used to enable Complete OCL documents to participate in the validation processing of an Xtext editor.</p>
<p>The APIs for merging Complete OCL and Ecore as intermediate Pivots and then migrating the Pivot back to Ecore are experimental.</p>
</div>
</div>
</body>
</html>