Java Code Examples for com.sun.codemodel.internal.JAnnotatable#annotate2()

The following examples show how to use com.sun.codemodel.internal.JAnnotatable#annotate2() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractField.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();

    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // 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);
    }
}
 
Example 2
Source File: AbstractField.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();

    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // 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);
    }
}
 
Example 3
Source File: AbstractField.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private XmlElementWriter getXew(boolean checkWrapper, JAnnotatable field) {
    XmlElementWriter xew;
    if(checkWrapper) {
        if(xesw==null) {
            xesw = field.annotate2(XmlElementsWriter.class);
        }
        xew = xesw.value();
    } else {
        xew = field.annotate2(XmlElementWriter.class);
    }
    return xew;
}
 
Example 4
Source File: BeanGenerator.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example 5
Source File: AbstractField.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();

    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // 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);
    }
}
 
Example 6
Source File: AbstractField.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private XmlElementWriter getXew(boolean checkWrapper, JAnnotatable field) {
    XmlElementWriter xew;
    if(checkWrapper) {
        if(xesw==null) {
            xesw = field.annotate2(XmlElementsWriter.class);
        }
        xew = xesw.value();
    } else {
        xew = field.annotate2(XmlElementWriter.class);
    }
    return xew;
}
 
Example 7
Source File: BeanGenerator.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example 8
Source File: AbstractField.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();

    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // 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);
    }
}
 
Example 9
Source File: AbstractField.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private XmlElementWriter getXew(boolean checkWrapper, JAnnotatable field) {
    XmlElementWriter xew;
    if(checkWrapper) {
        if(xesw==null) {
            xesw = field.annotate2(XmlElementsWriter.class);
        }
        xew = xesw.value();
    } else {
        xew = field.annotate2(XmlElementWriter.class);
    }
    return xew;
}
 
Example 10
Source File: BeanGenerator.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example 11
Source File: BeanGenerator.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example 12
Source File: AbstractField.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private XmlElementWriter getXew(boolean checkWrapper, JAnnotatable field) {
    XmlElementWriter xew;
    if(checkWrapper) {
        if(xesw==null) {
            xesw = field.annotate2(XmlElementsWriter.class);
        }
        xew = xesw.value();
    } else {
        xew = field.annotate2(XmlElementWriter.class);
    }
    return xew;
}
 
Example 13
Source File: BeanGenerator.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example 14
Source File: AbstractField.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();

    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // 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);
    }
}
 
Example 15
Source File: AbstractField.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private XmlElementWriter getXew(boolean checkWrapper, JAnnotatable field) {
    XmlElementWriter xew;
    if(checkWrapper) {
        if(xesw==null) {
            xesw = field.annotate2(XmlElementsWriter.class);
        }
        xew = xesw.value();
    } else {
        xew = field.annotate2(XmlElementWriter.class);
    }
    return xew;
}
 
Example 16
Source File: BeanGenerator.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Generates {@link XmlJavaTypeAdapter} from {@link PropertyInfo} if necessary.
 * Also generates other per-property annotations
 * (such as {@link XmlID}, {@link XmlIDREF}, and {@link XmlMimeType} if necessary.
 */
public final void generateAdapterIfNecessary(CPropertyInfo prop, JAnnotatable field) {
    CAdapter adapter = prop.getAdapter();
    if (adapter != null) {
        if (adapter.getAdapterIfKnown() == SwaRefAdapterMarker.class) {
            field.annotate(XmlAttachmentRef.class);
        } else {
            // [RESULT]
            // @XmlJavaTypeAdapter( Foo.class )
            XmlJavaTypeAdapterWriter xjtw = field.annotate2(XmlJavaTypeAdapterWriter.class);
            xjtw.value(adapter.adapterType.toType(this, EXPOSED));
        }
    }

    switch (prop.id()) {
        case ID:
            field.annotate(XmlID.class);
            break;
        case IDREF:
            field.annotate(XmlIDREF.class);
            break;
    }

    if (prop.getExpectedMimeType() != null) {
        field.annotate2(XmlMimeTypeWriter.class).value(prop.getExpectedMimeType().toString());
    }
}
 
Example 17
Source File: AbstractField.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();

    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // 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);
    }
}
 
Example 18
Source File: AbstractField.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private XmlElementWriter getXew(boolean checkWrapper, JAnnotatable field) {
    XmlElementWriter xew;
    if(checkWrapper) {
        if(xesw==null) {
            xesw = field.annotate2(XmlElementsWriter.class);
        }
        xew = xesw.value();
    } else {
        xew = field.annotate2(XmlElementWriter.class);
    }
    return xew;
}
 
Example 19
Source File: AbstractField.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private XmlElementWriter getXew(boolean checkWrapper, JAnnotatable field) {
    XmlElementWriter xew;
    if(checkWrapper) {
        if(xesw==null) {
            xesw = field.annotate2(XmlElementsWriter.class);
        }
        xew = xesw.value();
    } else {
        xew = field.annotate2(XmlElementWriter.class);
    }
    return xew;
}
 
Example 20
Source File: AbstractField.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();

    // Issue 570; always force generating name="" when do it when globalBindings underscoreBinding is set to non default value
    // 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);
    }
}