Search in sources :

Example 1 with XmlElementRef

use of org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef in project eclipselink by eclipse-ee4j.

the class XMLProcessor method processXmlElementRefs.

/**
 * Process an xml-element-refs.
 */
private Property processXmlElementRefs(XmlElementRefs xmlElementRefs, Property oldProperty, TypeInfo info) {
    processObjectFactory(info);
    resetProperty(oldProperty, info);
    List<XmlElementRef> eltRefs = new ArrayList<XmlElementRef>();
    boolean required = true;
    for (XmlElementRef eltRef : xmlElementRefs.getXmlElementRef()) {
        eltRefs.add(eltRef);
        required = required && eltRef.isRequired();
    }
    oldProperty.setXmlElementRefs(eltRefs);
    oldProperty.setIsReference(true);
    oldProperty.setIsRequired(required);
    // handle XmlAdapter
    if (xmlElementRefs.getXmlJavaTypeAdapter() != null) {
        oldProperty.setXmlJavaTypeAdapter(xmlElementRefs.getXmlJavaTypeAdapter());
    }
    // handle XmlElementWrapper
    if (xmlElementRefs.getXmlElementWrapper() != null) {
        oldProperty.setXmlElementWrapper(xmlElementRefs.getXmlElementWrapper());
    }
    // set user-defined properties
    if (xmlElementRefs.getXmlProperties() != null && xmlElementRefs.getXmlProperties().getXmlProperty().size() > 0) {
        oldProperty.setUserProperties(createUserPropertyMap(xmlElementRefs.getXmlProperties().getXmlProperty()));
    }
    if (xmlElementRefs.isSetXmlMixed()) {
        oldProperty.setMixedContent(xmlElementRefs.isXmlMixed());
    }
    // handle get/set methods
    if (xmlElementRefs.getXmlAccessMethods() != null) {
        oldProperty.setMethodProperty(true);
        oldProperty.setGetMethodName(xmlElementRefs.getXmlAccessMethods().getGetMethod());
        oldProperty.setSetMethodName(xmlElementRefs.getXmlAccessMethods().getSetMethod());
    }
    // handle read-only
    if (xmlElementRefs.isSetReadOnly()) {
        oldProperty.setReadOnly(xmlElementRefs.isReadOnly());
    }
    // handle write-only
    if (xmlElementRefs.isSetWriteOnly()) {
        oldProperty.setWriteOnly(xmlElementRefs.isWriteOnly());
    }
    return oldProperty;
}
Also used : XmlElementRef(org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef) ArrayList(java.util.ArrayList)

Example 2 with XmlElementRef

use of org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef in project eclipselink by eclipse-ee4j.

the class XMLProcessor method processXmlAnyElement.

/**
 * Handle xml-any-element. If the property was annotated with @XmlAnyElement
 * in code all values will be overridden.
 */
