users@jaxb.java.net

Re: How can JAXB generate getter method for boolean?

From: Aleksei Valikov <valikov_at_gmx.net>
Date: Thu, 10 Apr 2008 08:29:12 +0200

Hi Verran,

> It doesn't seem that anybody can answer my question below and I'd like to
> know if there are other more active forums and mailing lists that would be
> able to give me an answer to my question below. Can you please advise?

The ML is live, but we don't always have time to answer, sorry. :)

> Is there a way for JAXB 2.1.6 to generate classes whereby the boolean data
> types are generated as getter methods instead of "is"er methods? I am
> finding that Axis 2 is not liking the fact that it cannot find a "get"
> method for boolean values.
>
> Please let me know? My boolean data type is mandatory in the XSD.

As far as I can see from the source, code, you can't influence the
name of the boolean getter:

    protected String getGetterMethod() {
        return (getFieldType().boxify().getPrimitiveType()==codeModel.BOOLEAN?"is":"get")+prop.getName(true);
    }


You can surely do this in a plugin. Either switch the
FieldRendererFactory (won't recommend that) or simply append an
additional getXXX method returning the same thing as the isXXX method.

At the same time I think that isXXX method name for booleans is pretty
common convention/idiom so you could probably also try it from the
other end, namely, extending/patching Axis to consider isXXX methods
for booleans.

Bye.
/lexi