users@jaxb.java.net

Re: CodeModel

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Fri, 17 Nov 2006 08:31:10 -0800

HeruMartinus.Salim_at_infineon.com wrote:
> The problem has been solved.
> I inherit all the classes/interfaces inside the
> com.sun.tools.xjc.generator.bean.field package.
>
> Now I have problem by using JCodeModel.
> Can someone help my to use it?
>
> JClass iteratorType =
> codeModel.ref(Iterator.class).narrow(exposedType.boxify());
>
> $get = writer.declareMethod(iteratorType,"get"+prop.getName(true));
> JBlock block = $get.body();
> fixNullRef(block); // avoid using an internal getter
> block._return(acc.ref(true));

Change that to

block._return(acc.ref(true).invoke("iterator"));

>
>
> The code above resulting the code of
>
> public Iterator<Signals> getSignals() {
> if (signals == null) {
> signals = new ArrayList<Signals>();
> }
> return this.signals;
> }
>
> But I want to change the return statement into
>
> return this.signals.iterator();
>
> I've tried many possibilities, but still cannot solve this thing.
>
> Thanks.
> Regards,
> Heru
>
>
>
>> -----Original Message-----
>> From: Salim Heru Martinus (IFAG COM BTS MT SD)
>> Sent: Thursday, November 16, 2006 2:00 PM
>> To: users_at_jaxb.dev.java.net
>> Subject: RE: Re: XJC error message -> extends SingleField
>>
>> Can we bypass calling the constructor of SingleField inside
>> the MySingleField (it's subclass).
>> Because when the constructor of SingleField was called, all
>> the code was already there eventhough I don generate any code
>> from MySingleField.
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com