Search in sources :

Example 1 with XMLAnyAttributeMapping

use of org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping in project eclipselink by eclipse-ee4j.

the class MappingsGenerator method generateAnyAttributeMapping.

public AnyAttributeMapping generateAnyAttributeMapping(Property property, Descriptor descriptor, NamespaceInfo namespaceInfo) {
    XMLAnyAttributeMapping mapping = new XMLAnyAttributeMapping();
    initializeXMLMapping(mapping, property);
    initializeXMLContainerMapping(mapping, property.getType().isArray());
    // if the XPath is set (via xml-path) use it
    if (property.getXmlPath() != null) {
        mapping.setField(new XMLField(property.getXmlPath()));
    }
    mapping.setSchemaInstanceIncluded(false);
    mapping.setNamespaceDeclarationIncluded(false);
    JavaClass mapType = property.getType();
    if (areEquals(mapType, Map.class)) {
        mapType = jotHashMap;
    }
    mapping.useMapClassName(mapType.getRawName());
    return mapping;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLAnyAttributeMapping(org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping) JavaClass(org.eclipse.persistence.jaxb.javamodel.JavaClass)

Example 2 with XMLAnyAttributeMapping

use of org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping in project eclipselink by eclipse-ee4j.

the class SDOObjectType method addOpenMappings.

protected void addOpenMappings() {
    XMLAnyCollectionMapping anyMapping = new XMLAnyCollectionMapping();
    anyMapping.setAttributeName(ANY_MAPPING_ATTRIBUTE_NAME);
    anyMapping.setGetMethodName(ANY_MAPPING_GET_METHOD_NAME);
    anyMapping.setSetMethodName(ANY_MAPPING_SET_METHOD_NAME);
    anyMapping.setUseXMLRoot(true);
    getXmlDescriptor().addMapping(anyMapping);
    XMLAnyAttributeMapping anyAttrMapping = new XMLAnyAttributeMapping();
    anyAttrMapping.setAttributeName("openContentPropertiesAttributes");
    anyAttrMapping.setGetMethodName("_getOpenContentPropertiesAttributesMap");
    anyAttrMapping.setSetMethodName("_setOpenContentPropertiesAttributesMap");
    getXmlDescriptor().addMapping(anyAttrMapping);
}
Also used : XMLAnyAttributeMapping(org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping) XMLAnyCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping)

Example 3 with XMLAnyAttributeMapping

use of org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping in project eclipselink by eclipse-ee4j.

the class AnyAttributeReuseProject method buildRootDescriptor.

public ClassDescriptor buildRootDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Root.class);
    descriptor.setDefaultRootElement("root");
    XMLAnyAttributeMapping mapping = new XMLAnyAttributeMapping();
    mapping.setAttributeName("any");
    mapping.setGetMethodName("getAny");
    mapping.setSetMethodName("setAny");
    mapping.setReuseContainer(true);
    descriptor.addMapping(mapping);
    return descriptor;
}
Also used : XMLAnyAttributeMapping(org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor)

Example 4 with XMLAnyAttributeMapping

use of org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping in project eclipselink by eclipse-ee4j.

the class TestProject method getPhoneNumberDescriptor.

private XMLDescriptor getPhoneNumberDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(PhoneNumber.class);
    descriptor.setAlias("PhoneNumber");
    descriptor.setNamespaceResolver(nsr);
    if (setSchemaContext) {
        XMLSchemaReference sRef = new XMLSchemaURLReference();
        sRef.setSchemaContext("/phone-number-type");
        sRef.setType(XMLSchemaReference.COMPLEX_TYPE);
        descriptor.setSchemaReference(sRef);
    }
    if (setDefaultRootElement) {
        descriptor.setDefaultRootElement("phone-number");
    }
    // create number mapping
    XMLDirectMapping numberMapping = new XMLDirectMapping();
    numberMapping.setAttributeName("number");
    numberMapping.setXPath("number/text()");
    descriptor.addMapping(numberMapping);
    // create thing mapping
    XMLAnyAttributeMapping anyMapping = new XMLAnyAttributeMapping();
    anyMapping.setAttributeName("thing");
    descriptor.addMapping(anyMapping);
    /*
        // create type mapping
        XMLDirectMapping typeMapping = new XMLDirectMapping();
        typeMapping.setAttributeName("type");
        typeMapping.setXPath("@type");
        EnumTypeConverter converter = new EnumTypeConverter(typeMapping, PhoneNumberType.class, false);
        typeMapping.setConverter(converter);
        descriptor.addMapping(typeMapping);
        */
    return descriptor;
}
Also used : XMLAnyAttributeMapping(org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaReference(org.eclipse.persistence.oxm.schema.XMLSchemaReference) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference)

Example 5 with XMLAnyAttributeMapping

use of org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping in project eclipselink by eclipse-ee4j.

the class AnyAttributeUsingMapProject method buildRootDescriptor.

public ClassDescriptor buildRootDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Root.class);
    descriptor.setDefaultRootElement("root");
    XMLAnyAttributeMapping mapping = new XMLAnyAttributeMapping();
    mapping.setAttributeName("any");
    mapping.setGetMethodName("getAny");
    mapping.setSetMethodName("setAny");
    mapping.useMapClass(java.util.Hashtable.class);
    descriptor.addMapping(mapping);
    return descriptor;
}
Also used : XMLAnyAttributeMapping(org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor)

Aggregations

XMLAnyAttributeMapping (org.eclipse.persistence.oxm.mappings.XMLAnyAttributeMapping)8 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)5 XMLAnyCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping)2 QName (javax.xml.namespace.QName)1 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)1 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)1 XMLField (org.eclipse.persistence.oxm.XMLField)1 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)1 XMLSchemaReference (org.eclipse.persistence.oxm.schema.XMLSchemaReference)1 XMLSchemaURLReference (org.eclipse.persistence.oxm.schema.XMLSchemaURLReference)1