The following discussions should be avoided. What this question is NOT:
QUESTION:
I would like an example of a jaxb binding declaration to override the default mapping of xs:integer to Java BigInteger, so that xjc would produce Java Integer instead.
e.g.
<xs:attribute name="id" type="xs:integer"/>
should produce
@XmlAttribute(name = "id")
Integer id;
and not
@XmlAttribute(name = "id")
BigInteger id;
BigInteger represents immutable arbitrary-precision integers. It is similar to the primitive integer types but allows arbitrary large values. It is used when integers involved are larger than the limit of long type. For example, the factorial of 50 is 30414093201713378043612608166064768844377641568960512000000000000.
xjb extension to resolve any conflicts in the WSDL or schema. For example if two elements have the same name and you want to distinguish between them you can rename one by specifying it the bindings file.
You could add the following to your bindings file:
<globalBindings>
<javaType xmlType="xs:integer" name="java.lang.Integer"/>
</globalBindings>
This will produce, for example:
@XmlAttribute(name = "id")
@XmlJavaTypeAdapter(Adapter1 .class)
protected Integer id;
public int getId() {
if (id == null) {
return new Adapter1().unmarshal("0");
} else {
return id;
}
}
public void setId(Integer value) {
this.id = value;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With