Search in sources :

Example 1 with XMLChoiceFieldToClassAssociation

use of org.eclipse.persistence.internal.oxm.XMLChoiceFieldToClassAssociation 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 2 with XMLChoiceFieldToClassAssociation

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

the class XMLChoiceObjectMapping 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) Entry(java.util.Map.Entry) XMLChoiceFieldToClassAssociation(org.eclipse.persistence.internal.oxm.XMLChoiceFieldToClassAssociation) ArrayList(java.util.ArrayList)

Example 3 with XMLChoiceFieldToClassAssociation

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

the class SchemaModelGenerator method processChoiceMapping.

/**
 * Process a given XMLChoiceMapping.
 */
protected void processChoiceMapping(Map<Field, Class<?>> fieldToClassMap, List<XMLChoiceFieldToClassAssociation> choiceFieldToClassList, Sequence seq, ComplexType ct, HashMap<String, Schema> schemaForNamespace, Schema workingSchema, SchemaModelGeneratorProperties properties, List<Descriptor> descriptors, boolean isCollection) {
    Choice theChoice = new Choice();
    if (isCollection) {
        theChoice.setMaxOccurs(Occurs.UNBOUNDED);
    }
    for (XMLChoiceFieldToClassAssociation next : choiceFieldToClassList) {
        Field field = next.getXmlField();
        Element element = buildElement(field.getXPathFragment().getShortName(), Occurs.ZERO, null);
        QName schemaTypeQName = field.getSchemaType();
        if (schemaTypeQName != null) {
            element.setType(getSchemaTypeString(schemaTypeQName, workingSchema));
        } else {
            element = processReferenceDescriptor(element, getDescriptorByClass(fieldToClassMap.get(field), descriptors), schemaForNamespace, workingSchema, properties, descriptors, field, false);
        }
        theChoice.addElement(element);
    }
    seq.addChoice(theChoice);
}
Also used : Field(org.eclipse.persistence.internal.oxm.mappings.Field) XMLChoiceFieldToClassAssociation(org.eclipse.persistence.internal.oxm.XMLChoiceFieldToClassAssociation) Choice(org.eclipse.persistence.internal.oxm.schema.model.Choice) QName(javax.xml.namespace.QName) Element(org.eclipse.persistence.internal.oxm.schema.model.Element)

Aggregations

XMLChoiceFieldToClassAssociation (org.eclipse.persistence.internal.oxm.XMLChoiceFieldToClassAssociation)3 ArrayList (java.util.ArrayList)2 Entry (java.util.Map.Entry)2 XMLField (org.eclipse.persistence.oxm.XMLField)2 QName (javax.xml.namespace.QName)1 Field (org.eclipse.persistence.internal.oxm.mappings.Field)1 Choice (org.eclipse.persistence.internal.oxm.schema.model.Choice)1 Element (org.eclipse.persistence.internal.oxm.schema.model.Element)1 XMLEntry (org.eclipse.persistence.oxm.record.XMLEntry)1