use of org.eclipse.persistence.internal.oxm.record.ObjectMarshalContext in project eclipselink by eclipse-ee4j.
the class XPathObjectBuilder method marshalAttributes.
@Override
public boolean marshalAttributes(MarshalRecord marshalRecord, Object object, CoreAbstractSession session) {
lazyInitialize();
boolean hasValue = false;
NamespaceResolver namespaceResolver = ((Descriptor) descriptor).getNamespaceResolver();
List<XPathNode> attributeChildren = rootXPathNode.getAttributeChildren();
if (null != attributeChildren) {
ObjectMarshalContext objectMarshalContext = ObjectMarshalContext.getInstance();
for (XPathNode anAttributeChildren : attributeChildren) {
hasValue = anAttributeChildren.marshal(marshalRecord, object, session, namespaceResolver, null, objectMarshalContext, null) || hasValue;
}
}
if (rootXPathNode.getAnyAttributeNode() != null) {
hasValue = rootXPathNode.getAnyAttributeNode().marshal(marshalRecord, object, session, namespaceResolver, null, ObjectMarshalContext.getInstance(), null) || hasValue;
}
List<XPathNode> selfChildren = rootXPathNode.getSelfChildren();
if (null != selfChildren) {
for (XPathNode selfXPathNode : selfChildren) {
NodeValue marshalNodeValue = selfXPathNode.getMarshalNodeValue();
if (marshalNodeValue instanceof MappingNodeValue) {
Mapping selfMapping = ((MappingNodeValue) marshalNodeValue).getMapping();
Object value = selfMapping.getAttributeValueFromObject(object);
Descriptor referenceDescriptor = (Descriptor) selfMapping.getReferenceDescriptor();
Descriptor valueDescriptor;
if (value != null && (referenceDescriptor == null || referenceDescriptor.hasInheritance())) {
valueDescriptor = (Descriptor) session.getDescriptor(value.getClass());
} else {
valueDescriptor = referenceDescriptor;
}
if (null != valueDescriptor) {
marshalRecord.addXsiTypeAndClassIndicatorIfRequired(valueDescriptor, referenceDescriptor, (Field) selfMapping.getField(), false);
}
}
selfXPathNode.marshalSelfAttributes(marshalRecord, object, session, namespaceResolver, marshalRecord.getMarshaller());
}
}
return hasValue;
}
Aggregations