users@jaxb.java.net

RE: Re: CodeModel

From: <HeruMartinus.Salim_at_infineon.com>
Date: Fri, 17 Nov 2006 18:07:51 +0100

Hi,

Yup, I'm working on some plugin, but unfortunately the plugin is about
specific to the project. So I don't know weather it's gonna useful for
the other.

What I made so far is to "customize" the behavior of code-generating of
XJC. For example when it meets a single attribute, few expected
functions/methods are gonna generated. And when it's multiple (list),
another thing will be generated. And also for example, I disable the
getter function for single type of a class, and such like that.
What come in my mind could be useful for the other is the ability of
customization to disable the setter and getter function, or to replace
the code (such as code-injector, but a bit more dramatic changes).

When there are some advise on creating (extend to ) more generic plugin,
I would like to do that. Just I don't have enough experience to know the
needs of other programmers. Please some advice.

Regards,
Heru

> -----Original Message-----
> From: Kohsuke Kawaguchi [mailto:Kohsuke.Kawaguchi_at_Sun.COM]
> Sent: Friday, November 17, 2006 5:41 PM
> To: users_at_jaxb.dev.java.net
> Subject: Re: CodeModel
>
>
> You've obviously been working on some plugins. Could you
> refresh our memory about what you are working on?
>
> Would you be interested in hosting those on
> http://jaxb2-commons.dev.java.net/ ?
>
> 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));
> >
> >
> > 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.
>
>
> --
> Kohsuke Kawaguchi
> Sun Microsystems kohsuke.kawaguchi_at_sun.com
>