users@jaxb.java.net

Re: Method renaming

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 13 Mar 2007 09:22:36 -0700

Burnett, Adam wrote:
>> Hello, I'm attempting to write my first xjc plugin and running into
>> some difficulty. I'm trying to rename methods based on their return
>> type. Specifically I want to override the prefix added on to the
>> field's accessor (getXX instead of isXX). I looked at writing a
>> NameConverter but that doesn't give me access to what the data type of
>> the field is.
>> Next I tried iterating through all of the ClassOutline's and checking
>> the fields to see if any of them were the type I'm interested in and
>> then getting the CPropertyInfo for that FieldOutline and calling
>> setName. But my name changes aren't showing up in the final generated
>> source.
>> So I then tried renaming the methods in the postProcessModel method of
>> my plugin, but the problem there is that the default method prefix is
>> still added by xjc. For example if I rename the method to
>> "getWhatever" the generated source has "isgetWhatever". Also
>> according to the docs using setName in postProcessModel is apparently
>> a dangerous thing to do.

I believe I recently added JMethod.name(String) to change the method name.

>>
>> I'm a little confused as to what part of the com.sun.tools.xjc package
>> I should be looking at to accomplish this since there are so many
>> outlines, models, info's, etc. Am I correct in that I can only
>> accomplish this using the Outline in Plugin.run? Once I set the name
>> of a method how do I get that to actually update the Outline? Or am I
>> just totally off base?
>>
>> Thanks for the help and let me know if I need to supply more
>> information.


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com