blob: d3bee72307b6d4ccccb17ae5c72fb1e0f14be136 [file] [log] [blame]
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>OclAny</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="StandardLibrary.html" title="The OCL Standard Library">
<link rel="prev" href="Metaclass.html" title="Metaclass(T)">
<link rel="next" href="OclComparable.html" title="OclComparable">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<h1 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0">
OclAny
</h1>
<div class="section" title="OclAny">
<div class="titlepage">
<div>
<div>
<h2 class="title" style="clear: both">
<a name="OclAny"></a>
<span class="bold"><strong>
<code class="code">OclAny</code>
</strong></span>
</h2>
</div>
</div>
</div>
<p>All types in the UML model and the primitive and collection types in the OCL standard library conforms to the type OclAny.
Conceptually, OclAny behaves as a supertype for all the types.
Features of OclAny are available on each object in all OCL expressions.
OclAny is itself an instance of the metatype AnyType.</p>
<p>All classes in a UML model inherit all operations defined on OclAny.
To avoid name conflicts between properties in the model and the properties inherited from OclAny,
all names on the properties of OclAny start with &lsquo;ocl.&rsquo;
Although theoretically there may still be name conflicts, they can be avoided.
One can also use qualification by OclAny (name of the type) to explicitly refer to the OclAny properties.</p>
<p>Operations of OclAny, where the instance of OclAny is called object.</p>
<p>
<span class="bold"><strong>Operations</strong></span>
</p>
<p>
<code class="code">=(object2 : OclSelf) : Boolean</code>
precedence:
<code class="code">EQUALITY</code>
</p>
<p>True if
<code class="code">self</code> is the same object as object2. Infix operator.
</p>
<div class="literallayout">
<p>
<code class="code">post:&nbsp;result&nbsp;=&nbsp;self&nbsp;=&nbsp;object2<br>
</code>
</p>
</div>
<p></p>
<p>
<code class="code">&lt;&gt;(object2 : OclSelf) : Boolean</code>
precedence:
<code class="code">EQUALITY</code>
</p>
<p>True if
<code class="code">self</code> is a different object from object2. Infix operator.
</p>
<div class="literallayout">
<p>
<code class="code">post:&nbsp;result&nbsp;=&nbsp;not&nbsp;(self&nbsp;=&nbsp;object2)<br>
</code>
</p>
</div>
<p></p>
<p>
<code class="code">oclAsSet() : Set(OclSelf)</code>
</p>
<p>Returns a Set with
<code class="code">self</code> as the sole content, unless
<code class="code">self</code> is
<code class="code">null</code> in which case returns an empty set,
</p>
<p>
<code class="code">oclAsType(TT)(type : Metaclass(TT)) : TT[?]</code>
</p>
<p>Evaluates to
<code class="code">self</code>, where
<code class="code">self</code> is of the type identified by T.
The type T may be any classifier defined in the UML model;
if the actual type of
<code class="code">self</code> at evaluation time does not conform to T,
then the oclAsType operation evaluates to
<code class="code">invalid</code>.
</p>
<p>In the case of feature redefinition, casting an object to a supertype of its actual type
does not access the supertype&rsquo;s definition of the feature;
according to the semantics of redefinition, the redefined feature simply does not exist for the object.
However, when casting to a supertype, any features additionally defined by the subtype are suppressed.</p>
<div class="literallayout">
<p>
<code class="code">post&nbsp;IsSelf:&nbsp;result&nbsp;=&nbsp;self<br>
</code>
</p>
</div>
<p></p>
<div class="literallayout">
<p>
<code class="code">post&nbsp;IsType:&nbsp;result.oclIsKindOf(type)<br>
</code>
</p>
</div>
<p></p>
<p>
<code class="code">oclIsInState(statespec : OclState) : Boolean</code>
</p>
<p>Evaluates to
<code class="code">true</code> if the
<code class="code">self</code> is in the state indentified by statespec.
</p>
<p>
<code class="code">oclIsInvalid() : Boolean validating</code>
</p>
<p>Evaluates to
<code class="code">true</code> if the
<code class="code">self</code> is equal to OclInvalid.
</p>
<div class="literallayout">
<p>
<code class="code">post:&nbsp;result&nbsp;=&nbsp;self.oclIsTypeOf(OclInvalid)<br>
</code>
</p>
</div>
<p></p>
<p>
<code class="code">oclIsKindOf(T)(type : Metaclass(T)) : Boolean</code>
</p>
<p>Evaluates to
<code class="code">true</code> if the type of
<code class="code">self</code> conforms to t.
That is,
<code class="code">self</code> is of type t or a subtype of t.
</p>
<p>
<code class="code">oclIsNew() : Boolean</code>
</p>
<p>Can only be used in a postcondition.
Evaluates to
<code class="code">true</code> if the
<code class="code">self</code> is created during performing the operation (for instance, it didn&rsquo;t exist at precondition time).
</p>
<p>
<code class="code">oclIsTypeOf(T)(type : Metaclass(T)) : Boolean</code>
</p>
<p>Evaluates to
<code class="code">true</code> if
<code class="code">self</code> is of the type t but not a subtype of t
</p>
<p>
<code class="code">oclIsUndefined() : Boolean validating</code>
</p>
<p>Evaluates to
<code class="code">true</code> if the
<code class="code">self</code> is equal to
<code class="code">invalid</code> or equal to
<code class="code">null</code>.
</p>
<div class="literallayout">
<p>
<code class="code">post:&nbsp;result&nbsp;=&nbsp;self.oclIsTypeOf(OclVoid)&nbsp;or&nbsp;self.oclIsTypeOf(OclInvalid)<br>
</code>
</p>
</div>
<p></p>
<p>
<code class="code">oclLog() : OclSelf</code>
</p>
<p>Evaluates to the self, with the side effect of generating a log message comprising self.</p>
<p>
<code class="code">oclLog(message : String) : OclSelf</code>
</p>
<p>Evaluates to the self, with the side effect of generating a log message comprising message followed by self.</p>
<p>
<code class="code">oclType() : Metaclass(OclSelf)</code>
</p>
<p>Evaluates to the type of which
<code class="code">self</code> is an instance.
</p>
<p>
<code class="code">toString() : String</code>
</p>
<p>Returns a string representation of
<code class="code">self</code>.
</p>
</div>
</body>
</html>