users@jaxb.java.net

Re: Re: JAXB, XJC and the Java Beans spec. - boolean getter methods

From: <torsten.reinhard_at_gi-de.com>
Date: Wed, 5 Nov 2008 14:42:17 +0100

Hi,

I tried

<jxb:globalBindings>
        <jxb:javaType name= "boolean" xmlType="xs:boolean"
parseMethod="javax.xml.bind.DatatypeConverter.parseBoolean"
printMethod="javax.xml.bind.DatatypeConverter.printBoolean"/>
</jxb:globalBindings>

but what I get is now :

    @XmlElement(name = "OPB_NamePos", type = String.class)
    @XmlJavaTypeAdapter(Adapter1 .class)
    @XmlSchemaType(name = "boolean")
    protected Boolean opbNamePos;

    public Boolean isOPBNamePos() {
        return opbNamePos;
    }

    public void setOPBNamePos(Boolean value) {
        this.opbNamePos = value;
    }

That´s not what I was looking for - I need the primitive boolean type in
my set....() and is......() method.

what am I doing wrong?

thanx again,

torsten






"Felipe Gaúcho" <fgaucho_at_gmail.com>
05.11.2008 12:27
Bitte antworten an
users_at_jaxb.dev.java.net


An
users_at_jaxb.dev.java.net
Kopie

Thema
Re: JAXB, XJC and the Java Beans spec. - boolean getter methods






you can use customization to define what type will be used....

http://java.sun.com/webservices/docs/2.0/tutorial/doc/JAXBUsing4.html

you can even customize your compiler to generate String types for
xsd:boolean :)) if it makes sense...

On Wed, Nov 5, 2008 at 11:33 AM, <torsten.reinhard_at_gi-de.com> wrote:
>
> Hi,
>
> I have problems in using XJC to generate JAXB classes to match the Java
> Beans specification.
>
> The generated methods for <boolean> types are
> void set.....(Boolean value )
> Boolean is....()
>
> instead of
>
> void set....(boolean value)
> boolean is....()
>
> That causes problems in using JXPath (apache) for example, and other
> libraries, too.
>
> I´ve read a lot about this problem, for example:
>
>
http://weblogs.java.net/blog/kohsuke/archive/2007/07/hudson_1122_and.html
>
http://www.nabble.com/How-can-JAXB-generate-getter-method-for-boolean--td16563661.html

>
http://www.mojavelinux.com/blog/archives/2006/09/the_great_jaxb_api_blunder/

> https://jaxb.dev.java.net/issues/show_bug.cgi?id=131
> http://forums.java.net/jive/thread.jspa?messageID=301300&tstart=0
>
> I´ve read something about a "booleangetter" plugin - is this already
> available anywhere?
> Isn´t there maybe another (simple) solution?
>
> What would you suggest to come around this "boolean getter method
problem" ?
>
>
> Thanx, Torsten