Examples of DirectCollectionMapping


Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

                    ((CompositeCollectionMapping)nestedMapping).setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
                    nullPolicy = ((CompositeCollectionMapping)nestedMapping).getNullPolicy();
                }

                if (nestedMapping.isAbstractCompositeDirectCollectionMapping()) {
                    DirectCollectionMapping nestedCompositeDirectCollectionMapping = (DirectCollectionMapping) nestedMapping;
                    nullPolicy = nestedCompositeDirectCollectionMapping.getNullPolicy();
                    if(pType.isEnum()) {
                        TypeInfo enumTypeInfo = typeInfo.get(pType.getQualifiedName());
                        nestedCompositeDirectCollectionMapping.setValueConverter(buildJAXBEnumTypeConverter(nestedCompositeDirectCollectionMapping, (EnumTypeInfo) enumTypeInfo));
                    }
                    if(element.isList()){
                        XMLListConverter listConverter = new XMLListConverter();
                        listConverter.setObjectClassName(element.getJavaType().getQualifiedName());
                        ((DirectCollectionMapping)nestedMapping).setValueConverter(listConverter);
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

        return generateDirectCollectionMapping(property, descriptor, namespaceInfo);
    }

    public DirectCollectionMapping generateEnumCollectionMapping(Property property, Descriptor descriptor, NamespaceInfo namespaceInfo, EnumTypeInfo info) {
     
      DirectCollectionMapping mapping = generateDirectCollectionMapping(property, descriptor, namespaceInfo);
      mapping.setValueConverter(buildJAXBEnumTypeConverter(mapping, info));
      return mapping;
    }
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

          
        return mapping;
    }

    public DirectCollectionMapping generateDirectCollectionMapping(Property property, Descriptor descriptor, NamespaceInfo namespaceInfo) {
        DirectCollectionMapping mapping = new XMLCompositeDirectCollectionMapping();
        mapping.setAttributeName(property.getPropertyName());
        initializeXMLContainerMapping(mapping, property.getType().isArray());
        // handle read-only set via metadata
        if (property.isSetReadOnly()) {
            mapping.setIsReadOnly(property.isReadOnly());
        }
        // handle write-only set via metadata
        if (property.isSetWriteOnly()) {
            mapping.setIsWriteOnly(property.isWriteOnly());
        }
        if (property.isMethodProperty()) {
            if (property.getGetMethodName() == null) {
                // handle case of set with no get method
                String paramTypeAsString = property.getType().getName();
                mapping.setAttributeAccessor(new JAXBSetMethodAttributeAccessor(paramTypeAsString, helper.getClassLoader()));
                mapping.setIsReadOnly(true);
                mapping.setSetMethodName(property.getSetMethodName());
            } else if (property.getSetMethodName() == null) {
                mapping.setGetMethodName(property.getGetMethodName());
                mapping.setIsWriteOnly(true);
            } else {
                mapping.setSetMethodName(property.getSetMethodName());
                mapping.setGetMethodName(property.getGetMethodName());
            }
        }
        JavaClass collectionType = property.getType();

        if (collectionType.isArray()){
            JAXBArrayAttributeAccessor accessor = new JAXBArrayAttributeAccessor(mapping.getAttributeAccessor(), mapping.getContainerPolicy(), helper.getClassLoader());
            String componentClassName = collectionType.getComponentType().getQualifiedName();
            if (collectionType.getComponentType().isPrimitive()){
                Class primitiveClass = XMLConversionManager.getDefaultManager().convertClassNameToClass(componentClassName);
                accessor.setComponentClass(primitiveClass);
                mapping.setAttributeAccessor(accessor);

                Class declaredClass = XMLConversionManager.getDefaultManager().getObjectClass(primitiveClass);
                mapping.setAttributeElementClass(declaredClass);
            } else {
                accessor.setComponentClassName(componentClassName);
                mapping.setAttributeAccessor(accessor);

                JavaClass componentType = collectionType.getComponentType();
                try{
                    Class declaredClass = PrivilegedAccessHelper.getClassForName(componentType.getRawName(), false, helper.getClassLoader());
                    mapping.setAttributeElementClass(declaredClass);
                }catch (Exception e) {}
            }
        } else if (helper.isCollectionType(collectionType)){
            Collection args = collectionType.getActualTypeArguments();
          if (args.size() >0){
            JavaClass itemType = (JavaClass)args.iterator().next();
            try {
              Class declaredClass = PrivilegedAccessHelper.getClassForName(itemType.getRawName(), false, helper.getClassLoader());
              if(declaredClass != String.class){
                  mapping.setAttributeElementClass(declaredClass);
              }
            } catch (Exception e) {}
          }
        }
        collectionType = containerClassImpl(collectionType);
        mapping.useCollectionClassName(collectionType.getRawName());

        // if the XPath is set (via xml-path) use it; otherwise figure it out
        Field xmlField = getXPathForField(property, namespaceInfo, true, false);
        mapping.setField(xmlField);

        if (helper.isAnnotationPresent(property.getElement(), XmlMixed.class)) {
            xmlField.setXPath("text()");
        }

        if (Constants.QNAME_QNAME.equals(property.getSchemaType())){
            ((Field) mapping.getField()).setSchemaType(Constants.QNAME_QNAME);
        }

        // handle null policy set via xml metadata
        if (property.isSetNullPolicy()) {
            mapping.setNullPolicy(getNullPolicyFromProperty(property, namespaceInfo.getNamespaceResolverForDescriptor()));
        } else if (property.isNillable()){
            mapping.getNullPolicy().setNullRepresentedByXsiNil(true);
            mapping.getNullPolicy().setMarshalNullRepresentation(XMLNullRepresentationType.XSI_NIL);
        }
        mapping.getNullPolicy().setNullRepresentedByEmptyNode(false);

        if (property.isSetXmlElementWrapper()) {
            mapping.setWrapperNullPolicy(getWrapperNullPolicyFromProperty(property));
        }

        if (property.isRequired()) {
            ((Field) mapping.getField()).setRequired(true);
        }

        if (property.isXmlElementType() && property.getGenericType()!=null ){
          Class theClass = helper.getClassForJavaClass(property.getGenericType());
          mapping.setAttributeElementClass(theClass);
        }

        if (xmlField.getXPathFragment().isAttribute() || property.isXmlList() || xmlField.getXPathFragment().nameIsText()){
            mapping.setUsesSingleNode(true);
        }
        // handle cdata set via metadata
        if (property.isSetCdata()) {
            mapping.setIsCDATA(property.isCdata());
        }
        return mapping;
    }
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

            desc = new XMLDescriptor();
            desc.setJavaClass(generatedClass);


            if(nextElement.isList()){
                DirectCollectionMapping 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 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 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 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, getClass().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 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, getClass().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);
                }
            }
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

                    ((CompositeCollectionMapping)nestedMapping).setKeepAsElementPolicy(UnmarshalKeepAsElementPolicy.KEEP_UNKNOWN_AS_ELEMENT);
                    nullPolicy = ((CompositeCollectionMapping)nestedMapping).getNullPolicy();
                }

                if (nestedMapping.isAbstractCompositeDirectCollectionMapping()) {
                    DirectCollectionMapping nestedCompositeDirectCollectionMapping = (DirectCollectionMapping) nestedMapping;
                    nullPolicy = nestedCompositeDirectCollectionMapping.getNullPolicy();
                    if(pType.isEnum()) {
                        TypeInfo enumTypeInfo = typeInfo.get(pType.getQualifiedName());
                        nestedCompositeDirectCollectionMapping.setValueConverter(buildJAXBEnumTypeConverter(nestedCompositeDirectCollectionMapping, (EnumTypeInfo) enumTypeInfo));
                    }
                    if(element.isList()){
                        XMLListConverter listConverter = new XMLListConverter();
                        listConverter.setObjectClassName(pType.getQualifiedName());
                        ((DirectCollectionMapping)nestedMapping).setValueConverter(listConverter);
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

        return generateDirectCollectionMapping(property, descriptor, namespaceInfo);
    }

    public DirectCollectionMapping generateEnumCollectionMapping(Property property, Descriptor descriptor, NamespaceInfo namespaceInfo, EnumTypeInfo info) {
     
      DirectCollectionMapping mapping = generateDirectCollectionMapping(property, descriptor, namespaceInfo);
      mapping.setValueConverter(buildJAXBEnumTypeConverter(mapping, info));
      return mapping;
    }
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

          
        return mapping;
    }

    public DirectCollectionMapping generateDirectCollectionMapping(Property property, Descriptor descriptor, NamespaceInfo namespaceInfo) {
        DirectCollectionMapping mapping = new XMLCompositeDirectCollectionMapping();
        initializeXMLMapping((XMLMapping)mapping, property);

        initializeXMLContainerMapping(mapping, property.getType().isArray());
    
        JavaClass collectionType = property.getType();

        if (collectionType.isArray()){
            JAXBArrayAttributeAccessor accessor = new JAXBArrayAttributeAccessor(mapping.getAttributeAccessor(), mapping.getContainerPolicy(), helper.getClassLoader());
            String componentClassName = collectionType.getComponentType().getQualifiedName();
            if (collectionType.getComponentType().isPrimitive()){
                Class primitiveClass = XMLConversionManager.getDefaultManager().convertClassNameToClass(componentClassName);
                accessor.setComponentClass(primitiveClass);
                mapping.setAttributeAccessor(accessor);

                Class declaredClass = XMLConversionManager.getDefaultManager().getObjectClass(primitiveClass);
                mapping.setAttributeElementClass(declaredClass);
            } else {
                accessor.setComponentClassName(componentClassName);
                mapping.setAttributeAccessor(accessor);

                JavaClass componentType = collectionType.getComponentType();
                try{
                    Class declaredClass = PrivilegedAccessHelper.getClassForName(componentType.getRawName(), false, helper.getClassLoader());
                    mapping.setAttributeElementClass(declaredClass);
                }catch (Exception e) {}
            }
        } else if (helper.isCollectionType(collectionType)){
            Collection args = collectionType.getActualTypeArguments();
          if (args.size() >0){
            JavaClass itemType = (JavaClass)args.iterator().next();
            try {
              Class declaredClass = PrivilegedAccessHelper.getClassForName(itemType.getRawName(), false, helper.getClassLoader());
              if(declaredClass != String.class){
                  mapping.setAttributeElementClass(declaredClass);
              }
            } catch (Exception e) {}
          }
        }
        collectionType = containerClassImpl(collectionType);
        mapping.useCollectionClassName(collectionType.getRawName());

        if (property.getDefaultValue() != null) {
            mapping.setNullValue(property.getDefaultValue());
        }
       
        // if the XPath is set (via xml-path) use it; otherwise figure it out
        Field xmlField = getXPathForField(property, namespaceInfo, true, false);
        mapping.setField(xmlField);

        if (helper.isAnnotationPresent(property.getElement(), XmlMixed.class)) {
            xmlField.setXPath("text()");
        }

        if (Constants.QNAME_QNAME.equals(property.getSchemaType())){
            ((Field) mapping.getField()).setSchemaType(Constants.QNAME_QNAME);
        }

        // handle null policy set via xml metadata
        if (property.isSetNullPolicy()) {
            mapping.setNullPolicy(getNullPolicyFromProperty(property, namespaceInfo.getNamespaceResolverForDescriptor()));
        } else if (property.isNillable()){
            mapping.getNullPolicy().setNullRepresentedByXsiNil(true);
            mapping.getNullPolicy().setMarshalNullRepresentation(XMLNullRepresentationType.XSI_NIL);
        }
        mapping.getNullPolicy().setNullRepresentedByEmptyNode(false);

        if (property.isSetXmlElementWrapper()) {
            mapping.setWrapperNullPolicy(getWrapperNullPolicyFromProperty(property));
        }

        if (property.isRequired()) {
            ((Field) mapping.getField()).setRequired(true);
        }

        if (property.isXmlElementType() && property.getGenericType()!=null ){
          Class theClass = org.eclipse.persistence.internal.helper.Helper.getClassFromClasseName(property.getGenericType().getQualifiedName(), helper.getClassLoader());
          mapping.setAttributeElementClass(theClass);
        }

        if (xmlField.getXPathFragment().isAttribute() || property.isXmlList() || xmlField.getXPathFragment().nameIsText()){
            mapping.setUsesSingleNode(true);
        }
        // handle cdata set via metadata
        if (property.isSetCdata()) {
            mapping.setIsCDATA(property.isCdata());
        }
        return mapping;
    }
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

            desc = new XMLDescriptor();
            desc.setJavaClass(generatedClass);


            if(nextElement.isList()){
                DirectCollectionMapping 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 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 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 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, getClass().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 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, getClass().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);
                }
            }
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

                XPathFragment frag = ((XMLField)directMapping.getField()).getXPathFragment();
                if(frag.nameIsText()) {
                    return getJsonTypeForJavaType(directMapping.getAttributeClassification());
                }
            } else if(mapping instanceof DirectCollectionMapping) {
                DirectCollectionMapping directMapping = (DirectCollectionMapping)mapping;
                XPathFragment frag = ((XMLField)directMapping.getField()).getXPathFragment();
                if(frag.nameIsText()) {
                    return getJsonTypeForJavaType(directMapping.getAttributeElementClass());
                }
            }
        }
        for(DatabaseMapping next:mappings) {
            if(next instanceof ChoiceObjectMapping) {
View Full Code Here

Examples of org.eclipse.persistence.internal.oxm.mappings.DirectCollectionMapping

                nestedProperty.setType(JsonType.ARRAY);
                nestedProperty.setItem(new Property());
                nestedProperty.getItem().setRef(getReferenceForDescriptor((XMLDescriptor)mapping.getReferenceDescriptor()));
                //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) {
                    JAXBEnumTypeConverter conv = (JAXBEnumTypeConverter)mapping.getValueConverter();
                    enumeration = new ArrayList<String>();
                    for(Object nextValue: conv.getAttributeToFieldValues().values()) {
                        enumeration.add(nextValue.toString());
                    }
                }
                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);
                }
                nestedProperty.getItem().setType(getJsonTypeForJavaType(mapping.getAttributeElementClass()));
                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.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(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) {
                    JAXBEnumTypeConverter conv = (JAXBEnumTypeConverter)directMapping.getConverter();
                    enumeration = new ArrayList<String>();
                    for(Object nextValue: conv.getAttributeToFieldValues().values()) {
                        enumeration.add(nextValue.toString());
                    }
                }               
                String propertyName = getNameForFragment(frag);
                if(frag.nameIsText()) {
                    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(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 = 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 null;               
            } else if(next.isAbstractCompositeObjectMapping()) {
                CompositeObjectMapping mapping = (CompositeObjectMapping)next;
                XMLDescriptor nextDescriptor = (XMLDescriptor)mapping.getReferenceDescriptor();
                XMLField field = (XMLField)mapping.getField();
                XPathFragment firstFragment = field.getXPathFragment();
                String propName = getNameForFragment(firstFragment);
                prop = properties.get(propName);
                if(prop == null) {
                    prop = new Property();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.