JAXB 2.2.10

see also http://docs.oracle.com/javaee/5/tutorial/doc/bnbbf.html
see also https://jaxb.java.net/tutorial/index.html
see also https://jaxb.java.net/guide/index.html - Unofficial JAXB Guide
see also How to get simple and better typed binding in https://metro.java.net/guide/ch03.html

globalBindings

fixedAttributeAsConstantProperty
fixed attributes will be generated as a java constant.

@XmlSchemaType(name = "NMTOKEN")
public final static String COUNTRY = "US";
collectionType
Specifies the base type used for collections.

@XmlElement(required = true)
protected List item = new Vector();
typesafeEnumBase
typesafeEnumBase = a list of QNames, each of which must resolve to a simple type definition
Specifies that all simple type definitions deriving directly or indirectly from e.g. xsd:string and having enumeration facets should be bound by default to a typesafe enum.

    
        
        
        
        
        
        
    

choiceContentProperty
The default value is false. choiceContentProperty is not relevant when the bindingStyle is elementBinding (see below).

    
        
        
    

Xjc with choiceContentProperty="false":
public class FileUploadRequest {
    protected String path;
    protected byte[] file;
Xjc with choiceContentProperty="true":
@XmlElements({
    @XmlElement(name = "path", type = String.class),
    @XmlElement(name = "file", type = byte[].class)
})
protected Object pathOrFile;
typesafeEnumMemberName
typesafeEnumMemberName = "generateName" | "generateError"
generateError specifies that the code generator generates an error when it cannot map an enumeration to a Java enum type.

    
        
        
         -> 1MA is an invalid java name
        
    

[ERROR] Cannot generate a constant name from the enumeration value "1MA". Use  to specify one.
generateName specifies that member names will be generated following the pattern VALUE_N. N starts off at one, and is incremented for each member of the enumeration.
    @XmlEnumValue("1MA")
    VALUE_6("1MA");
    private final String value;
enableFailFastCheck
Type constraint checking is performed when setting a property.
item.setQuantity( new BigInteger( "-5" ) );// must be a positive number here
If @enableFailFastCheck was "true" and the optional FailFast validation method was supported by an implementation, a TypeConstraintException would be thrown here. Note that the JAXB implementation does not support the FailFast feature.

generateIsSetMethod
First see FileUploadRequest schema declaration above.
Causes two additional property methods, isSetPath and isSetFile, to be generated. These methods enable a client application to distinguish between schema default values and values occurring explicitly within an instance document. Some good folks claim unsetPath and unsetFile should be generated too but it didn't happened for me (with or without a default attribute set on path element).

underscoreBinding
Consider this element:

Jxc generation result when asWordSeparator (default value):
@XmlElement(name = "sOmE_PROPerty")     -> it's an invisible underscore between sOmE and PROPerty
protected String sOmEPROPerty;
Jxc generation result when asCharInWord:
protected String sOmE_PROPerty;         -> it's an invisible underscore between sOmE and PROPerty

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.