Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Ocl Query to retrieve all classes implementing a certain interface
Ocl Query to retrieve all classes implementing a certain interface [message #69181] Wed, 25 March 2009 01:34 Go to next message
Victor Hugo is currently offline Victor HugoFriend
Messages: 20
Registered: July 2009
Junior Member
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)"
Re: Ocl Query to retrieve all classes implementing a certain interface [message #69222 is a reply to message #69181] Wed, 25 March 2009 21:27 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: give.a.damus.gmail.com

--=-LZwn2JkfzGfxijeyGkX+
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi,

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.

This is what I`m tring to do:

Class.allInstances()-&gt;select(c1 | c1.oclIsTypeOf('package::MyInterface' ))

The problem, is that I get a compilation error from the editor. It says:
&quot;Cannot find operation (oclIsTypeOf(String)) for the type (Class)&quot;


</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-LZwn2JkfzGfxijeyGkX+--
Re: Ocl Query to retrieve all classes implementing a certain interface [message #69262 is a reply to message #69222] Thu, 26 March 2009 02:11 Go to previous messageGo to next message
Victor Hugo is currently offline Victor HugoFriend
Messages: 20
Registered: July 2009
Junior Member
Hi Christian!

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

Class.allInstances()->select( a | a.oclIsKindOf( _package::MyInterface ) )

with this code i obtain this erro message from editor: "Unknown type
([_package, MyInterface])"

THanks
Re: Ocl Query to retrieve all classes implementing a certain interface [message #69283 is a reply to message #69262] Thu, 26 March 2009 12:07 Go to previous message
Christian Damus is currently offline Christian DamusFriend
Messages: 1270
Registered: July 2009
Location: Canada
Senior Member

--=-rbYxFka3w3U3SawX9zXZ
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi,

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.

HTH,

Christian

On Thu, 2009-03-26 at 02:11 +0000, Victor Hugo wrote:

> Hi Christian!
>
> THanks for answer but my problem cannot be resolved.
> I tried to do as you said without success.
> I try this:
>
> Class.allInstances()->select( a | a.oclIsKindOf( _package::MyInterface ) )
>
> with this code i obtain this erro message from editor: "Unknown type
> ([_package, MyInterface])"
>
> THanks
>
>
>

--=-rbYxFka3w3U3SawX9zXZ
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 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:

Class.allInstances()-&gt;select( a | a.oclIsKindOf( _package::MyInterface ) )

with this code i obtain this erro message from editor: &quot;Unknown type
([_package, MyInterface])&quot;

THanks



</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-rbYxFka3w3U3SawX9zXZ--
Previous Topic:OCLHelper questions
Next Topic:OCL Parser Problem
Goto Forum:
  


Current Time: Fri Apr 19 19:51:23 GMT 2024

Powered by FUDForum. Page generated in 0.03202 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top