dev@jaxb.java.net

Getters for Attributes With/Without Defaults

From: Andrea Smyth <andrea.smyth_at_iona.com>
Date: Mon, 28 Aug 2006 18:30:49 +0100

Hello,

I noticed that getters for attributes have different signature depending
on whether the attribute is defined with or without a default in the schema:

<xs:complexType name="foo">
        <xs:attribute name="longAttrWithDefault" type="xs:long"
default="12345"/>
        <xs:attribute name="longAttrWithoutDefault" type="xs:long"/>
  </xs:complexType>

generates:
...
protected Long longAttrWithDefault;
protected Long longAttrWithoutDefault;

public Long getLongAttrWithoutDefault() {
    return longAttrWithoutDefault;
}
public long getLongAttrWithDefault() {
    if (longAttrWithDefault == null) {
        return 12345L;
    } else {
    return longAttrWithDefault;
    }
}

Is this really intentional - I can't find anywhere in the spec where it
says so, but comments in the code
(com.sun.tools.xjc.generator.bean.field.SingleField.java) seem to
suggest so?
Or is it a bug?
BTW I'm using jaxb-ri-20060801.

I'd appreciate if someone could confirm one way or the other.

Regards,
Andrea.

---------------
Andrea Smyth
Principal Engineer
IONA Technologies
Shelbourne Road,
Dublin 4, Ireland

andrea.smyth_at_iona.com
--------------------------------------
Making Software Work Together TM