Search in sources :

Example 1 with DeserializerImpl

use of org.apache.axis.encoding.DeserializerImpl in project Lucee by lucee.

the class BeanDeserializer method getDeserializer.

/**
 * Get the Deserializer for the attribute or child element.
 * @param xmlType QName of the attribute/child element or null if not known.
 * @param javaType Class of the corresponding property
 * @param href String is the value of the href attribute, which is used
 *             to determine whether the child element is complete or an
 *             href to another element.
 * @param context DeserializationContext
 * @return Deserializer or null if not found.
 */
protected Deserializer getDeserializer(QName xmlType, Class javaType, String href, DeserializationContext context) {
    if (javaType.isArray()) {
        context.setDestinationClass(javaType);
    }
    // See if we have a cached deserializer
    if (cacheStringDSer != null) {
        if (String.class.equals(javaType) && href == null && (cacheXMLType == null && xmlType == null || cacheXMLType != null && cacheXMLType.equals(xmlType))) {
            cacheStringDSer.reset();
            return cacheStringDSer;
        }
    }
    Deserializer dSer = null;
    if (xmlType != null && href == null) {
        // Use the xmlType to get the deserializer.
        dSer = context.getDeserializerForType(xmlType);
    } else {
        // If the xmlType is not set, get a default xmlType
        TypeMapping tm = context.getTypeMapping();
        QName defaultXMLType = tm.getTypeQName(javaType);
        // not have an xsi:type.
        if (href == null) {
            dSer = context.getDeserializer(javaType, defaultXMLType);
        } else {
            dSer = new DeserializerImpl();
            context.setDestinationClass(javaType);
            dSer.setDefaultType(defaultXMLType);
        }
    }
    if (javaType.equals(String.class) && dSer instanceof SimpleDeserializer) {
        cacheStringDSer = (SimpleDeserializer) dSer;
        cacheXMLType = xmlType;
    }
    return dSer;
}
Also used : Deserializer(org.apache.axis.encoding.Deserializer) QName(javax.xml.namespace.QName) DeserializerImpl(org.apache.axis.encoding.DeserializerImpl) TypeMapping(org.apache.axis.encoding.TypeMapping)

Aggregations

QName (javax.xml.namespace.QName)1 Deserializer (org.apache.axis.encoding.Deserializer)1 DeserializerImpl (org.apache.axis.encoding.DeserializerImpl)1 TypeMapping (org.apache.axis.encoding.TypeMapping)1