Home » Modeling » OCL » Ocl Query to retrieve all classes implementing a certain interface
|
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 |
Eclipse User |
|
|
|
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. So, for example,<BR>
<BR>
c1.oclIsTypeOf(_package::MyClass)<BR>
<BR>
Two notes:<BR>
<BR>
- 'package' is a reserved word in OCL; it must be prefixed by an underscore<BR>
- you probably want oclIsKindOf to test for type conformance, not just<BR>
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. 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.<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()->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)"
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-LZwn2JkfzGfxijeyGkX+--
|
|
| |
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 |
|
--=-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 "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.<BR>
<BR>
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.<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()->select( a | a.oclIsKindOf( _package::MyInterface ) )
with this code i obtain this erro message from editor: "Unknown type
([_package, MyInterface])"
THanks
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>
--=-rbYxFka3w3U3SawX9zXZ--
|
|
|
Goto Forum:
Current Time: Tue Sep 24 14:58:46 GMT 2024
Powered by FUDForum. Page generated in 0.04690 seconds
|