private Property processXmlAnyElement(XmlAnyElement xmlAnyElement, Property oldProperty, TypeInfo tInfo, JavaType javaType) {
    processObjectFactory(tInfo);
    // reset any existing values
    resetProperty(oldProperty, tInfo);
    // set xml-any-element specific properties
    oldProperty.setIsAny(true);
    oldProperty.setDomHandlerClassName(xmlAnyElement.getDomHandler());
    oldProperty.setLax(xmlAnyElement.isLax());
    oldProperty.setMixedContent(xmlAnyElement.isXmlMixed());
    oldProperty.setXmlJavaTypeAdapter(xmlAnyElement.getXmlJavaTypeAdapter());
    // update TypeInfo
    tInfo.setMixed(xmlAnyElement.isXmlMixed());
    tInfo.setAnyElementPropertyName(oldProperty.getPropertyName());
    // handle XmlPath
    if (xmlAnyElement.getXmlPath() != null) {
        oldProperty.setXmlPath(xmlAnyElement.getXmlPath());
    }
    // handle get/set methods
    if (xmlAnyElement.getXmlAccessMethods() != null) {
        oldProperty.setMethodProperty(true);
        oldProperty.setGetMethodName(xmlAnyElement.getXmlAccessMethods().getGetMethod());
        oldProperty.setSetMethodName(xmlAnyElement.getXmlAccessMethods().getSetMethod());
    }
    // handle read-only
    if (xmlAnyElement.isSetReadOnly()) {
        oldProperty.setReadOnly(xmlAnyElement.isReadOnly());
    }
    // handle write-only
    if (xmlAnyElement.isSetWriteOnly()) {
        oldProperty.setWriteOnly(xmlAnyElement.isWriteOnly());
    }
    // set user-defined properties
    if (xmlAnyElement.getXmlProperties() != null && xmlAnyElement.getXmlProperties().getXmlProperty().size() > 0) {
        oldProperty.setUserProperties(createUserPropertyMap(xmlAnyElement.getXmlProperties().getXmlProperty()));
    }
    // check for container type
    if (!xmlAnyElement.getContainerType().equals(DEFAULT)) {
        setContainerType(oldProperty, xmlAnyElement.getContainerType());
    }
    // check for xml-element-refs
    if (xmlAnyElement.getXmlElementRefs() != null) {
        oldProperty.setXmlElementRefs(xmlAnyElement.getXmlElementRefs().getXmlElementRef());
        oldProperty.setIsReference(true);
        boolean required = true;
        for (XmlElementRef eltRef : xmlAnyElement.getXmlElementRefs().getXmlElementRef()) {
            required = required && eltRef.isRequired();
        }
        oldProperty.setIsRequired(required);
        if (xmlAnyElement.getXmlElementRefs().isSetXmlMixed()) {
            oldProperty.setMixedContent(xmlAnyElement.getXmlElementRefs().isXmlMixed());
        }
    }
    return oldProperty;
}
Also used : XmlElementRef(org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef)

Example 3 with XmlElementRef

use of org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef in project eclipselink by eclipse-ee4j.

the class OXMJavaClassImpl method getDeclaredFields.

/**
 * Return all of the declared <code>JavaFields</code> for this <code>JavaClass</code>.
 *
 * @return A <code>Collection</code> containing this <code>JavaClass'</code> <code>JavaFields</code>.
 */
