The OCL Standard Library Language

The OCL Standard Library Language

The OCL Standard Library Language is used to define the OCL Standard Library, for which *.oclstdlib is the default extension.

The standard library can be replaced or extended.

Syntax

OCL Standard Library Document

The Library syntax defines an OCL Standard Library document, for which *.oclstdlib is the default extension.

Zero or more library documents may be imported for use within the composite library whose name must be specified.

A namespace prefix and namespace URI may optionally be specified.

The body of the document comprises

  • optional module declaration

  • optional specification of the OCL Standard libraries

  • optional import of referenced Ecore or UML or OCLinEcore resources

  • Precedences

  • a hierarchy of Packages

  • a hierarchy of Classifiers

  • Annotations

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.

The default library may be extended by specifying it as the first library import.

library 'http://www.eclipse.org/ocl/3.1.0/OCL.oclstdlib'

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.

Precedence

The Precedence syntax defines the precedence and associativity of infix operators.

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.

Multiple lists of precedence levels can be merged from imported libraries provided the lists are interleaveable with conflict or ambiguity.

Package

The Package syntax defines a nested hierarchy of packages and classifiers .

A Package has a name and optionally a namespace prefix and namespace URI.

The content of a Package may comprise Packages, Classifiers and Annotations.

Class and Classifier

The Class and Classifier syntax define a type within a Package.

A Class has a name and optionally template parameters. A class may also name the metatype such as PrimitiveType that the Class is an instance of.

A Class may extend one or more other Classes that may be specialized using the template parameters.

The content of a Class may comprise Operations, Properties, Invariants and Annotations.

Inv

The Inv syntax defines an invariant constraint.

Operation

The general Operation syntax defines a conventional Operation or Iteration.

LibOperation

The LibOperation syntax defines a conventional Operation.

An Operation may be static and has a name and optionally template parameters.

An Operation has zero of more Parameters.

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.examples.library.LibraryOperation interface. This class is used when evaluating the operation.

The content of an Operation may comprise Preconditions, Postconditions and Annotations.

The static qualifier supports declaration of static library operations such as allInstances() that are invoked on types rather than objects.

LibIteration

The LibIteration syntax defines an Iteration.

An Iteration has a name and optionally template parameters.

An Iteration has one or more comma-separated Iterators.

Optionally following a semicolon, an Iteration has one or more comma-separated Accumulators.

Optionally following a bar, an Iteration has one or more comma-separated Parameters.

An Iteration has a return Type. An Iteration may specify the name of a Java class implementing the org.eclipse.ocl.examples.library.LibraryIteration interface. This class is used when evaluating the iteration.

The content of an Iteration may comprise Preconditions, Postconditions and Annotations.

Iterator

The Iterator syntax defines an Iterator.

Accumulator

The Accumulator syntax defines an Accumulator.

Parameter

The Parameter syntax defines a Parameter.

Pre

The Pre syntax defines a precondition constraint.

Post

The Post syntax defines a postcondition constraint.

LibProperty

The LibProperty syntax defines an Property.

An Property may be static and has a name and a Type.

A Property may specify the name of a Java class implementing the org.eclipse.ocl.examples.library.LibraryProperty interface. This class is used when evaluating the iteration.

The content of a Property may comprise Annotations.

Specification

The Specification syntax integrates an OCL Expression as the specification of a constraint.