cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Goers <Ralph.Go...@dslextreme.com>
Subject Re: interface implementation
Date Fri, 12 Aug 2005 07:21:32 GMT
You can do

if (a instanceof B) {
  b = (B)a;
}

which will guarantee you won't get a class cast exception. However, you 
need to do something if a is not an instance of B.

Gunter D'Hondt wrote:

>I'm currently trying to use polymorphism but I'm always getting a 
>ClassCastException:
>
>--------------------------
>public class A {}
>public class B extends A {}
>public class C {
>        public void foo(A a) {
>                B b = new B();
>                b = (B) a;
>        }
>}
>--------------------------
>How am I doing wrong here?
>
>Regards,
>Gunter
>
>
>
>
>
>
>
>
>Ralph Goers <Ralph.Goers@dslextreme.com> 
>12/08/2005 08:31
>Please respond to
>users@cocoon.apache.org
>
>
>To
>users@cocoon.apache.org
>cc
>
>Subject
>Re: interface implementation
>
>
>
>
>
>
>It sounds like maybe you want the Factory in cocoon.xconf. Get your 
>objects from it and then store them in the session.
>
>Gunter D'Hondt wrote:
>
>  
>
>>How can I define an implementation of an interface inside the 
>>    
>>
>cocoon.xconf 
>  
>
>>without using the Avalon component-tag coz the class should not be shared 
>>    
>>
>
>  
>
>>over all users since it should be possible to place it inside the session 
>>    
>>
>
>  
>
>>object?
>>
>>Regards,
>>Gunter D'Hondt
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>>For additional commands, e-mail: users-help@cocoon.apache.org
>>
>>
>>
>>    
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
>For additional commands, e-mail: users-help@cocoon.apache.org
>
>  
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message