RE: OCL expression

RE: OCL expression

From: Waldin, Earl <>
Date: Mon, 18 Dec 2006 14:45:03 +0100
Message-ID: <>
Dear Ajaree

See below in text for my response.

> -----Original Message-----
> From: 
> [] On Behalf Of ajaree naco
> Sent: Monday, 18 December, 2006 08:50
> To:
> Subject: OCL expression
> Dear All,
> I have a problem on issuing OCL expression to restrict a class A's
constraint as
> "class A can not have any subclass"
> How can I express this constraint between: 
> 1. context A inv: self.inheritedMember->isempty()
> 2. context A inv: self.generalization->size() = 0

These two constraints do not say what you want. The first essentially
says that the superclasses of A cannot have any members. The second says
that class A cannot itself be a subclass. Neither one prevents, say a
class B, from being a subclass of A.

In UML 1.4 you could have

  context A inv: self.isLeaf

isLeaf corresponds to final in Java. UML 1.4 distinguishes between
isLeaf for operations and classes. The metaclass Class in UML 1.4
inherited the property isLeaf from the metaclass GeneralizableElement.
So in UML 1.4 isLeaf = true means that a class cannot be subclassed.

I really have no idea how to say this in UML 2.0 without resorting to
allInstances, which is to be avoided. The metaclass Class inherits the
isLeaf property from RedefinableElement. However, this is not related to
generalization. Redefinition has only to do with overriding/redefining
owned members in the context of a classifier. It is typically used for
features such as attributes or operations, in which case a subclass
would redefine an attribute or operation of one of its superclasses. In
the case of classes you could use it in the following way. Assume you
have a class A containing a nested class A1, a class B containing a
nested class B1, and B is a subclass of A. Then B1 could redefine A1 as
long as A1 is not a leaf. Stated in a positive sense, if we had the

   "context A1 inv: self.isLeaf

then B1 could not redefine A1. B1 could, however, still be a subclass of

I won't list my allInstances hack here.

Does anybody know how to say this in UML 2.0?

	-Earl Waldin

Earl Waldin				tel: +41 31 828 9222
Paranor AG				fax: +41 31 828 9299
Juraweg 14				email: earl dot waldin at
paranor dot ch
CH-3046 Wahlendorf

> or any suggestion ?
> Best Regards,
> Ajaree
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> To remove yourself from this list please mail 
> with a message containing the word "unsubscribe".
Received on Mon 18 Dec 2006 - 13:45:08 GMT