Search in sources :

Example 41 with XMLCompositeDirectCollectionMapping

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

the class XMLSessionConfigProject method buildSessionEventManagerConfigDescriptor.

public ClassDescriptor buildSessionEventManagerConfigDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(SessionEventManagerConfig.class);
    XMLCompositeDirectCollectionMapping sessionEventListenersMapping = new XMLCompositeDirectCollectionMapping();
    sessionEventListenersMapping.setAttributeName("m_sessionEventListeners");
    sessionEventListenersMapping.setGetMethodName("getSessionEventListeners");
    sessionEventListenersMapping.setSetMethodName("setSessionEventListeners");
    sessionEventListenersMapping.setXPath("event-listener-class/text()");
    descriptor.addMapping(sessionEventListenersMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)

Example 42 with XMLCompositeDirectCollectionMapping

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

the class SimpleUnionProject method getPersonDescriptor.

private XMLDescriptor getPersonDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Person.class);
    descriptor.setDefaultRootElement("person");
    NamespaceResolver resolver = new NamespaceResolver();
    resolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
    resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
    descriptor.setNamespaceResolver(resolver);
    XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping();
    itemsMapping.setAttributeName("items");
    itemsMapping.setGetMethodName("getItems");
    itemsMapping.setSetMethodName("setItems");
    itemsMapping.useCollectionClass(java.util.ArrayList.class);
    XMLUnionField field = new XMLUnionField("item/text()");
    QName dateQname = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "date");
    QName integerQName = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer");
    field.addSchemaType(dateQname);
    field.addSchemaType(integerQName);
    itemsMapping.setField(field);
    descriptor.addMapping(itemsMapping);
    XMLDirectMapping firstNameMapping = new XMLDirectMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setXPath("first-name/text()");
    descriptor.addMapping(firstNameMapping);
    XMLDirectMapping lastNameMapping = new XMLDirectMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setXPath("last-name/text()");
    descriptor.addMapping(lastNameMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) QName(javax.xml.namespace.QName) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping) XMLUnionField(org.eclipse.persistence.oxm.XMLUnionField)

Example 43 with XMLCompositeDirectCollectionMapping

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

the class SimpleUnionXMLAttributeProject method getPersonDescriptor.

private XMLDescriptor getPersonDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Person.class);
    descriptor.setDefaultRootElement("person");
    NamespaceResolver resolver = new NamespaceResolver();
    resolver.put(XMLConstants.SCHEMA_INSTANCE_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
    resolver.put(XMLConstants.SCHEMA_PREFIX, javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);
    descriptor.setNamespaceResolver(resolver);
    XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping();
    itemsMapping.setAttributeName("items");
    itemsMapping.setGetMethodName("getItems");
    itemsMapping.setSetMethodName("setItems");
    itemsMapping.useCollectionClass(java.util.ArrayList.class);
    XMLUnionField field = new XMLUnionField("items/@item");
    QName dateQname = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "date");
    QName integerQName = new QName(javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer");
    field.addSchemaType(dateQname);
    field.addSchemaType(integerQName);
    itemsMapping.setField(field);
    descriptor.addMapping(itemsMapping);
    XMLDirectMapping firstNameMapping = new XMLDirectMapping();
    firstNameMapping.setAttributeName("firstName");
    firstNameMapping.setXPath("first-name/text()");
    descriptor.addMapping(firstNameMapping);
    XMLDirectMapping lastNameMapping = new XMLDirectMapping();
    lastNameMapping.setAttributeName("lastName");
    lastNameMapping.setXPath("last-name/text()");
    descriptor.addMapping(lastNameMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) QName(javax.xml.namespace.QName) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping) XMLUnionField(org.eclipse.persistence.oxm.XMLUnionField)

Example 44 with XMLCompositeDirectCollectionMapping

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

the class DirectCollectionSingleNodeProject method getEmployeeDescriptor.

private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);
    XMLCompositeDirectCollectionMapping responsibilitiesMapping = new XMLCompositeDirectCollectionMapping();
    responsibilitiesMapping.setAttributeName("responsibilities");
    responsibilitiesMapping.useCollectionClass(ArrayList.class);
    responsibilitiesMapping.setXPath("responsibilities/text()");
    responsibilitiesMapping.setUsesSingleNode(true);
    descriptor.addMapping(responsibilitiesMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)

Example 45 with XMLCompositeDirectCollectionMapping

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

the class RootProject method getRootDescriptor.

private XMLDescriptor getRootDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Root.class);
    descriptor.setDefaultRootElement("root");
    XMLCompositeDirectCollectionMapping itemsMapping = new XMLCompositeDirectCollectionMapping();
    itemsMapping.setAttributeName("items");
    itemsMapping.setXPath("item/text()");
    itemsMapping.setFieldElementClass(ArrayList.class);
    itemsMapping.useCollectionClass(ArrayList.class);
    XMLListConverter listConverter = new XMLListConverter();
    listConverter.setObjectClass(Double.class);
    itemsMapping.setValueConverter(listConverter);
    descriptor.addMapping(itemsMapping);
    return descriptor;
}
Also used : XMLListConverter(org.eclipse.persistence.oxm.mappings.converters.XMLListConverter) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)

Aggregations

XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)63 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)49 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)40 XMLField (org.eclipse.persistence.oxm.XMLField)14 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)11 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)11 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)10 QName (javax.xml.namespace.QName)6 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)6 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)3 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)3 JAXBException (org.eclipse.persistence.exceptions.JAXBException)3 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)3 JAXBArrayAttributeAccessor (org.eclipse.persistence.internal.jaxb.many.JAXBArrayAttributeAccessor)3 Field (org.eclipse.persistence.internal.oxm.mappings.Field)3 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)3 BigDecimal (java.math.BigDecimal)2 CoreDescriptor (org.eclipse.persistence.core.descriptors.CoreDescriptor)2 CoreMapping (org.eclipse.persistence.core.mappings.CoreMapping)2 CoreConverter (org.eclipse.persistence.core.mappings.converters.CoreConverter)2