Object Constraint Language (OCL) Support

From RAD Studio
Jump to: navigation, search

Go Up to Modeling Concepts


Constraints allow you to add new rules or modify existing ones. Constraints may be written as free-form text. A constraint is a condition expressed as a text string in a natural language, some programming language, or in the UML's Object Constraint Language (OCL). Constraints may be attached to more than one element.

About OCL

The Object Constraint Language (OCL) is a textual language, especially designed for use in the context of diagrammatic languages such as the UML. OCL was added to UML to increase expressiveness of visual diagram-based features.

OCL 2.0 is the newest version of the OMG's (Object Management Group) constraint language to accompany their suit of object-oriented modeling languages.

Note: Portions of this product include the Object Constraint Language Library, courtesy of Kent University, United Kingdom. See http://www.cs.kent.ac.uk.

OCL constraints and expressions

OCL constraints

The Tool Palette on some types of diagrams (for example, UML 2.0 Class Diagram) contains buttons that enable you to create OCL constraints as design elements on diagrams and link these constraints with the desired context.

You can show or hide constraint elements for the better presentation of your diagrams.

OCL support for constraints provides error highlighting. The text of the constraint is validated when the constraint is linked to its context. The valid constraints are displayed in the regular font. Invalid constraints or OCL expressions with syntax errors are displayed in a red font.

Constrained elements are marked with the decorators. The decorators are small icons attached to the context elements of constraints. If a constraint is valid, the decorator is green; otherwise the decorator is red. If the constraints are concealed, you can still monitor the validity of constraints by means of the decorators.

Any OCL constraint contains an OCL expression.

OCL expressions

For OCL expressions without object constraints (expressions as properties of other nodes), no validation is performed, because no valid OCL context can be set for these elements.

See Also