Search in sources :

Example 96 with XMLField

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

the class XMLChoiceCollectionMapping method getChoiceFieldToClassAssociations.

@Override
public ArrayList getChoiceFieldToClassAssociations() {
    ArrayList associations = new ArrayList();
    if (this.fieldToClassNameMappings.size() > 0) {
        Set<Entry<XMLField, String>> entries = fieldToClassNameMappings.entrySet();
        Iterator<Entry<XMLField, String>> iter = entries.iterator();
        while (iter.hasNext()) {
            Entry<XMLField, String> nextEntry = iter.next();
            XMLField xmlField = nextEntry.getKey();
            String className = nextEntry.getValue();
            XMLChoiceFieldToClassAssociation association = new XMLChoiceFieldToClassAssociation(xmlField, className);
            associations.add(association);
        }
    }
    return associations;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLEntry(org.eclipse.persistence.oxm.record.XMLEntry) Entry(java.util.Map.Entry) XMLChoiceFieldToClassAssociation(org.eclipse.persistence.internal.oxm.XMLChoiceFieldToClassAssociation) ArrayList(java.util.ArrayList)

Example 97 with XMLField

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

the class XMLChoiceCollectionMapping method getFieldForName.

private XMLField getFieldForName(String localName, String namespaceUri) {
    Iterator<DatabaseField> fields = getFields().iterator();
    while (fields.hasNext()) {
        XMLField nextField = (XMLField) fields.next();
        XPathFragment fragment = nextField.getXPathFragment();
        while (fragment != null && (!fragment.nameIsText())) {
            if (fragment.getNextFragment() == null || fragment.getHasText()) {
                if (fragment.getLocalName().equals(localName)) {
                    String fragUri = fragment.getNamespaceURI();
                    if ((namespaceUri == null && fragUri == null) || (namespaceUri != null && fragUri != null && namespaceUri.equals(fragUri))) {
                        return nextField;
                    }
                }
            }
            fragment = fragment.getNextFragment();
        }
    }
    return null;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) DatabaseField(org.eclipse.persistence.internal.helper.DatabaseField) XPathFragment(org.eclipse.persistence.internal.oxm.XPathFragment)

Example 98 with XMLField

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

the class BinaryDataCollectionReuseProject method getEmployeeDescriptor.

private XMLDescriptor getEmployeeDescriptor(NamespaceResolver aNSResolver) {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);
    XMLBinaryDataCollectionMapping photosMapping = new XMLBinaryDataCollectionMapping();
    photosMapping.setAttributeName("photos");
    XMLField field = new XMLField("photos/list/photo");
    field.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
    photosMapping.setReuseContainer(true);
    photosMapping.setField(field);
    descriptor.addMapping(photosMapping);
    if (aNSResolver != null) {
        descriptor.setNamespaceResolver(aNSResolver);
    }
    photosMapping.setShouldInlineBinaryData(false);
    photosMapping.setSwaRef(false);
    photosMapping.setMimeType("image");
    photosMapping.setCollectionContentType(ClassConstants.APBYTE);
    return descriptor;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLBinaryDataCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLBinaryDataCollectionMapping)

Example 99 with XMLField

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

the class BinaryDataCollectionDataHandlerProject method getEmployeeDescriptor.

@Override
protected XMLDescriptor getEmployeeDescriptor(NamespaceResolver aNSResolver) {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(EmployeeWithByteArrayObject.class);
    descriptor.setDefaultRootElement("employee");
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);
    XMLBinaryDataCollectionMapping photosMapping = new XMLBinaryDataCollectionMapping();
    photosMapping.setAttributeName("photos");
    XMLField field = new XMLField("photos/list/photo");
    photosMapping.setField(field);
    descriptor.addMapping(photosMapping);
    if (aNSResolver != null) {
        descriptor.setNamespaceResolver(aNSResolver);
    }
    photosMapping.setShouldInlineBinaryData(false);
    photosMapping.setSwaRef(true);
    photosMapping.setMimeType("image");
    photosMapping.setAttributeElementClass(DataHandler.class);
    return descriptor;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLBinaryDataCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLBinaryDataCollectionMapping)

Example 100 with XMLField

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

the class XMLChoiceWithReferenceProject method getEmployeeDescriptor.

public XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor desc = new XMLDescriptor();
    desc.setJavaClass(Employee.class);
    XMLDirectMapping name = new XMLDirectMapping();
    name.setAttributeName("name");
    name.setXPath("name/text()");
    desc.addMapping(name);
    XMLChoiceObjectMapping mapping = new XMLChoiceObjectMapping();
    mapping.setAttributeName("contact");
    List<XMLField> sourceFields = new ArrayList<XMLField>();
    List<XMLField> targetFields = new ArrayList<XMLField>();
    XMLField source = new XMLField("address/address-id/text()");
    sourceFields.add(source);
    source = new XMLField("address/zip/text()");
    sourceFields.add(source);
    XMLField target = new XMLField("@id");
    targetFields.add(target);
    target = new XMLField("zip/text()");
    targetFields.add(target);
    mapping.addChoiceElement(sourceFields, Address.class, targetFields);
    sourceFields = new ArrayList<XMLField>();
    source = new XMLField("phone/@id");
    sourceFields.add(source);
    targetFields = new ArrayList<XMLField>();
    target = new XMLField("@id");
    targetFields.add(target);
    mapping.addChoiceElement(sourceFields, PhoneNumber.class, targetFields);
    desc.addMapping(mapping);
    return desc;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLChoiceObjectMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceObjectMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ArrayList(java.util.ArrayList)

Aggregations

XMLField (org.eclipse.persistence.oxm.XMLField)302 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)141 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)99 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)48 QName (javax.xml.namespace.QName)43 Element (org.w3c.dom.Element)41 NodeList (org.w3c.dom.NodeList)39 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)36 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)30 ArrayList (java.util.ArrayList)27 Node (org.w3c.dom.Node)25 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)22 DatabaseField (org.eclipse.persistence.internal.helper.DatabaseField)21 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)17 XMLRecord (org.eclipse.persistence.oxm.record.XMLRecord)17 XPathFragment (org.eclipse.persistence.internal.oxm.XPathFragment)15 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)15 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)15 AttributeAccessor (org.eclipse.persistence.mappings.AttributeAccessor)14 Field (org.eclipse.persistence.internal.oxm.mappings.Field)13