[e-lang] Extending Java classes
Kevin Reid
kpreid at mac.com
Wed Jul 22 22:33:28 EDT 2009
On Jul 22, 2009, at 20:03, Robert Krahn wrote:
> Hi,
>
> I found old posts on this mailing discussing the inheritance of Java
> classes. Is this possible now?
>
> What I would like to do is something like (excuse my naivete): def
> list extends
> <unsafe:org.erights.e.elib.tables.ConstListImpl>.asType() {}
It is not currently possible to create a new Java class from E. You
can, however, implement any Java interface.
What I recommend for taming purposes is writing, in Java, a subclass
which overrides all the methods you want to instead call another
object, a handler. The handler is then implemented in E.
interface EFooHandler {
public void bar();
}
class EFoo extends Foo {
private EFooHandler handler;
public EFoo(EFooHandler h) {
handler = h;
}
/* overrides bar() in Foo */
public void bar() {
handler.bar();
}
}
--
Kevin Reid <http://switchb.org/kpreid/>
More information about the e-lang
mailing list