Search in sources :

Example 1 with DefaultElementConverter

use of org.eclipse.persistence.internal.jaxb.DefaultElementConverter in project eclipselink by eclipse-ee4j.

the class MappingsGenerator method generateCompositeObjectMapping.

public CompositeObjectMapping generateCompositeObjectMapping(Property property, Descriptor descriptor, NamespaceInfo namespaceInfo, String referenceClassName) {
    CompositeObjectMapping mapping = new XMLCompositeObjectMapping();
    initializeXMLMapping((XMLMapping) mapping, property);
    // if the XPath is set (via xml-path) use it; otherwise figure it out
    mapping.setField(getXPathForField(property, namespaceInfo, false, false));
    // handle null policy set via xml metadata
    if (property.isSetNullPolicy()) {
        mapping.setNullPolicy(getNullPolicyFromProperty(property, getNamespaceResolverForDescriptor(namespaceInfo)));
    } else {
        NullPolicy nullPolicy = (NullPolicy) mapping.getNullPolicy();
        nullPolicy.setSetPerformedForAbsentNode(false);
        if (property.isNillable()) {
            nullPolicy.setNullRepresentedByXsiNil(true);
            nullPolicy.setMarshalNullRepresentation(XMLNullRepresentationType.XSI_NIL);
        }
    }
    if (referenceClassName == null) {
        setTypedTextField((Field) mapping.getField());
        String defaultValue = property.getDefaultValue();
        if (null != defaultValue) {
            mapping.setConverter(new DefaultElementConverter(defaultValue));
        }
    } else {
        mapping.setReferenceClassName(referenceClassName);
    }
    if (property.isTransientType()) {
        mapping.setReferenceClassName(Constants.UNKNOWN_OR_TRANSIENT_CLASS);
    }
    if (property.isRequired()) {
        ((Field) mapping.getField()).setRequired(true);
    }
    return mapping;
}
Also used : IsSetNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy) XmlIsSetNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy) NullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.NullPolicy) XmlNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlNullPolicy) XmlAbstractNullPolicy(org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy) AbstractNullPolicy(org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy) XMLField(org.eclipse.persistence.oxm.XMLField) DatabaseField(org.eclipse.persistence.internal.helper.DatabaseField) Field(org.eclipse.persistence.internal.oxm.mappings.Field) JavaField(org.eclipse.persistence.jaxb.javamodel.JavaField) DefaultElementConverter(org.eclipse.persistence.internal.jaxb.DefaultElementConverter) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping) CompositeObjectMapping(org.eclipse.persistence.internal.oxm.mappings.CompositeObjectMapping) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Aggregations

DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)1 DefaultElementConverter (org.eclipse.persistence.internal.jaxb.DefaultElementConverter)1 CompositeObjectMapping (org.eclipse.persistence.internal.oxm.mappings.CompositeObjectMapping)1 Field (org.eclipse.persistence.internal.oxm.mappings.Field)1 JavaField (org.eclipse.persistence.jaxb.javamodel.JavaField)1 XmlAbstractNullPolicy (org.eclipse.persistence.jaxb.xmlmodel.XmlAbstractNullPolicy)1 XmlIsSetNullPolicy (org.eclipse.persistence.jaxb.xmlmodel.XmlIsSetNullPolicy)1 XmlNullPolicy (org.eclipse.persistence.jaxb.xmlmodel.XmlNullPolicy)1 XMLField (org.eclipse.persistence.oxm.XMLField)1 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)1 AbstractNullPolicy (org.eclipse.persistence.oxm.mappings.nullpolicy.AbstractNullPolicy)1 IsSetNullPolicy (org.eclipse.persistence.oxm.mappings.nullpolicy.IsSetNullPolicy)1 NullPolicy (org.eclipse.persistence.oxm.mappings.nullpolicy.NullPolicy)1