Search in sources :

Example 1 with XmlAttributeWriter

use of com.sun.tools.xjc.generator.annotation.spec.XmlAttributeWriter in project jaxb-ri by eclipse-ee4j.

the class AbstractField method annotateAttribute.

/**
 * Annotate the attribute property 'field'
 */
private void annotateAttribute(JAnnotatable field) {
    CAttributePropertyInfo ap = (CAttributePropertyInfo) prop;
    QName attName = ap.getXmlName();
    // [RESULT]
    // @XmlAttribute(name="foo", required=true, namespace="bar://baz")
    XmlAttributeWriter xaw = field.annotate2(XmlAttributeWriter.class);
    final String generatedName = attName.getLocalPart();
    final String generatedNS = attName.getNamespaceURI();
    // generate name property?
    if (!generatedName.equals(ap.getName(false)) || !generatedName.equals(ap.getName(true)) || (outline.parent().getModel().getNameConverter() != NameConverter.standard)) {
        xaw.name(generatedName);
    }
    // generate namespace property?
    if (!generatedNS.equals("")) {
        // assume attributeFormDefault == unqualified
        xaw.namespace(generatedNS);
    }
    // generate required property?
    if (ap.isRequired()) {
        xaw.required(true);
    }
}
Also used : QName(javax.xml.namespace.QName) XmlAttributeWriter(com.sun.tools.xjc.generator.annotation.spec.XmlAttributeWriter) CAttributePropertyInfo(com.sun.tools.xjc.model.CAttributePropertyInfo)

Aggregations

XmlAttributeWriter (com.sun.tools.xjc.generator.annotation.spec.XmlAttributeWriter)1 CAttributePropertyInfo (com.sun.tools.xjc.model.CAttributePropertyInfo)1 QName (javax.xml.namespace.QName)1