users@jaxb.java.net

Method renaming

From: Burnett, Adam <Adam.Burnett_at_idearc.com>
Date: Tue, 6 Mar 2007 15:43:54 -0500

> 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'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.
>
>
> Adam Burnett
> Idearc Media Corp.
> Internet Operations - Wireless Group
> 781-684-6776
>
> Visit http://www.superpages.com
>