The oclIsTypeOf() operation expects a type object (the actual
classifier), not a name. So, for example,

c1.oclIsTypeOf(_package::MyClass)

Two notes:

- 'package' is a reserved word in OCL; it must be prefixed by an
underscore
- you probably want oclIsKindOf to test for type conformance, not just
the exact type

What's more is that in UML, the implementation of interfaces is not a
type conformance relationship as the generalization of classes (or other
kinds of classifier) is. Thus, an object that is an instance of some
class is *not* an instance of any interfaces implemented by that class.
A consequence of this is that the classes implementing an interface must
always re-specify the features of the interface, as they do not inherit
those features from the interface. According to the spec, this
re-specification can even have a different structure according to the
domain, the example given being the implementation of an interface
property by Java-bean-style accessor operations.

In general, the OCL type system is oblivious to interfaces.

HTH,

Christian

On Wed, 2009-03-25 at 01:34 +0000, Victor Hugo wrote:

> Hi Folks,
>
> I need some help to create an ocl query that returns all classes that
> implements a certain interface.
>
> This is what I`m tring to do:
>
> Class.allInstances()->select(c1 | c1.oclIsTypeOf('package::MyInterface' ))
>
> The problem, is that I get a compilation error from the editor. It says:
> "Cannot find operation (oclIsTypeOf(String)) for the type (Class)"
>
>

--=-LZwn2JkfzGfxijeyGkX+
Content-Type: text/html; charset="utf-8"

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi,<BR>
<BR>
The oclIsTypeOf() operation expects a type object (the actual classifier), not a name.&nbsp; So, for example,<BR>
<BR>
&nbsp;&nbsp; c1.oclIsTypeOf(_package::MyClass)<BR>
<BR>
Two notes:<BR>
<BR>
&nbsp; - 'package' is a reserved word in OCL; it must be prefixed by an underscore<BR>
&nbsp; - you probably want oclIsKindOf to test for type conformance, not just<BR>
&nbsp;&nbsp;&nbsp; the exact type<BR>
<BR>
What's more is that in UML, the implementation of interfaces is not a type conformance relationship as the generalization of classes (or other kinds of classifier) is.&nbsp; Thus, an object that is an instance of some class is *not* an instance of any interfaces implemented by that class.&nbsp; A consequence of this is that the classes implementing an interface must always re-specify the features of the interface, as they do not inherit those features from the interface.&nbsp; According to the spec, this re-specification can even have a different structure according to the domain, the example given being the implementation of an interface property by Java-bean-style accessor operations.<BR>
<BR>
In general, the OCL type system is oblivious to interfaces.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
On Wed, 2009-03-25 at 01:34 +0000, Victor Hugo wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hi Folks,

I need some help to create an ocl query that returns all classes that
implements a certain interface.

The occurrence of the term "interface" suggests that the context is a
UML model. If that is the case, then you will have to make sure that
the model in which the "package" package is defined is loaded in the
same resource set as was used in initializing your OCL environment.

Also, if "package" is not a root namespace and is not a member of any
namespace in the owner chain of the contextual classifier of the
constraint, then it will have to be fully qualified in order for the
parser to find it.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.24.1.1">
</HEAD>
<BODY>
Hi,<BR>
<BR>
The occurrence of the term &quot;interface&quot; suggests that the context is a UML model.&nbsp; If that is the case, then you will have to make sure that the model in which the &quot;package&quot; package is defined is loaded in the same resource set as was used in initializing your OCL environment.<BR>
<BR>
Also, if &quot;package&quot; is not a root namespace and is not a member of any namespace in the owner chain of the contextual classifier of the constraint, then it will have to be fully qualified in order for the parser to find it.<BR>
<BR>
HTH,<BR>
<BR>
Christian<BR>
<BR>
On Thu, 2009-03-26 at 02:11 +0000, Victor Hugo wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
Hi Christian!

THanks for answer but my problem cannot be resolved.
I tried to do as you said without success.
I try this: