blob: d43fcec1c75163c7bb314f575979238a4b95c409 [file] [log] [blame]
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>The OCL Standard Library Language</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="UsersGuide.html" title="Users Guide">
<link rel="prev" href="CompleteOCL.html" title="The Complete OCL Language">
<link rel="next" href="Editors.html" title="Editors">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">The OCL Standard Library Language</h1>
<div class="section" title="The OCL Standard Library Language">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="OCLstdlib"></a>The OCL Standard Library Language</h2>
</div>
</div>
</div>
<p>The OCL Standard Library Language is used to define the OCL Standard Library, for which *.oclstdlib is the default extension.</p>
<p>The standard library can be replaced or extended.</p>
<p>The source for the OCL Standard Library may be found at model/OCL-2.5.oclstdlib in the org.eclipse.ocl.library plugin. </p>
<div class="section" title="Syntax">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="Syntax4"></a>Syntax</h3>
</div>
</div>
</div>
<div class="section" title="Grammar Implementation">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="GrammarImplementation4"></a>Grammar Implementation</h4>
</div>
</div>
</div>
<p>The grammar used by the Xtext editors may be found at:</p>
<p>/src/org/eclipse/ocl/examples/xtext/oclstdlib/OCLstdlib.xtext</p>
<p>in the org.eclipse.ocl.xtext.oclstdlib plugin. The OCL Standard Library grammar extends the Essential OCL grammar.</p>
</div>
<div class="section" title="OCL Standard Library Document">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Library"></a>OCL Standard Library Document</h4>
</div>
</div>
</div>
<p>The Library syntax defines an OCL Standard Library document, for which *.oclstdlib is the default extension.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-library1.png"></div>
<p>
</p>
<p>Zero or more library documents may be imported for use within the composite library whose name must be specified.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-library2.png"></div>
<p>
</p>
<p>A namespace prefix and namespace URI may optionally be specified.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-library3.png"></div>
<p>
</p>
<p>The body of the document comprises</p>
<div class="itemizedlist">
<ul class="itemizedlist" type="disc">
<li class="listitem">
<p>optional module declaration</p>
</li>
<li class="listitem">
<p>optional specification of the OCL Standard libraries</p>
</li>
<li class="listitem">
<p>optional import of referenced Ecore or UML or OCLinEcore resources</p>
</li>
<li class="listitem">
<p>
<a class="link" href="OCLstdlib.html#OCLstdlib-Precedence" title="Precedence">Precedences</a>
</p>
</li>
<li class="listitem">
<p>a hierarchy of
<a class="link" href="OCLstdlib.html#OCLstdlib-Package" title="Package">Packages</a>
</p>
</li>
<li class="listitem">
<p>a hierarchy of
<a class="link" href="OCLstdlib.html#OCLstdlib-Classifier" title="Class and Classifier">Classifiers</a>
</p>
</li>
<li class="listitem">
<p>Annotations</p>
</li>
</ul>
</div>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-library.png"></div>
<p>
</p>
<p>Zero or more external libraries may be imported so that their definitions are merged to form a composite library of basic and extended evaluation capability.</p>
<p>The default library may be extended by specifying it as the first library import.</p>
<div class="literallayout">
<p>
<code class="code">library&nbsp;'http://www.eclipse.org/ocl/3.1.0/OCL.oclstdlib'<br>
</code>
</p>
</div>
<p></p>
<p>The namespace URI of the first library package defines the namespace URI of the composite library. The namespace URI of subsequent library imports may not conflict, but may be null.</p>
</div>
<div class="section" title="Precedence">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Precedence"></a>Precedence</h4>
</div>
</div>
</div>
<p>The Precedence syntax defines the precedence and associativity of infix operators.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-precedence.png"></div>
<p>
</p>
<p>Each entry in a list of precedences names a precedence level taht can then be used by an infix operator. Each level can be either left or right associative.</p>
<p>Multiple lists of precedence levels can be merged from imported libraries provided the lists are interleaveable with conflict or ambiguity.</p>
</div>
<div class="section" title="Package">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Package"></a>Package</h4>
</div>
</div>
</div>
<p>The Package syntax defines a nested hierarchy of packages and classifiers .</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-package1.png"></div>
<p>
</p>
<p>A Package has a name and optionally a namespace prefix and namespace URI.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-package2.png"></div>
<p>
</p>
<p>The content of a Package may comprise
<a class="link" href="OCLstdlib.html#OCLstdlib-Package" title="Package">Packages</a>,
<a class="link" href="OCLstdlib.html#OCLstdlib-Classifier" title="Class and Classifier">Classifiers</a> and Annotations.
</p>
</div>
<div class="section" title="Class and Classifier">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Classifier"></a>Class and Classifier</h4>
</div>
</div>
</div>
<p>The Class and Classifier syntax define a type within a Package.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-classifier.png"></div>
<p>
</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-class1.png"></div>
<p>
</p>
<p>A Class has a name and optionally template parameters. A class may also name the metatype such as
<code class="code">PrimitiveType</code> that the Class is an instance of.
</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-class2.png"></div>
<p>
</p>
<p>A Class may extend one or more other Classes that may be specialized using the template parameters.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-class3.png"></div>
<p>
</p>
<p>The content of a Class may comprise
<a class="link" href="OCLstdlib.html#OCLstdlib-Operation" title="Operation">Operations</a>,
<a class="link" href="OCLstdlib.html#OCLstdlib-Property" title="LibProperty">Properties</a>,
<a class="link" href="OCLstdlib.html#OCLstdlib-Inv" title="Inv">Invariants</a> and Annotations.
</p>
</div>
<div class="section" title="Inv">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Inv"></a>Inv</h4>
</div>
</div>
</div>
<p>The Inv syntax defines an invariant constraint.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-inv.png"></div>
<p>
</p>
</div>
<div class="section" title="Operation">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Operation"></a>Operation</h4>
</div>
</div>
</div>
<p>The general Operation syntax defines a conventional Operation or Iteration.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-operation.png"></div>
<p>
</p>
</div>
<div class="section" title="LibOperation">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-LibOperation"></a>LibOperation</h4>
</div>
</div>
</div>
<p>The LibOperation syntax defines a conventional Operation.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-operation1.png"></div>
<p>
</p>
<p>An Operation may be static and has a name and optionally template parameters.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-operation2.png"></div>
<p>
</p>
<p>An Operation has zero of more
<a class="link" href="OCLstdlib.html#OCLstdlib-Parameter" title="Parameter">Parameters</a>.
</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-operation3.png"></div>
<p>
</p>
<p>An Operation has a return Type. An infix operation may specify a precedence level. An operation may specify the name of a Java class implementing the org.eclipse.ocl.library.LibraryOperation interface. This class is used when evaluating the operation.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-operation4.png"></div>
<p>
</p>
<p>The content of an Operation may comprise
<a class="link" href="OCLstdlib.html#OCLstdlib-Pre" title="Pre">Preconditions</a>,
<a class="link" href="OCLstdlib.html#OCLstdlib-Post" title="Post">Postconditions</a> and Annotations.
</p>
<p>The
<code class="code">static</code> qualifier supports declaration of static library operations such as
<code class="code">allInstances()</code> that are invoked on types rather than objects.
</p>
</div>
<div class="section" title="LibIteration">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-LibIteration"></a>LibIteration</h4>
</div>
</div>
</div>
<p>The LibIteration syntax defines an Iteration.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-iteration1.png"></div>
<p>
</p>
<p>An Iteration has a name and optionally template parameters.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-iteration2.png"></div>
<p>
</p>
<p>An Iteration has one or more comma-separated
<a class="link" href="OCLstdlib.html#OCLstdlib-Iterator" title="Iterator">Iterators</a>.
</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-iteration3.png"></div>
<p>
</p>
<p>Optionally following a semicolon, an Iteration has one or more comma-separated
<a class="link" href="OCLstdlib.html#OCLstdlib-Accumulator" title="Accumulator">Accumulators</a>.
</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-iteration4.png"></div>
<p>
</p>
<p>Optionally following a bar, an Iteration has one or more comma-separated
<a class="link" href="OCLstdlib.html#OCLstdlib-Parameter" title="Parameter">Parameters</a>.
</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-iteration5.png"></div>
<p>
</p>
<p>An Iteration has a return Type. An Iteration may specify the name of a Java class implementing the org.eclipse.ocl.library.LibraryIteration interface. This class is used when evaluating the iteration.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-iteration6.png"></div>
<p>
</p>
<p>The content of an Iteration may comprise
<a class="link" href="OCLstdlib.html#OCLstdlib-Pre" title="Pre">Preconditions</a>,
<a class="link" href="OCLstdlib.html#OCLstdlib-Post" title="Post">Postconditions</a> and Annotations.
</p>
</div>
<div class="section" title="Iterator">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Iterator"></a>Iterator</h4>
</div>
</div>
</div>
<p>The Iterator syntax defines an Iterator.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-iterator.png"></div>
<p>
</p>
</div>
<div class="section" title="Accumulator">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Accumulator"></a>Accumulator</h4>
</div>
</div>
</div>
<p>The Accumulator syntax defines an Accumulator.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-accumulator.png"></div>
<p>
</p>
</div>
<div class="section" title="Parameter">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Parameter"></a>Parameter</h4>
</div>
</div>
</div>
<p>The Parameter syntax defines a Parameter.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-parameter.png"></div>
<p>
</p>
</div>
<div class="section" title="Pre">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Pre"></a>Pre</h4>
</div>
</div>
</div>
<p>The Pre syntax defines a precondition constraint.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-pre.png"></div>
<p>
</p>
</div>
<div class="section" title="Post">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Post"></a>Post</h4>
</div>
</div>
</div>
<p>The Post syntax defines a postcondition constraint.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-post.png"></div>
<p>
</p>
</div>
<div class="section" title="LibProperty">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Property"></a>LibProperty</h4>
</div>
</div>
</div>
<p>The LibProperty syntax defines an Property.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-property1.png"></div>
<p>
</p>
<p>An Property may be static and has a name and a Type.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-property2.png"></div>
<p>
</p>
<p>A Property may specify the name of a Java class implementing the org.eclipse.ocl.library.LibraryProperty interface. This class is used when evaluating the iteration.</p>
<p>The content of a Property may comprise Annotations.</p>
</div>
<div class="section" title="Specification">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="OCLstdlib-Specification"></a>Specification</h4>
</div>
</div>
</div>
<p>The Specification syntax integrates an OCL Expression as the specification of a constraint.</p>
<p>
</p>
<div class="mediaobject">
<img src="images/1400-specification.png"></div>
<p>
</p>
</div>
</div>
</div>
</body>
</html>