RAD Studio (Common)
ContentsIndex
PreviousUpNext
OCL Support

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, as it turned out a visual diagram-based language is limited in its expressiveness. 

OCL 2.0 is the newest version of the OMG’s constraint language to accompany their suit of Object Oriented modelling languages. 

The use of OCL as an accompanying constraint and query language for modelling with these languages is essential. 

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

 

OCL constraint

 

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 expression

 

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

OCL is supported for the following diagram types:  

Diagram types with OCL support  

Diagram type  
Version of UML  
How support is provided  
Class (class, namespace, package)  
UML 1.5, 2.0  
Creating object constraints is supported.  
Interaction (Sequence and Communication)  
UML 2.0  
State invariant constraints for lifelines and constraints for the operands of the combined fragments as OCL expressions.  
State Machine  
UML 2.0  
Guard conditions of transitions as OCL expressions.  
Use Case  
UML 2.0  
Pre- and post-condition constraints for the behavior associated with the use cases as OCL expressions. For example, an interaction chosen as a behavior.  
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!