Runtime checking is all we get.

public static function isImplementationOf(clazz:Class,
interfaze:Class):Boolean {
  var result:Boolean;
  if (clazz == null) {
    result = false;
  }
  else {
    var classDescription:XML = describeType(clazz) as XML;
    result = (classDescription.factory.implementsInterface.(@type ==
getQualifiedClassName(interfaze)).length() != 0);
  }
  return result;
}

--- In flexcoders@yahoogroups.com, "Gordon Smith" <[EMAIL PROTECTED]> wrote:
>
> As far as I know, Adobe plans to follow the emerging Ecmascript 4
> standard. We're unlikely to support covariant return types in
> ActionScript unless ES4 has them.
> 
>  
> 
> Gordon Smith
> 
> Adobe Flex SDK Team
> 
>  
> 
> ________________________________
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Rick Winscot
> Sent: Thursday, June 26, 2008 10:30 PM
> To: flexcoders@yahoogroups.com
> Subject: RE: [flexcoders] AS3 interface question
> 
>  
> 
> By the way... there is an open issue in the Adobe bug-base regarding
> this. Vote for it! NOW!
> 
>  
> 
> http://bugs.adobe.com/jira/browse/ASC-3442
> <http://bugs.adobe.com/jira/browse/ASC-3442> 
> 
>  
> 
> Rick Winscot
> 
>  
> 
>  
> 
> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
> Behalf Of Ralf Bokelberg
> Sent: Thursday, June 26, 2008 9:22 AM
> To: flexcoders@yahoogroups.com
> Subject: Re: [flexcoders] AS3 interface question
> 
>  
> 
> Yep, it's a language feature, which is not there. I think it is called
> covariant return types.
> Afaik, all you can do is check the type and cast.
> Cheers
> Ralf.
> 
> On Thu, Jun 26, 2008 at 3:14 PM, diehlryan <[EMAIL PROTECTED]
> <mailto:rdiehl%40docfinity.com> > wrote:
> > I'm running into a wall when trying to use extension with interfaces.
> > The example I'm about to provide works using Java, so I believe the
> > OOP practices behind it are valid. But I can't figure out how to
> > accomplish the same thing in Flex, I keep running into compiler
> > issues. The example is a condensed version of something I'm working
> > on, for simplicity sake.
> >
> > Let's say you have a bunch of events that all have some common
> > functionality, like the ability to have a nextEvent. Also, a subset
> > of those events also have additional functionality, they can be
> > filtered by a type of criteria. We'll call them search events.
> >
> > Now, there are some parts of the application that can work with any
> > type of search event, and any type of criteria. But when the
> > individual searches are executed, that implementation expects a
> > specific type of search event and search criteria. That's my end goal
> > here.
> >
> > Here are the interfaces I'm using:
> >
> > public interface ICriteria
> > {
> > // just a marker
> > }
> >
> > public interface ICustomCriteria extends ICriteria
> > {
> > function get name():String;
> > function set name(name:String):void;
> > }
> >
> > public interface IEvent
> > {
> > function get nextEvent():IEvent;
> > function set nextEvent(event:IEvent):void;
> > }
> >
> > public interface ISearchEvent
> > {
> > function get criteria():ICriteria;
> > function set criteria(criteria:ICriteria):void;
> > }
> >
> > So far, so good. And now the implementing classes:
> >
> > // would like to make this an abstract class, but not supported in AS
> > public class BaseEvent implements IEvent
> > {
> > private var _nextEvent:IEvent;
> >
> > public function set nextEvent(event:IEvent):void
> > {
> > this._nextEvent = event;
> > }
> >
> > public function get nextEvent():IEvent
> > {
> > return this._nextEvent;
> > }
> > }
> >
> > // would like to make this an abstract class, but not supported in AS
> > public class BaseSearchEvent extends BaseEvent implements ISearchEvent
> > {
> > private var _criteria:ICriteria;
> >
> > public function set criteria(criteria:ICriteria):void
> > {
> > this._criteria = criteria;
> > }
> >
> > public function get criteria():ICriteria
> > {
> > return this._criteria;
> > }
> > }
> >
> > Those base classes are fine and compile correctly. Now if you
> > remember from the requirements, there are some places that can work
> > with any type of ISearchEvent, and some places that can only work with
> > an individual subclass. Here is where the compiler errors come in.
> > Doing what I am about to do works in Java, and I'm wondering if there
> > is a way to accomplish it in AS3.
> >
> > public class CustomSearchEvent extends BaseSearchEvent
> > {
> > private var _criteria:ICustomCriteria;
> >
> > public override function get criteria():ICustomCriteria
> > {
> > return this._criteria;
> > }
> >
> > public override function set criteria(criteria:ICustomCriteria):void
> > {
> > this._criteria = criteria;
> > }
> > }
> >
> > The above class does not compile because the method signatures for
> > get/set criteria are different than those specified in the interface.
> > But from an OO perspective, I think this is a valid thing to want to
> > do. If you're working with an ISearchEvent instance, you should be
> > able to subclass the base class and provide custom behavior. The
> > ICustomCriteria is a subclass of ICriteria, so you should be able to
> > substitute them in this context. Is there another way to accomplish
> > this? Or is this just a language feature that's not there?
> >
> >
>


Reply via email to