That's it exactly. Thanks.
-----Original Message-----
From: tcl...@li...
[mailto:tcl...@li...] On Behalf Of Tom
Poindexter
Sent: Tuesday, March 11, 2008 9:25 PM
To: A list for users of tcljava
Subject: Re: [tcljava-user] Real "inner class" construction
On Tue, Mar 11, 2008 at 11:15:52AM -0500, Jared Hodge wrote:
> In Jacl 1.4.0 Is there any way to instantiate a true "inner class" in
> jacl as is described in:
>
> http://java.sun.com/docs/books/tutorial/java/javaOO/summarynested.html
>
>
>
> I see how to instantiate a static nested class:
>
> set myNewStaticNestedObject [java::call OuterClass.NestedClass
> $constructorArg1]
>
>
>
> but I don't see the jacl equivalent to
>
> OuterClass.InnerClass innerObject = outerObject.new InnerClass();
>
>
>
> I guess I could make my inner class static nested and pass in the
outer
> class as an argument, but that gets messy in the java.
This should be possible, the trick is that a constructor to the inner
class
has an implicit argument of the outer class. I coded up a simple
exmaple, see
if you can apply it to your classes:
// ////////////////////////////////////////////////////////////////
// foo/Bar.java
package foo;
public class Bar {
private String s;
public Bar(String s) {
this.s = s;
}
public String getS() {
return "Bar s: " + s;
}
public class InnerBar {
public InnerBar() {}
public void printIt() {
System.out.println("my Bar = " + getS());
}
}
}
// end foo/Bar.java
// ////////////////////////////////////////////////////////////////
$ javac foo/Bar.java
$ jaclsh
% package require java
1.4.1
% set B [java::new foo.Bar bing]
java0x1
% $B getS
Bar s: bing
% java::info constructors foo.Bar
{foo.Bar java.lang.String}
% java::info constructors foo.Bar.InnerBar
{{foo.Bar$InnerBar} foo.Bar}
% set IB [java::new foo.Bar.InnerBar $B]
java0x2
% $IB printIt
my Bar = Bar s: bing
--
Tom Poindexter
tpo...@ny...
------------------------------------------------------------------------
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
tcljava-user mailing list
tcl...@li...
https://lists.sourceforge.net/lists/listinfo/tcljava-user
|