use of org.eclipse.persistence.internal.oxm.mappings.DirectMapping in project eclipselink by eclipse-ee4j.
the class JsonSchemaGenerator method generateProperty.
private Property generateProperty(Mapping next, XMLDescriptor descriptor, Map<String, Property> properties) {
Property prop = null;
if (next.isCollectionMapping()) {
if (next instanceof CollectionReferenceMapping) {
CollectionReferenceMapping mapping = (CollectionReferenceMapping) next;
Set<XMLField> sourceFields = mapping.getSourceToTargetKeyFieldAssociations().keySet();
XMLDescriptor reference = (XMLDescriptor) mapping.getReferenceDescriptor();
for (XMLField nextField : sourceFields) {
XPathFragment frag = nextField.getXPathFragment();
String propertyName = getNameForFragment(frag);
XMLField targetField = (XMLField) mapping.getSourceToTargetKeyFieldAssociations().get(nextField);
Class<?> type = CoreClassConstants.STRING;
if (reference != null) {
type = getTypeForTargetField(targetField, reference);
}
prop = properties.get(propertyName);
if (prop == null) {
prop = new Property();
prop.setName(propertyName);
}
Property nestedProperty = getNestedPropertyForFragment(frag, prop);
nestedProperty.setType(JsonType.ARRAY);
nestedProperty.setItem(new Property());
nestedProperty.getItem().setType(getJsonTypeForJavaType(type));
if (!properties.containsKey(prop.getName())) {
properties.put(prop.getName(), prop);
}
}
return prop;
} else if (next.isAbstractCompositeCollectionMapping()) {
CompositeCollectionMapping mapping = (CompositeCollectionMapping) next;
XMLField field = (XMLField) mapping.getField();
XPathFragment frag = field.getXPathFragment();
String propName = getNameForFragment(frag);
// for paths, there may already be an existing property
prop = properties.get(propName);
if (prop == null) {
prop = new Property();
prop.setName(propName);
}
Property nestedProperty = getNestedPropertyForFragment(frag, prop);
nestedProperty.setType(JsonType.ARRAY);
nestedProperty.setItem(new Property());
XMLDescriptor referenceDescriptor = (XMLDescriptor) mapping.getReferenceDescriptor();
if (referenceDescriptor != null && referenceDescriptor.hasInheritance()) {
// handle inheritence
// schema.setAnyOf(new Property[descriptor.getInheritancePolicy().getAllChildDescriptors().size()]);
List<ClassDescriptor> descriptors = getAllDescriptorsForInheritance(referenceDescriptor);
Property[] props = new Property[descriptors.size()];
for (int i = 0; i < props.length; i++) {
XMLDescriptor nextDescriptor = null;
nextDescriptor = (XMLDescriptor) descriptors.get(i);
Property ref = new Property();
ref.setRef(getReferenceForDescriptor(nextDescriptor, true));
props[i] = ref;
}
nestedProperty.getItem().setAnyOf(props);
} else {
nestedProperty.getItem().setRef(getReferenceForDescriptor(referenceDescriptor, false));
// populateProperties(nestedProperty.getItem().getProperties(), (XMLDescriptor)mapping.getReferenceDescriptor());
}
} else if (next.isAbstractCompositeDirectCollectionMapping()) {
DirectCollectionMapping mapping = (DirectCollectionMapping) next;
XMLField field = (XMLField) mapping.getField();
XPathFragment frag = field.getXPathFragment();
List<String> enumeration = null;
if (mapping.getValueConverter() instanceof JAXBEnumTypeConverter) {
enumeration = getEnumeration((DatabaseMapping) next);
}
String propertyName = getNameForFragment(frag);
if (frag.nameIsText()) {
propertyName = (String) this.contextProperties.get(MarshallerProperties.JSON_VALUE_WRAPPER);
}
if (frag.isAttribute() && this.attributePrefix != null) {
propertyName = attributePrefix + propertyName;
}
prop = properties.get(propertyName);
if (prop == null) {
prop = new Property();
prop.setName(propertyName);
}
Property nestedProperty = getNestedPropertyForFragment(frag, prop);
nestedProperty.setType(JsonType.ARRAY);
nestedProperty.setItem(new Property());
if (enumeration != null) {
nestedProperty.getItem().setEnumeration(enumeration);
}
Class<?> type = mapping.getAttributeElementClass();
if (type == null) {
type = CoreClassConstants.STRING;
}
nestedProperty.getItem().setType(getJsonTypeForJavaType(type));
return prop;
} else if (next instanceof BinaryDataCollectionMapping) {
BinaryDataCollectionMapping mapping = (BinaryDataCollectionMapping) next;
XMLField field = (XMLField) mapping.getField();
XPathFragment frag = field.getXPathFragment();
String propertyName = getNameForFragment(frag);
if (frag.isSelfFragment()) {
propertyName = Constants.VALUE_WRAPPER;
if (this.contextProperties != null) {
String valueWrapper = (String) this.contextProperties.get(JAXBContextProperties.JSON_VALUE_WRAPPER);
if (valueWrapper != null) {
propertyName = valueWrapper;
}
}
}
if (frag.isAttribute() && this.attributePrefix != null) {
propertyName = attributePrefix + propertyName;
}
prop = properties.get(propertyName);
if (prop == null) {
prop = new Property();
prop.setName(propertyName);
}
Property nestedProperty = getNestedPropertyForFragment(frag, prop);
nestedProperty.setType(JsonType.ARRAY);
nestedProperty.setItem(new Property());
if (mapping.shouldInlineBinaryData()) {
nestedProperty.getItem().setType(JsonType.STRING);
} else {
nestedProperty.getItem().setAnyOf(getXopIncludeProperties());
}
return prop;
}
} else {
if (next.isAbstractDirectMapping()) {
// handle direct mapping
DirectMapping directMapping = (DirectMapping) next;
XMLField field = (XMLField) directMapping.getField();
XPathFragment frag = field.getXPathFragment();
List<String> enumeration = null;
if (directMapping.getConverter() instanceof JAXBEnumTypeConverter) {
enumeration = getEnumeration((DatabaseMapping) directMapping);
}
String propertyName = getNameForFragment(frag);
if (frag.nameIsText()) {
propertyName = Constants.VALUE_WRAPPER;
if (this.contextProperties != null) {
String valueWrapper = (String) this.contextProperties.get(JAXBContextProperties.JSON_VALUE_WRAPPER);
if (valueWrapper != null) {
propertyName = valueWrapper;
}
}
}
if (frag.isAttribute() && this.attributePrefix != null) {
propertyName = attributePrefix + propertyName;
}
prop = properties.get(propertyName);
if (prop == null) {
prop = new Property();
prop.setName(propertyName);
}
Property nestedProperty = getNestedPropertyForFragment(frag, prop);
if (enumeration != null) {
nestedProperty.setEnumeration(enumeration);
}
if (directMapping instanceof BinaryDataMapping) {
BinaryDataMapping binaryMapping = (BinaryDataMapping) directMapping;
if (binaryMapping.shouldInlineBinaryData() || binaryMapping.isSwaRef()) {
nestedProperty.setType(JsonType.STRING);
} else {
if (this.xopIncludeProp == null) {
initXopIncludeProp();
}
nestedProperty.setAnyOf(this.xopIncludeProp);
}
} else {
nestedProperty.setType(getJsonTypeForJavaType(directMapping.getAttributeClassification()));
}
return prop;
} else if (next instanceof ObjectReferenceMapping) {
ObjectReferenceMapping mapping = (ObjectReferenceMapping) next;
Set<XMLField> sourceFields = mapping.getSourceToTargetKeyFieldAssociations().keySet();
XMLDescriptor reference = (XMLDescriptor) mapping.getReferenceDescriptor();
for (XMLField nextField : sourceFields) {
XPathFragment frag = nextField.getXPathFragment();
String propName = getNameForFragment(frag);
XMLField targetField = (XMLField) mapping.getSourceToTargetKeyFieldAssociations().get(nextField);
Class<?> type = CoreClassConstants.STRING;
if (reference != null) {
type = getTypeForTargetField(targetField, reference);
}
prop = properties.get(propName);
if (prop == null) {
prop = new Property();
prop.setName(propName);
}
Property nestedProperty = getNestedPropertyForFragment(frag, prop);
// nestedProperty.setType(JsonType.ARRAY);
// nestedProperty.setItem(new Property());
nestedProperty.setType(getJsonTypeForJavaType(type));
if (!properties.containsKey(prop.getName())) {
properties.put(prop.getName(), prop);
}
}
return prop;
} else if (next.isAbstractCompositeObjectMapping()) {
CompositeObjectMapping mapping = (CompositeObjectMapping) next;
XMLDescriptor nextDescriptor = (XMLDescriptor) mapping.getReferenceDescriptor();
XMLField field = (XMLField) mapping.getField();
XPathFragment firstFragment = field.getXPathFragment();
if (firstFragment.isSelfFragment() || firstFragment.nameIsText()) {
if (nextDescriptor != null) {
populateProperties(properties, nextDescriptor);
}
} else {
String propName = getNameForFragment(firstFragment);
prop = properties.get(propName);
if (prop == null) {
prop = new Property();
prop.setName(propName);
}
// prop.setType(JsonType.OBJECT);
prop.setName(propName);
Property nestedProperty = getNestedPropertyForFragment(firstFragment, prop);
XMLDescriptor referenceDescriptor = (XMLDescriptor) mapping.getReferenceDescriptor();
if (referenceDescriptor != null && referenceDescriptor.hasInheritance()) {
// handle inheritence
// schema.setAnyOf(new Property[descriptor.getInheritancePolicy().getAllChildDescriptors().size()]);
List<ClassDescriptor> descriptors = getAllDescriptorsForInheritance(referenceDescriptor);
Property[] props = new Property[descriptors.size()];
for (int i = 0; i < props.length; i++) {
XMLDescriptor nextDesc = (XMLDescriptor) descriptors.get(i);
Property ref = new Property();
ref.setRef(getReferenceForDescriptor(nextDesc, true));
props[i] = ref;
}
nestedProperty.setAnyOf(props);
} else {
nestedProperty.setRef(getReferenceForDescriptor(referenceDescriptor, false));
// populateProperties(nestedProperty.getItem().getProperties(), (XMLDescriptor)mapping.getReferenceDescriptor());
}
// populateProperties(nestedProperty.getProperties(), nextDescriptor);
}
} else if (next instanceof BinaryDataMapping) {
BinaryDataMapping binaryMapping = (BinaryDataMapping) next;
XMLField field = (XMLField) binaryMapping.getField();
XPathFragment frag = field.getXPathFragment();
String propertyName = getNameForFragment(frag);
if (frag.isSelfFragment()) {
propertyName = Constants.VALUE_WRAPPER;
if (this.contextProperties != null) {
String valueWrapper = (String) this.contextProperties.get(MarshallerProperties.JSON_VALUE_WRAPPER);
if (valueWrapper != null) {
propertyName = valueWrapper;
}
}
}
if (frag.isAttribute() && this.attributePrefix != null) {
propertyName = attributePrefix + propertyName;
}
prop = properties.get(propertyName);
if (prop == null) {
prop = new Property();
prop.setName(propertyName);
}
Property nestedProperty = getNestedPropertyForFragment(frag, prop);
if (binaryMapping.shouldInlineBinaryData() || binaryMapping.isSwaRef()) {
nestedProperty.setType(JsonType.STRING);
} else {
if (this.xopIncludeProp == null) {
initXopIncludeProp();
}
nestedProperty.setAnyOf(this.xopIncludeProp);
}
return prop;
}
}
return prop;
}
use of org.eclipse.persistence.internal.oxm.mappings.DirectMapping in project eclipselink by eclipse-ee4j.
the class JsonSchemaGenerator method getEnumeration.
private List<String> getEnumeration(DatabaseMapping textMapping) {
JAXBEnumTypeConverter converter = null;
if (textMapping.isAbstractDirectMapping()) {
converter = (JAXBEnumTypeConverter) ((DirectMapping) textMapping).getConverter();
} else if (textMapping.isAbstractCompositeDirectCollectionMapping()) {
converter = (JAXBEnumTypeConverter) ((DirectCollectionMapping) textMapping).getValueConverter();
}
if (converter == null) {
return null;
}
List<String> enumeration = new ArrayList<String>();
for (Object nextValue : converter.getAttributeToFieldValues().values()) {
enumeration.add(nextValue.toString());
}
return enumeration;
}
use of org.eclipse.persistence.internal.oxm.mappings.DirectMapping in project eclipselink by eclipse-ee4j.
the class MappingsGenerator method generateDirectEnumerationMapping.
public DirectMapping generateDirectEnumerationMapping(Property property, Descriptor descriptor, NamespaceInfo namespaceInfo, EnumTypeInfo enumInfo) {
DirectMapping mapping = new XMLDirectMapping();
initializeXMLMapping((XMLMapping) mapping, property);
mapping.setNullValueMarshalled(true);
mapping.setConverter(buildJAXBEnumTypeConverter(mapping, enumInfo));
// handle null policy set via xml metadata
if (property.isSetNullPolicy()) {
mapping.setNullPolicy(getNullPolicyFromProperty(property, getNamespaceResolverForDescriptor(namespaceInfo)));
} else if (property.isNillable()) {
mapping.getNullPolicy().setNullRepresentedByXsiNil(true);
mapping.getNullPolicy().setMarshalNullRepresentation(XMLNullRepresentationType.XSI_NIL);
}
mapping.setField(getXPathForField(property, namespaceInfo, true, false));
if (!mapping.getXPath().equals("text()")) {
((NullPolicy) mapping.getNullPolicy()).setSetPerformedForAbsentNode(false);
}
return mapping;
}
use of org.eclipse.persistence.internal.oxm.mappings.DirectMapping in project eclipselink by eclipse-ee4j.
the class MappingsGenerator method generateWrapperClassAndDescriptor.
private Class<?> generateWrapperClassAndDescriptor(TypeInfo type, QName next, ElementDeclaration nextElement, String nextClassName, String attributeTypeName) {
String namespaceUri = null;
if (next != null) {
// generate a class/descriptor for this element
namespaceUri = next.getNamespaceURI();
if (namespaceUri == null || namespaceUri.equals(XMLProcessor.DEFAULT)) {
namespaceUri = "";
}
}
TypeMappingInfo tmi = nextElement.getTypeMappingInfo();
Class<?> generatedClass = null;
JaxbClassLoader loader = getJaxbClassLoader();
if (tmi != null) {
generatedClass = CompilerHelper.getExisitingGeneratedClass(tmi, typeMappingInfoToGeneratedClasses, typeMappingInfoToAdapterClasses, helper.getClassLoader());
if (generatedClass == null) {
generatedClass = this.generateWrapperClass(loader.nextAvailableGeneratedClassName(), attributeTypeName, nextElement.isList(), next);
}
typeMappingInfoToGeneratedClasses.put(tmi, generatedClass);
} else {
generatedClass = this.generateWrapperClass(loader.nextAvailableGeneratedClassName(), attributeTypeName, nextElement.isList(), next);
}
this.qNamesToGeneratedClasses.put(next, generatedClass);
try {
Class<Object> declaredClass = PrivilegedAccessHelper.getClassForName(nextClassName, false, helper.getClassLoader());
this.qNamesToDeclaredClasses.put(next, declaredClass);
} catch (Exception e) {
}
Descriptor desc = (Descriptor) project.getDescriptor(generatedClass);
if (desc == null) {
desc = new XMLDescriptor();
desc.setJavaClass(generatedClass);
if (nextElement.isList()) {
DirectCollectionMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, Session, XMLUnmarshaller, XMLRecord> mapping = new XMLCompositeDirectCollectionMapping();
mapping.setAttributeName("value");
mapping.setXPath("text()");
mapping.setUsesSingleNode(true);
mapping.setReuseContainer(true);
if (type != null && type.isEnumerationType()) {
mapping.setValueConverter(buildJAXBEnumTypeConverter(mapping, (EnumTypeInfo) type));
} else {
try {
Class<Object> fieldElementClass = PrivilegedAccessHelper.getClassForName(nextClassName, false, helper.getClassLoader());
mapping.setFieldElementClass(fieldElementClass);
} catch (ClassNotFoundException e) {
}
}
if (nextClassName.equals("[B") || nextClassName.equals("[Ljava.lang.Byte;")) {
((Field) mapping.getField()).setSchemaType(Constants.BASE_64_BINARY_QNAME);
} else if (nextClassName.equals("javax.xml.namespace.QName")) {
((Field) mapping.getField()).setSchemaType(Constants.QNAME_QNAME);
}
desc.addMapping((CoreMapping) mapping);
} else {
if (nextElement.getJavaTypeName().equals(OBJECT_CLASS_NAME)) {
CompositeObjectMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, Session, UnmarshalKeepAsElementPolicy, XMLUnmarshaller, XMLRecord> mapping = new XMLCompositeObjectMapping();
mapping.setAttributeName("value");
mapping.setSetMethodName("setValue");
mapping.setGetMethodName("getValue");
mapping.setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
mapping.setXPath(".");
setTypedTextField((Field) mapping.getField());
desc.addMapping((CoreMapping) mapping);
} else if (isBinaryData(nextElement.getJavaType())) {
BinaryDataMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, MimeTypePolicy, Session, XMLUnmarshaller, XMLRecord> mapping = new XMLBinaryDataMapping();
mapping.setAttributeName("value");
mapping.setXPath(".");
((Field) mapping.getField()).setSchemaType(Constants.BASE_64_BINARY_QNAME);
mapping.setSetMethodName("setValue");
mapping.setGetMethodName("getValue");
mapping.getNullPolicy().setNullRepresentedByXsiNil(true);
mapping.getNullPolicy().setNullRepresentedByEmptyNode(false);
Class<?> attributeClassification = org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(attributeTypeName, helper.getClassLoader());
mapping.setAttributeClassification(attributeClassification);
mapping.setShouldInlineBinaryData(false);
// if(nextElement.getTypeMappingInfo() != null) {
mapping.setSwaRef(nextElement.isXmlAttachmentRef());
mapping.setMimeType(nextElement.getXmlMimeType());
// }
desc.addMapping((CoreMapping) mapping);
} else {
DirectMapping<AbstractSession, AttributeAccessor, ContainerPolicy, Converter, ClassDescriptor, DatabaseField, XMLMarshaller, Session, XMLUnmarshaller, XMLRecord> mapping = new XMLDirectMapping();
mapping.setNullValueMarshalled(true);
mapping.setAttributeName("value");
mapping.setXPath("text()");
mapping.setSetMethodName("setValue");
mapping.setGetMethodName("getValue");
if (nextElement.getDefaultValue() != null) {
mapping.setNullValue(nextElement.getDefaultValue());
mapping.getNullPolicy().setNullRepresentedByXsiNil(true);
}
if (helper.isBuiltInJavaType(nextElement.getJavaType())) {
Class<?> attributeClassification = null;
if (nextElement.getJavaType().isPrimitive()) {
attributeClassification = XMLConversionManager.getDefaultManager().convertClassNameToClass(attributeTypeName);
} else {
attributeClassification = org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(attributeTypeName, helper.getClassLoader());
}
mapping.setAttributeClassification(attributeClassification);
}
IsSetNullPolicy nullPolicy = new IsSetNullPolicy("isSetValue", false, true, XMLNullRepresentationType.ABSENT_NODE);
// nullPolicy.setNullRepresentedByEmptyNode(true);
mapping.setNullPolicy(nullPolicy);
if (type != null && type.isEnumerationType()) {
mapping.setConverter(buildJAXBEnumTypeConverter(mapping, (EnumTypeInfo) type));
}
if (nextClassName.equals("[B") || nextClassName.equals("[Ljava.lang.Byte;")) {
((Field) mapping.getField()).setSchemaType(Constants.BASE_64_BINARY_QNAME);
} else if (nextClassName.equals("javax.xml.namespace.QName")) {
((Field) mapping.getField()).setSchemaType(Constants.QNAME_QNAME);
}
if (nextElement.getJavaTypeAdapterClass() != null) {
mapping.setConverter(new XMLJavaTypeConverter(nextElement.getJavaTypeAdapterClass()));
}
desc.addMapping((CoreMapping) mapping);
}
}
if (next != null) {
NamespaceInfo info = getNamespaceInfoForURI(namespaceUri);
if (info != null) {
NamespaceResolver resolver = getNamespaceResolverForDescriptor(info);
String prefix = null;
if (namespaceUri != Constants.EMPTY_STRING) {
prefix = resolver.resolveNamespaceURI(namespaceUri);
if (prefix == null) {
prefix = getPrefixForNamespace(namespaceUri, resolver);
}
}
desc.setNamespaceResolver(resolver);
if (nextElement.isXmlRootElement()) {
desc.setDefaultRootElement(getQualifiedString(prefix, next.getLocalPart()));
} else {
desc.setDefaultRootElement("");
desc.addRootElement(getQualifiedString(prefix, next.getLocalPart()));
desc.setResultAlwaysXMLRoot(true);
}
} else {
if (namespaceUri.equals("")) {
desc.setDefaultRootElement(next.getLocalPart());
} else {
NamespaceResolver resolver = new org.eclipse.persistence.oxm.NamespaceResolver();
String prefix = getPrefixForNamespace(namespaceUri, resolver);
desc.setNamespaceResolver(resolver);
if (nextElement.isXmlRootElement()) {
desc.setDefaultRootElement(getQualifiedString(prefix, next.getLocalPart()));
} else {
desc.setDefaultRootElement("");
desc.addRootElement(getQualifiedString(prefix, next.getLocalPart()));
desc.setResultAlwaysXMLRoot(true);
}
}
}
}
project.addDescriptor((CoreDescriptor) desc);
}
return generatedClass;
}
use of org.eclipse.persistence.internal.oxm.mappings.DirectMapping in project eclipselink by eclipse-ee4j.
the class MappingsGenerator method generateDescriptorForJAXBElementSubclass.
public void generateDescriptorForJAXBElementSubclass(JavaClass javaClass, CoreProject project, NamespaceResolver nsr) {
String jClassName = javaClass.getQualifiedName();
TypeInfo info = typeInfo.get(jClassName);
Descriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClassName(jClassName);
String[] factoryMethodParamTypes = info.getFactoryMethodParamTypes();
MultiArgInstantiationPolicy policy = new MultiArgInstantiationPolicy();
policy.useFactoryInstantiationPolicy(info.getObjectFactoryClassName(), info.getFactoryMethodName());
policy.setParameterTypeNames(factoryMethodParamTypes);
policy.setDefaultValues(new String[] { null });
xmlDescriptor.setInstantiationPolicy(policy);
JavaClass paramClass = helper.getJavaClass(factoryMethodParamTypes[0]);
boolean isObject = paramClass.getName().equals("java.lang.Object");
if (helper.isBuiltInJavaType(paramClass) && !isObject) {
if (isBinaryData(paramClass)) {
BinaryDataMapping mapping = new XMLBinaryDataMapping();
mapping.setAttributeName("value");
mapping.setXPath(".");
((Field) mapping.getField()).setSchemaType(Constants.BASE_64_BINARY_QNAME);
mapping.setSetMethodName("setValue");
mapping.setGetMethodName("getValue");
Class<?> attributeClassification = org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(factoryMethodParamTypes[0], helper.getClassLoader());
mapping.setAttributeClassification(attributeClassification);
mapping.getNullPolicy().setNullRepresentedByEmptyNode(false);
mapping.setShouldInlineBinaryData(false);
if (mapping.getMimeType() == null) {
if (areEquals(paramClass, javax.xml.transform.Source.class)) {
mapping.setMimeTypePolicy(new FixedMimeTypePolicy("application/xml"));
} else {
mapping.setMimeTypePolicy(new FixedMimeTypePolicy("application/octet-stream"));
}
}
xmlDescriptor.addMapping((CoreMapping) mapping);
} else {
DirectMapping mapping = new XMLDirectMapping();
mapping.setNullValueMarshalled(true);
mapping.setAttributeName("value");
mapping.setGetMethodName("getValue");
mapping.setSetMethodName("setValue");
mapping.setXPath("text()");
Class<?> attributeClassification = org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(factoryMethodParamTypes[0], helper.getClassLoader());
mapping.setAttributeClassification(attributeClassification);
xmlDescriptor.addMapping((CoreMapping) mapping);
}
} else if (paramClass.isEnum()) {
EnumTypeInfo enumInfo = (EnumTypeInfo) typeInfo.get(paramClass.getQualifiedName());
DirectMapping mapping = new XMLDirectMapping();
mapping.setConverter(buildJAXBEnumTypeConverter(mapping, enumInfo));
mapping.setNullValueMarshalled(true);
mapping.setAttributeName("value");
mapping.setGetMethodName("getValue");
mapping.setSetMethodName("setValue");
mapping.setXPath("text()");
Class<?> attributeClassification = org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(factoryMethodParamTypes[0], helper.getClassLoader());
mapping.setAttributeClassification(attributeClassification);
xmlDescriptor.addMapping((CoreMapping) mapping);
} else {
CompositeObjectMapping mapping = new XMLCompositeObjectMapping();
mapping.setAttributeName("value");
mapping.setGetMethodName("getValue");
mapping.setSetMethodName("setValue");
mapping.setXPath(".");
if (isObject) {
mapping.setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
} else {
mapping.setReferenceClassName(factoryMethodParamTypes[0]);
}
xmlDescriptor.addMapping((CoreMapping) mapping);
}
xmlDescriptor.setNamespaceResolver(nsr);
setSchemaContext(xmlDescriptor, info);
project.addDescriptor((CoreDescriptor) xmlDescriptor);
info.setDescriptor(xmlDescriptor);
}
Aggregations