public void setFieldToNodeValues(Map<Field, NodeValue> fieldToNodeValues) { this.fieldToNodeValues = fieldToNodeValues; this.classToNodeValues = new HashMap<Class, List<FieldNodeValue>>(); for(Field nextField:fieldToNodeValues.keySet()) { Class associatedClass = ((Map<Field, Class>)this.xmlChoiceCollectionMapping.getFieldToClassMappings()).get(nextField); if (classToNodeValues.containsKey(associatedClass)) { classToNodeValues.get(associatedClass).add(new FieldNodeValue(nextField, fieldToNodeValues.get(nextField))); } else { List<FieldNodeValue> newFieldToNodeValuesList = new ArrayList<FieldNodeValue>(); newFieldToNodeValuesList.add(new FieldNodeValue(nextField, fieldToNodeValues.get(nextField))); this.classToNodeValues.put(associatedClass, newFieldToNodeValuesList); } } Collection classes = this.classToNodeValues.keySet(); for(Class nextClass:((Map<Class, Mapping>)this.xmlChoiceCollectionMapping.getChoiceElementMappingsByClass()).keySet()) { //Create node values for any classes that aren't already processed if(!(classes.contains(nextClass))) { Field field = (Field) xmlChoiceCollectionMapping.getClassToFieldMappings().get(nextClass); NodeValue nodeValue = new XMLChoiceCollectionMappingUnmarshalNodeValue(xmlChoiceCollectionMapping, xmlField, (Mapping) xmlChoiceCollectionMapping.getChoiceElementMappingsByClass().get(nextClass)); List<FieldNodeValue> newFieldToNodeValuesList = new ArrayList<FieldNodeValue>(); newFieldToNodeValuesList.add(new FieldNodeValue(field, nodeValue)); this.classToNodeValues.put(nextClass, newFieldToNodeValuesList); NodeValue nodeValueForField = fieldToNodeValues.get(field); nodeValue.setXPathNode(nodeValueForField.getXPathNode()); } } }
public void setFieldToNodeValues(Map<Field, NodeValue> fieldToNodeValues) { this.fieldToNodeValues = fieldToNodeValues; this.classToNodeValues = new HashMap<Class, List<FieldNodeValue>>(); for(Field nextField:fieldToNodeValues.keySet()) { Class associatedClass = ((Map<Field, Class>)this.xmlChoiceCollectionMapping.getFieldToClassMappings()).get(nextField); if (classToNodeValues.containsKey(associatedClass)) { classToNodeValues.get(associatedClass).add(new FieldNodeValue(nextField, fieldToNodeValues.get(nextField))); } else { List<FieldNodeValue> newFieldToNodeValuesList = new ArrayList<FieldNodeValue>(); newFieldToNodeValuesList.add(new FieldNodeValue(nextField, fieldToNodeValues.get(nextField))); this.classToNodeValues.put(associatedClass, newFieldToNodeValuesList); } } Collection classes = this.classToNodeValues.keySet(); for(Class nextClass:((Map<Class, Mapping>)this.xmlChoiceCollectionMapping.getChoiceElementMappingsByClass()).keySet()) { //Create node values for any classes that aren't already processed if(!(classes.contains(nextClass))) { Field field = (Field) xmlChoiceCollectionMapping.getClassToFieldMappings().get(nextClass); NodeValue nodeValue = new XMLChoiceCollectionMappingUnmarshalNodeValue(xmlChoiceCollectionMapping, xmlField, (Mapping) xmlChoiceCollectionMapping.getChoiceElementMappingsByClass().get(nextClass)); List<FieldNodeValue> newFieldToNodeValuesList = new ArrayList<FieldNodeValue>(); newFieldToNodeValuesList.add(new FieldNodeValue(field, nodeValue)); this.classToNodeValues.put(nextClass, newFieldToNodeValuesList); NodeValue nodeValueForField = fieldToNodeValues.get(field); nodeValue.setXPathNode(nodeValueForField.getXPathNode()); } } }
frag = marshalRecord.getTextWrapperFragment(); }else{ frag = associatedNodeValue.getXPathNode().getXPathFragment(); if(frag != null){ frag = getOwningFragment(associatedNodeValue, frag);
frag = marshalRecord.getTextWrapperFragment(); }else{ frag = associatedNodeValue.getXPathNode().getXPathFragment(); if(frag != null){ frag = getOwningFragment(associatedNodeValue, frag);
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object value, CoreAbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) { value = xmlChoiceCollectionMapping.convertObjectValueToDataValue(value, session, marshalRecord.getMarshaller()); if(value !=null && value.getClass() == CoreClassConstants.STRING && this.xmlChoiceCollectionMapping.isMixedContent()) { marshalMixedContent(marshalRecord, (String)value); return true; } NodeValue associatedNodeValue = getNodeValueForValue(value); if(associatedNodeValue != null) { if(associatedNodeValue.isAnyMappingNodeValue()){ //NodeValue unwrappedNodeValue = ((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementMarshalNodeValue(); return marshalSingleValueWithNodeValue(null, marshalRecord, object, value, session, namespaceResolver, marshalContext, associatedNodeValue); } else{ //Find the correct fragment XPathFragment frag = associatedNodeValue.getXPathNode().getXPathFragment(); if(frag != null){ frag = getOwningFragment(associatedNodeValue, frag); NodeValue unwrappedNodeValue = ((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementMarshalNodeValue(); return marshalSingleValueWithNodeValue(frag, marshalRecord, object, value, session, namespaceResolver, marshalContext, unwrappedNodeValue); } } } return true; }
public boolean marshalSingleValue(XPathFragment xPathFragment, MarshalRecord marshalRecord, Object object, Object value, CoreAbstractSession session, NamespaceResolver namespaceResolver, MarshalContext marshalContext) { value = xmlChoiceCollectionMapping.convertObjectValueToDataValue(value, session, marshalRecord.getMarshaller()); if(value !=null && value.getClass() == CoreClassConstants.STRING && this.xmlChoiceCollectionMapping.isMixedContent()) { marshalMixedContent(marshalRecord, (String)value); return true; } NodeValue associatedNodeValue = getNodeValueForValue(value); if(associatedNodeValue != null) { if(associatedNodeValue.isAnyMappingNodeValue()){ //NodeValue unwrappedNodeValue = ((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementMarshalNodeValue(); return marshalSingleValueWithNodeValue(null, marshalRecord, object, value, session, namespaceResolver, marshalContext, associatedNodeValue); } else{ //Find the correct fragment XPathFragment frag = associatedNodeValue.getXPathNode().getXPathFragment(); if(frag != null){ frag = getOwningFragment(associatedNodeValue, frag); NodeValue unwrappedNodeValue = ((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementMarshalNodeValue(); return marshalSingleValueWithNodeValue(frag, marshalRecord, object, value, session, namespaceResolver, marshalContext, unwrappedNodeValue); } } } return true; }