@Override
public Collection<JavaField> getDeclaredFields() {
    List<JavaField> fieldsToReturn = new ArrayList<JavaField>();
    if (this.enumValues != null) {
        for (Iterator<String> iterator = this.enumValues.iterator(); iterator.hasNext(); ) {
            fieldsToReturn.add(new OXMJavaFieldImpl(iterator.next(), JAVA_LANG_OBJECT, this));
        }
    } else {
        JavaAttributes javaAttributes = this.javaType.getJavaAttributes();
        if (null != javaAttributes) {
            List<JAXBElement<? extends JavaAttribute>> fields = javaAttributes.getJavaAttribute();
            for (Iterator<JAXBElement<? extends JavaAttribute>> iterator = fields.iterator(); iterator.hasNext(); ) {
                JAXBElement<? extends JavaAttribute> jaxbElement = iterator.next();
                JavaAttribute att = jaxbElement.getValue();
                if (att instanceof XmlElement) {
                    XmlElement xme = (XmlElement) att;
                    String fieldName = xme.getJavaAttribute();
                    String fieldType = xme.getType();
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                } else if (att instanceof XmlElements) {
                    XmlElements xmes = (XmlElements) att;
                    String fieldName = xmes.getJavaAttribute();
                    String fieldType = JAVA_LANG_OBJECT;
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                } else if (att instanceof XmlElementRef) {
                    XmlElementRef xmer = (XmlElementRef) att;
                    String fieldName = xmer.getJavaAttribute();
                    String fieldType = xmer.getType();
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                } else if (att instanceof XmlAttribute) {
                    XmlAttribute xma = (XmlAttribute) att;
                    String fieldName = xma.getJavaAttribute();
                    String fieldType = xma.getType();
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                } else if (att instanceof XmlValue) {
                    XmlValue xmv = (XmlValue) att;
                    String fieldName = xmv.getJavaAttribute();
                    String fieldType = xmv.getType();
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                } else if (att instanceof XmlAnyElement) {
                    XmlAnyElement xmae = (XmlAnyElement) att;
                    String fieldName = xmae.getJavaAttribute();
                    String fieldType = JAVA_LANG_OBJECT;
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                } else if (att instanceof XmlAnyAttribute) {
                    XmlAnyAttribute xmaa = (XmlAnyAttribute) att;
                    String fieldName = xmaa.getJavaAttribute();
                    String fieldType = JAVA_UTIL_MAP;
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                } else if (att instanceof XmlJoinNodes) {
                    XmlJoinNodes xmjn = (XmlJoinNodes) att;
                    String fieldName = xmjn.getJavaAttribute();
                    String fieldType = xmjn.getType();
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                } else if (att instanceof XmlInverseReference) {
                    XmlInverseReference xmir = (XmlInverseReference) att;
                    String fieldName = xmir.getJavaAttribute();
                    String fieldType = xmir.getType();
                    fieldsToReturn.add(new OXMJavaFieldImpl(fieldName, fieldType, this));
                }
            }
        }
    }
    return fieldsToReturn;
}
Also used : XmlElementRef(org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef) XmlAttribute(org.eclipse.persistence.jaxb.xmlmodel.XmlAttribute) XmlAnyElement(org.eclipse.persistence.jaxb.xmlmodel.XmlAnyElement) ArrayList(java.util.ArrayList) XmlJoinNodes(org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes) JAXBElement(jakarta.xml.bind.JAXBElement) XmlInverseReference(org.eclipse.persistence.jaxb.xmlmodel.XmlInverseReference) JavaAttributes(org.eclipse.persistence.jaxb.xmlmodel.JavaType.JavaAttributes) XmlElements(org.eclipse.persistence.jaxb.xmlmodel.XmlElements) JavaField(org.eclipse.persistence.jaxb.javamodel.JavaField) XmlAnyAttribute(org.eclipse.persistence.jaxb.xmlmodel.XmlAnyAttribute) XmlElement(org.eclipse.persistence.jaxb.xmlmodel.XmlElement) XmlValue(org.eclipse.persistence.jaxb.xmlmodel.XmlValue) JavaAttribute(org.eclipse.persistence.jaxb.xmlmodel.JavaAttribute)

Aggregations

XmlElementRef (org.eclipse.persistence.jaxb.xmlmodel.XmlElementRef)3 ArrayList (java.util.ArrayList)2 JAXBElement (jakarta.xml.bind.JAXBElement)1 JavaField (org.eclipse.persistence.jaxb.javamodel.JavaField)1 JavaAttribute (org.eclipse.persistence.jaxb.xmlmodel.JavaAttribute)1 JavaAttributes (org.eclipse.persistence.jaxb.xmlmodel.JavaType.JavaAttributes)1 XmlAnyAttribute (org.eclipse.persistence.jaxb.xmlmodel.XmlAnyAttribute)1 XmlAnyElement (org.eclipse.persistence.jaxb.xmlmodel.XmlAnyElement)1 XmlAttribute (org.eclipse.persistence.jaxb.xmlmodel.XmlAttribute)1 XmlElement (org.eclipse.persistence.jaxb.xmlmodel.XmlElement)1 XmlElements (org.eclipse.persistence.jaxb.xmlmodel.XmlElements)1 XmlInverseReference (org.eclipse.persistence.jaxb.xmlmodel.XmlInverseReference)1 XmlJoinNodes (org.eclipse.persistence.jaxb.xmlmodel.XmlJoinNodes)1 XmlValue (org.eclipse.persistence.jaxb.xmlmodel.XmlValue)1