Example usage for javax.xml.namespace QName equals

List of usage examples for javax.xml.namespace QName equals

Introduction

In this page you can find the example usage for javax.xml.namespace QName equals.

Prototype

public final boolean equals(Object objectToTest) 

Source Link

Document

Test this QName for equality with another Object.

If the Object to be tested is not a QName or is null, then this method returns false.

Two QNames are considered equal if and only if both the Namespace URI and local part are equal.

Usage

From source file:org.apache.axis.description.OperationDesc.java

public ParameterDesc getOutputParamByQName(QName qname) {
    ParameterDesc param = null;//from   ww  w. j av  a  2s  .co  m

    for (Iterator i = parameters.iterator(); i.hasNext();) {
        ParameterDesc pnext = (ParameterDesc) i.next();
        if (pnext.getQName().equals(qname) && pnext.getMode() != ParameterDesc.IN) {
            param = pnext;
            break;
        }
    }

    if (param == null) {
        if (null == returnDesc.getQName()) {
            param = new ParameterDesc(returnDesc); //Create copy
            param.setQName(qname);
        } else if (qname.equals(returnDesc.getQName())) {
            param = returnDesc;
        }
    }

    return param;
}

From source file:org.apache.axis.description.OperationDesc.java

/**
 * Returns the FaultDesc for a QName (which is typically found
 * in the details element of a SOAP fault).
 * Returns null if not found./* ww  w .jav  a  2 s .c  om*/
 */
public FaultDesc getFaultByQName(QName qname) {
    if (faults != null) {
        for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
            FaultDesc desc = (FaultDesc) iterator.next();
            if (qname.equals(desc.getQName())) {
                return desc;
            }
        }
    }
    return null;
}

From source file:org.apache.axis.description.OperationDesc.java

/**
* Returns the FaultDesc for an XMLType. 
* Returns null if not found.//from  w  w  w .  j  a v a 2  s  . c o m
*/
public FaultDesc getFaultByXmlType(QName xmlType) {
    if (faults != null) {
        for (Iterator iterator = faults.iterator(); iterator.hasNext();) {
            FaultDesc desc = (FaultDesc) iterator.next();
            if (xmlType.equals(desc.getXmlType())) {
                return desc;
            }
        }
    }
    return null;
}

From source file:org.apache.axis.description.TypeDesc.java

/**
 * Get the field name associated with this QName, but only if it's
 * marked as an attribute.//  w w w.ja  v  a2s .c  om
 */
public String getFieldNameForAttribute(QName qname) {
    String possibleMatch = null;

    for (int i = 0; fields != null && i < fields.length; i++) {
        FieldDesc field = fields[i];
        if (!field.isElement()) {
            // It's an attribute, so if we have a solid match, return
            // its name.
            if (qname.equals(field.getXmlName())) {
                return field.getFieldName();
            }
            // Not a solid match, but it's still possible we might match
            // the default (i.e. QName("", fieldName))
            if (qname.getNamespaceURI().equals("") && qname.getLocalPart().equals(field.getFieldName())) {
                possibleMatch = field.getFieldName();
            }
        }
    }

    if (possibleMatch == null && canSearchParents) {
        // check superclasses if they exist
        // and we are allowed to look
        if (parentDesc != null) {
            possibleMatch = parentDesc.getFieldNameForAttribute(qname);
        }
    }

    return possibleMatch;
}

From source file:org.apache.axis.encoding.ser.ArraySerializer.java

/**
 * Serialize an element that is an array.
 * @param name is the element name/*from  w  w w . java2 s . com*/
 * @param attributes are the attributes...serialize is free to add more.
 * @param value is the value
 * @param context is the SerializationContext
 */
public void serialize(QName name, Attributes attributes, Object value, SerializationContext context)
        throws IOException {
    if (value == null)
        throw new IOException(Messages.getMessage("cantDoNullArray00"));

    MessageContext msgContext = context.getMessageContext();
    SchemaVersion schema = SchemaVersion.SCHEMA_2001;
    SOAPConstants soap = SOAPConstants.SOAP11_CONSTANTS;
    boolean encoded = context.isEncoded();

    if (msgContext != null) {
        schema = msgContext.getSchemaVersion();
        soap = msgContext.getSOAPConstants();
    }

    Class cls = value.getClass();
    Collection list = null;

    if (!cls.isArray()) {
        if (!(value instanceof Collection)) {
            throw new IOException(Messages.getMessage("cantSerialize00", cls.getName()));
        }
        list = (Collection) value;
    }

    // Get the componentType of the array/list
    Class componentClass;
    if (list == null) {
        componentClass = cls.getComponentType();
    } else {
        componentClass = Object.class;
    }

    // Get the QName of the componentType
    // if it wasn't passed in from the constructor
    QName componentTypeQName = this.componentType;

    // Check to see if componentType is also an array.
    // If so, set the componentType to the most nested non-array
    // componentType.  Increase the dims string by "[]"
    // each time through the loop.
    // Note from Rich Scheuerle:
    //    This won't handle Lists of Lists or
    //    arrays of Lists....only arrays of arrays.
    String dims = "";

    if (componentTypeQName != null) {
        // if we have a Type QName at this point,
        // this is because ArraySerializer has been instanciated with it
        TypeMapping tm = context.getTypeMapping();
        SerializerFactory factory = (SerializerFactory) tm.getSerializer(componentClass, componentTypeQName);
        while (componentClass.isArray() && factory instanceof ArraySerializerFactory) {
            ArraySerializerFactory asf = (ArraySerializerFactory) factory;
            componentClass = componentClass.getComponentType();
            QName componentType = null;
            if (asf.getComponentType() != null) {
                componentType = asf.getComponentType();
                if (encoded) {
                    componentTypeQName = componentType;
                }
            }
            // update factory with the new values
            factory = (SerializerFactory) tm.getSerializer(componentClass, componentType);
            if (soap == SOAPConstants.SOAP12_CONSTANTS)
                dims += "* ";
            else
                dims += "[]";
        }
    } else {
        // compatibility mode
        while (componentClass.isArray()) {
            componentClass = componentClass.getComponentType();
            if (soap == SOAPConstants.SOAP12_CONSTANTS)
                dims += "* ";
            else
                dims += "[]";
        }
    }

    // Try the current XML type from the context
    if (componentTypeQName == null) {
        componentTypeQName = context.getCurrentXMLType();
        if (componentTypeQName != null) {
            if ((componentTypeQName.equals(xmlType) || componentTypeQName.equals(Constants.XSD_ANYTYPE)
                    || componentTypeQName.equals(soap.getArrayType()))) {
                componentTypeQName = null;
            }
        }
    }

    if (componentTypeQName == null) {
        componentTypeQName = context.getItemType();
    }

    // Then check the type mapping for the class
    if (componentTypeQName == null) {
        componentTypeQName = context.getQNameForClass(componentClass);
    }

    // If still not found, look at the super classes
    if (componentTypeQName == null) {
        Class searchCls = componentClass;
        while (searchCls != null && componentTypeQName == null) {
            searchCls = searchCls.getSuperclass();
            componentTypeQName = context.getQNameForClass(searchCls);
        }
        if (componentTypeQName != null) {
            componentClass = searchCls;
        }
    }

    // Still can't find it?  Throw an error.
    if (componentTypeQName == null) {
        throw new IOException(Messages.getMessage("noType00", componentClass.getName()));
    }

    int len = (list == null) ? Array.getLength(value) : list.size();
    String arrayType = "";
    int dim2Len = -1;
    if (encoded) {
        if (soap == SOAPConstants.SOAP12_CONSTANTS) {
            arrayType = dims + len;
        } else {
            arrayType = dims + "[" + len + "]";
        }

        // Discover whether array can be serialized directly as a two-dimensional
        // array (i.e. arrayType=int[2,3]) versus an array of arrays.
        // Benefits:
        //   - Less text passed on the wire.
        //   - Easier to read wire format
        //   - Tests the deserialization of multi-dimensional arrays.
        // Drawbacks:
        //   - Is not safe!  It is possible that the arrays are multiply
        //     referenced.  Transforming into a 2-dim array will cause the
        //     multi-referenced information to be lost.  Plus there is no
        //     way to determine whether the arrays are multi-referenced.
        //   - .NET currently (Dec 2002) does not support 2D SOAP-encoded arrays
        //
        // OLD Comment as to why this was ENABLED:
        // It is necessary for
        // interoperability (echo2DStringArray).  It is 'safe' for now
        // because Axis treats arrays as non multi-ref (see the note
        // in SerializationContext.isPrimitive(...) )
        // More complicated processing is necessary for 3-dim arrays, etc.
        //
        // Axis 1.1 - December 2002
        // Turned this OFF because Microsoft .NET can not deserialize
        // multi-dimensional SOAP-encoded arrays, and this interopability
        // is pretty high visibility. Make it a global configuration parameter:
        //  <parameter name="enable2DArrayEncoding" value="true"/>    (tomj)
        //

        // Check the message context to see if we should turn 2D processing ON
        // Default is OFF
        boolean enable2Dim = false;

        // Vidyanand : added this check
        if (msgContext != null) {
            enable2Dim = JavaUtils
                    .isTrueExplicitly(msgContext.getProperty(AxisEngine.PROP_TWOD_ARRAY_ENCODING));
        }

        if (enable2Dim && !dims.equals("")) {
            if (cls.isArray() && len > 0) {
                boolean okay = true;
                // Make sure all of the component arrays are the same size
                for (int i = 0; i < len && okay; i++) {

                    Object elementValue = Array.get(value, i);
                    if (elementValue == null)
                        okay = false;
                    else if (dim2Len < 0) {
                        dim2Len = Array.getLength(elementValue);
                        if (dim2Len <= 0) {
                            okay = false;
                        }
                    } else if (dim2Len != Array.getLength(elementValue)) {
                        okay = false;
                    }
                }
                // Update the arrayType to use mult-dim array encoding
                if (okay) {
                    dims = dims.substring(0, dims.length() - 2);
                    if (soap == SOAPConstants.SOAP12_CONSTANTS)
                        arrayType = dims + len + " " + dim2Len;
                    else
                        arrayType = dims + "[" + len + "," + dim2Len + "]";
                } else {
                    dim2Len = -1;
                }
            }
        }
    }

    // Need to distinguish if this is array processing for an
    // actual schema array or for a maxOccurs usage.
    // For the maxOccurs case, the currentXMLType of the context is
    // the same as the componentTypeQName.
    QName itemQName = context.getItemQName();
    boolean maxOccursUsage = !encoded && itemQName == null
            && componentTypeQName.equals(context.getCurrentXMLType());

    if (encoded) {
        AttributesImpl attrs;
        if (attributes == null) {
            attrs = new AttributesImpl();
        } else if (attributes instanceof AttributesImpl) {
            attrs = (AttributesImpl) attributes;
        } else {
            attrs = new AttributesImpl(attributes);
        }

        String compType = context.attributeQName2String(componentTypeQName);

        if (attrs.getIndex(soap.getEncodingURI(), soap.getAttrItemType()) == -1) {
            String encprefix = context.getPrefixForURI(soap.getEncodingURI());

            if (soap != SOAPConstants.SOAP12_CONSTANTS) {
                compType = compType + arrayType;

                attrs.addAttribute(soap.getEncodingURI(), soap.getAttrItemType(), encprefix + ":arrayType",
                        "CDATA", compType);

            } else {
                attrs.addAttribute(soap.getEncodingURI(), soap.getAttrItemType(), encprefix + ":itemType",
                        "CDATA", compType);

                attrs.addAttribute(soap.getEncodingURI(), "arraySize", encprefix + ":arraySize", "CDATA",
                        arrayType);
            }
        }

        // Force type to be SOAP_ARRAY for all array serialization.
        //
        // There are two choices here:
        // Force the type to type=SOAP_ARRAY
        //   Pros:  More interop test successes.
        //   Cons:  Since we have specific type information it
        //          is more correct to use it.  Plus the specific
        //          type information may be important on the
        //          server side to disambiguate overloaded operations.
        // Use the specific type information:
        //   Pros:  The specific type information is more correct
        //          and may be useful for operation overloading.
        //   Cons:  More interop test failures (as of 2/6/2002).
        //
        String qname = context.getPrefixForURI(schema.getXsiURI(), "xsi") + ":type";
        QName soapArray;
        if (soap == SOAPConstants.SOAP12_CONSTANTS) {
            soapArray = Constants.SOAP_ARRAY12;
        } else {
            soapArray = Constants.SOAP_ARRAY;
        }

        int typeI = attrs.getIndex(schema.getXsiURI(), "type");
        if (typeI != -1) {
            attrs.setAttribute(typeI, schema.getXsiURI(), "type", qname, "CDATA",
                    context.qName2String(soapArray));
        } else {
            attrs.addAttribute(schema.getXsiURI(), "type", qname, "CDATA", context.qName2String(soapArray));
        }

        attributes = attrs;
    }

    // For the maxOccurs case, each item is named with the QName
    // we got in the arguments.  For normal array case, we write an element with
    // that QName, and then serialize each item as <item>
    QName elementName = name;
    Attributes serializeAttr = attributes;
    if (!maxOccursUsage) {
        serializeAttr = null; // since we are putting them here
        context.startElement(name, attributes);
        if (itemQName != null)
            elementName = itemQName;
        else if (componentQName != null)
            elementName = componentQName;
    }

    if (dim2Len < 0) {
        // Normal case, serialize each array element
        if (list == null) {
            for (int index = 0; index < len; index++) {
                Object aValue = Array.get(value, index);

                // Serialize the element.
                context.serialize(elementName,
                        (serializeAttr == null ? serializeAttr : new AttributesImpl(serializeAttr)), aValue,
                        componentTypeQName, componentClass); // prefered type QName
            }
        } else {
            for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                Object aValue = iterator.next();

                // Serialize the element.
                context.serialize(elementName,
                        (serializeAttr == null ? serializeAttr : new AttributesImpl(serializeAttr)), aValue,
                        componentTypeQName, componentClass); // prefered type QName
            }
        }
    } else {
        // Serialize as a 2 dimensional array
        for (int index = 0; index < len; index++) {
            for (int index2 = 0; index2 < dim2Len; index2++) {
                Object aValue = Array.get(Array.get(value, index), index2);
                context.serialize(elementName, null, aValue, componentTypeQName, componentClass);
            }
        }
    }

    if (!maxOccursUsage)
        context.endElement();
}

From source file:org.apache.axis.encoding.ser.BeanSerializer.java

/**
 * Check for meta-data in the bean that will tell us if any of the
 * properties are actually attributes, add those to the element
 * attribute list//from w  ww . ja  v  a 2s.c om
 *
 * @param value the object we are serializing
 * @return attributes for this element, null if none
 */
protected Attributes getObjectAttributes(Object value, Attributes attributes, SerializationContext context) {

    if (typeDesc == null || !typeDesc.hasAttributes())
        return attributes;

    AttributesImpl attrs;
    if (attributes == null) {
        attrs = new AttributesImpl();
    } else if (attributes instanceof AttributesImpl) {
        attrs = (AttributesImpl) attributes;
    } else {
        attrs = new AttributesImpl(attributes);
    }

    try {
        // Find each property that is an attribute
        // and add it to our attribute list
        for (int i = 0; i < propertyDescriptor.length; i++) {
            String propName = propertyDescriptor[i].getName();
            if (propName.equals("class"))
                continue;

            FieldDesc field = typeDesc.getFieldByName(propName);
            // skip it if its not an attribute
            if (field == null || field.isElement())
                continue;

            QName qname = field.getXmlName();
            if (qname == null) {
                qname = new QName("", propName);
            }

            if (propertyDescriptor[i].isReadable() && !propertyDescriptor[i].isIndexed()) {
                // add to our attributes
                Object propValue = propertyDescriptor[i].get(value);
                // Convert true/false to 1/0 in case of soapenv:mustUnderstand
                if (qname.equals(MUST_UNDERSTAND_QNAME)) {
                    if (propValue.equals(Boolean.TRUE)) {
                        propValue = "1";
                    } else if (propValue.equals(Boolean.FALSE)) {
                        propValue = "0";
                    }
                }
                // If the property value does not exist, don't serialize
                // the attribute.  In the future, the decision to serializer
                // the attribute may be more sophisticated.  For example, don't
                // serialize if the attribute matches the default value.
                if (propValue != null) {
                    setAttributeProperty(propValue, qname, field.getXmlType(), field.getJavaType(), attrs,
                            context);
                }
            }
        }
    } catch (Exception e) {
        // no attributes
        return attrs;
    }

    return attrs;
}

From source file:org.apache.axis.encoding.SerializationContext.java

/**
 * Invoked to do the actual serialization of the qName (called by serialize above).
 * additional attributes that will be serialized with the qName.
 * @param elemQName is the QName of the element
 * @param attributes are additional attributes
 * @param value is the object to serialize
 * @param xmlType (optional) is the desired type QName.
 * @param sendType indicates whether the xsi:type attribute should be set.
 *//*  www  .java2  s  . c  o m*/
private void serializeActual(QName elemQName, Attributes attributes, Object value, QName xmlType,
        Class javaClass, Boolean sendType) throws IOException {
    boolean shouldSendType = (sendType == null) ? shouldSendXSIType() : sendType.booleanValue();

    if (value != null) {
        TypeMapping tm = getTypeMapping();

        if (tm == null) {
            throw new IOException(Messages.getMessage("noSerializer00", value.getClass().getName(), "" + this));
        }

        // Set currentXMLType to the one desired one.
        // Note for maxOccurs usage this xmlType is the
        // type of the component not the type of the array.
        currentXMLType = xmlType;

        // if we're looking for xsd:anyType, accept anything...
        if (Constants.equals(Constants.XSD_ANYTYPE, xmlType)) {
            xmlType = null;
            shouldSendType = true;
        }

        // Try getting a serializer for the prefered xmlType
        QNameHolder actualXMLType = new QNameHolder();

        Class javaType = getActualJavaClass(xmlType, javaClass, value);

        Serializer ser = getSerializer(javaType, xmlType, actualXMLType);

        if (ser != null) {
            // Send the xmlType if indicated or if
            // the actual xmlType is different than the
            // prefered xmlType
            if (shouldSendType || (xmlType != null && (!xmlType.equals(actualXMLType.value)))) {

                if (!isEncoded()) {
                    if (Constants.isSOAP_ENC(actualXMLType.value.getNamespaceURI())) {
                        // Don't write SOAP_ENC types (i.e. Array) if we're not using encoding
                    } else if (javaType.isPrimitive() && javaClass != null
                            && JavaUtils.getWrapperClass(javaType) == javaClass) {
                        // Don't write xsi:type when serializing primitive wrapper value as primitive type.
                    } else {
                        if (!(javaType.isArray() && xmlType != null
                                && Constants.isSchemaXSD(xmlType.getNamespaceURI()))) {
                            writeXMLType = actualXMLType.value;
                        }
                    }
                } else {
                    writeXMLType = actualXMLType.value;
                }
            }

            // -----------------
            // NOTE: I have seen doc/lit tests that use
            // the type name as the element name in multi-ref cases
            // (for example <soapenc:Array ... >)
            // In such cases the xsi:type is not passed along.
            // -----------------
            // The multiref QName is our own fake name.
            // It may be beneficial to set the name to the
            // type name, but I didn't see any improvements
            // in the interop tests.
            //if (name.equals(multirefQName) && type != null)
            //    name = type;
            ser.serialize(elemQName, attributes, value, this);
            return;
        }
        throw new IOException(Messages.getMessage("noSerializer00", value.getClass().getName(), "" + tm));
    }
    // !!! Write out a generic null, or get type info from somewhere else?
}

From source file:org.apache.axis.encoding.SerializationContextImpl.java

/**
 * Invoked to do the actual serialization of the qName (called by serialize above).
 * additional attributes that will be serialized with the qName.
 * @param elemQName is the QName of the element
 * @param attributes are additional attributes
 * @param value is the object to serialize
 * @param xmlType (optional) is the desired type QName.
 * @param sendType indicates whether the xsi:type attribute should be set.
 *//*from  w w  w . j  av a 2 s .c o m*/
private void serializeActual(QName elemQName,
                            Attributes attributes,
                            Object value,
                            QName xmlType,
                            Boolean sendType)
    throws IOException
{
    boolean shouldSendType = (sendType == null) ? shouldSendXSIType() :
        sendType.booleanValue();

    if (value != null) {
        Class javaType = value.getClass();
        TypeMapping tm = getTypeMapping();

        if (tm == null) {
            throw new IOException(
                    Messages.getMessage("noSerializer00",
                                         value.getClass().getName(),
                                         "" + this));
        }

        // Set currentXMLType to the one desired one.
        // Note for maxOccurs usage this xmlType is the
        // type of the component not the type of the array.
        currentXMLType = xmlType;

        // if we're looking for xsd:anyType, accept anything...
        if (Constants.equals(Constants.XSD_ANYTYPE,xmlType)){
            xmlType = null;
            shouldSendType = true;
        }

        // Try getting a serializer for the prefered xmlType
        QNameHolder actualXMLType = new QNameHolder();
        Serializer ser = getSerializer(javaType, xmlType,
                                       actualXMLType);

        if ( ser != null ) {
            // Send the xmlType if indicated or if
            // the actual xmlType is different than the
            // prefered xmlType
            if (shouldSendType ||
                (xmlType != null &&
                 (!xmlType.equals(actualXMLType.value)))) {
                attributes = setTypeAttribute(attributes,
                                              actualXMLType.value);
            }

            // -----------------
            // NOTE: I have seen doc/lit tests that use
            // the type name as the element name in multi-ref cases
            // (for example <soapenc:Array ... >)
            // In such cases the xsi:type is not passed along.
            // -----------------
            // The multiref QName is our own fake name.
            // It may be beneficial to set the name to the
            // type name, but I didn't see any improvements
            // in the interop tests.
            //if (name.equals(multirefQName) && type != null)
            //    name = type;
            ser.serialize(elemQName, attributes, value, this);
            return;
        }

        // if no serializer was configured try to find one dynamically using WSDLJava
        // generated metadata
        try {
            Method method = value.getClass().getMethod(
                    "getSerializer", getSerializerClasses);
            if (method != null) {
                Serializer serializer = (Serializer) method.invoke(value,
                        new Object[] {"", value.getClass(), elemQName});
                TypeDesc typedesc = TypeDesc.getTypeDescForClass(value.getClass());
                if (typedesc != null) {
                    QName qname = typedesc.getXmlType();
                    if (qname != null) {
                        attributes = setTypeAttribute(attributes,
                                                      qname);
                    }
                }
                serializer.serialize(elemQName, attributes, value, this);
                return;
            }
        } catch (Exception e) {
        }

        throw new IOException(Messages.getMessage("noSerializer00",
                value.getClass().getName(), "" + tm));
    }
    // !!! Write out a generic null, or get type info from somewhere else?
}

From source file:org.apache.axis.encoding.TypeMappingImpl.java

public QName getTypeQName(Class javaType, TypeMappingDelegate next) {
    QName xmlType = getTypeQNameExact(javaType, next);

    /* If auto-typing is on and the array has the default SOAP_ARRAY QName,
     * then generate a namespace for this array intelligently.   Also
     * register it's javaType and xmlType. List classes and derivitives
     * can't be used because they should be serialized as an anyType array.
     *//*from w  w  w  .  j a v a  2 s.  c om*/
    if (shouldDoAutoTypes() && javaType != List.class && !List.class.isAssignableFrom(javaType)
            && xmlType != null && xmlType.equals(Constants.SOAP_ARRAY)) {
        xmlType = new QName(Namespaces.makeNamespace(javaType.getName()),
                Types.getLocalNameFromFullName(javaType.getName()));

        internalRegister(javaType, xmlType, new ArraySerializerFactory(), new ArrayDeserializerFactory());
    }

    // Can only detect arrays via code
    if (xmlType == null && isArray(javaType)) {

        // get the registered array if any
        Pair pair = (Pair) class2Pair.get(Object[].class);
        // TODO: it always returns the last registered one,
        //  so that's why the soap 1.2 typemappings have to 
        //  move to an other registry to differentiate them
        if (pair != null) {
            xmlType = pair.xmlType;
        } else {
            xmlType = Constants.SOAP_ARRAY;
        }
    }

    /* If the class isn't an array or List and auto-typing is turned on,
    * register the class and it's type as beans.
    */
    if (xmlType == null && shouldDoAutoTypes()) {
        xmlType = new QName(Namespaces.makeNamespace(javaType.getName()),
                Types.getLocalNameFromFullName(javaType.getName()));

        /* If doAutoTypes is set, register a new type mapping for the
        * java class with the above QName.  This way, when getSerializer()
        * and getDeserializer() are called, this QName is returned and
        * these methods do not need to worry about creating a serializer.
        */
        internalRegister(javaType, xmlType, new BeanSerializerFactory(javaType, xmlType),
                new BeanDeserializerFactory(javaType, xmlType));
    }

    //log.debug("getTypeQName xmlType =" + xmlType);
    return xmlType;
}

From source file:org.apache.axis.message.RPCHandler.java

/**
 * Register the start of a parameter (child element of the method call
 * element)./*from   w ww .j  a va2  s. c o m*/
 *
 * Our job here is to figure out a) which parameter this is (based on
 * the QName of the element or its position), and b) what type it is
 * (based on the xsi:type attribute or operation metadata) so we can
 * successfully deserialize it.
 */
public SOAPHandler onStartChild(String namespace, String localName, String prefix, Attributes attributes,
        DeserializationContext context) throws SAXException {
    if (log.isDebugEnabled()) {
        log.debug("Enter: RPCHandler.onStartChild()");
    }

    if (!context.isDoneParsing()) {
        try {
            context.pushNewElement(new MessageElement(namespace, localName, prefix, attributes, context));
        } catch (AxisFault axisFault) {
            throw new SAXException(axisFault);
        }
    }

    MessageElement curEl = context.getCurElement();
    QName type = null;
    QName qname = new QName(namespace, localName);
    ParameterDesc paramDesc = null;

    SOAPConstants soapConstants = context.getSOAPConstants();
    if (soapConstants == SOAPConstants.SOAP12_CONSTANTS && Constants.QNAME_RPC_RESULT.equals(qname)) {
        // TODO: fix it ... now we just skip it
        return new DeserializerImpl();
    }

    // Create a new param if not the same element
    if (currentParam == null || !currentParam.getQName().getNamespaceURI().equals(namespace)
            || !currentParam.getQName().getLocalPart().equals(localName)) {
        currentParam = new RPCParam(namespace, localName, null);
        rpcElem.addParam(currentParam);
    }

    // Grab xsi:type attribute if present, on either this element or
    // the referent (if it's an href).  MessageElement.getType() will
    // automatically dig through to the referent if necessary.
    type = curEl.getType();
    if (type == null) {
        type = context.getTypeFromAttributes(namespace, localName, attributes);
    }

    if (log.isDebugEnabled()) {
        log.debug(Messages.getMessage("typeFromAttr00", "" + type));
    }

    Class destClass = null;

    // If we have an operation descriptor, try to associate this parameter
    // with the appropriate ParameterDesc
    if (operation != null) {

        // Try by name first
        if (isResponse) {
            paramDesc = operation.getOutputParamByQName(qname);
        } else {
            paramDesc = operation.getInputParamByQName(qname);
        }

        // If that didn't work, try position
        // FIXME : Do we need to be in EITHER named OR positional
        //         mode?  I.e. will it screw us up to find something
        //         by position if we've already looked something up
        //         by name?  I think so...
        if (paramDesc == null) {
            if (isResponse) {
                paramDesc = operation.getReturnParamDesc();
            } else {
                paramDesc = operation.getParameter(rpcElem.getParams().size() - 1);
            }
        }

        if (paramDesc == null) {
            throw new SAXException(Messages.getMessage("noParmDesc"));
        }
        // Make sure that we don't find body parameters that should
        // be in the header
        if (!isHeaderElement
                && ((isResponse && paramDesc.isOutHeader()) || (!isResponse && paramDesc.isInHeader()))) {
            throw new SAXException(Messages.getMessage("expectedHeaderParam", paramDesc.getQName().toString()));
        }

        destClass = paramDesc.getJavaType();
        if ((destClass != null) && (destClass.isArray())) {
            context.setDestinationClass(destClass);
        }

        // Keep the association so we can use it later
        // (see RPCProvider.processMessage())
        currentParam.setParamDesc(paramDesc);

        if (type == null) {
            type = paramDesc.getTypeQName();
        }
    }

    if (type != null && type.equals(XMLType.AXIS_VOID)) {
        Deserializer nilDSer = new DeserializerImpl();
        return (SOAPHandler) nilDSer;
    }

    // If the nil attribute is set, just
    // return the base DeserializerImpl.
    // Register the value target to set the value
    // on the RPCParam.  This is necessary for cases like
    //  <method>
    //    <foo>123</foo>
    //    <foo>456</foo>
    //    <foo xsi:nil="true" />
    //  </method>
    // so that a list of 3 items is created.
    // Failure to register the target would result in the last
    // item not being added to the list
    if (context.isNil(attributes)) {
        Deserializer nilDSer = new DeserializerImpl();
        nilDSer.registerValueTarget(new RPCParamTarget(currentParam));
        return (SOAPHandler) nilDSer;
    }

    Deserializer dser = null;
    if ((type == null) && (namespace != null) && (!namespace.equals(""))) {
        dser = context.getDeserializerForType(qname);
    } else {
        dser = context.getDeserializer(destClass, type);
        // !!!
        if (dser == null && destClass != null && destClass.isArray()
                && operation.getStyle() == Style.DOCUMENT) {
            dser = context.getDeserializerForClass(destClass);
        }
        // !!!
    }

    if (dser == null) {
        if (type != null) {
            dser = context.getDeserializerForType(type);
            if (null != destClass && dser == null && Element.class.isAssignableFrom(destClass)) {
                //If a DOM element is expected, as last resort always allow direct mapping 
                // of parameter's SOAP xml to a DOM element.  Support of literal  parms by default.
                dser = context.getDeserializerForType(Constants.SOAP_ELEMENT);

            }
            if (dser == null) {
                dser = context.getDeserializerForClass(destClass);
            }
            if (dser == null) {
                throw new SAXException(Messages.getMessage("noDeser01", localName, "" + type));
            }
            if (paramDesc != null && paramDesc.getJavaType() != null) {
                // If we have an xsi:type, make sure it makes sense
                // with the current paramDesc type
                Class xsiClass = context.getTypeMapping().getClassForQName(type);
                if (null != xsiClass && !JavaUtils.isConvertable(xsiClass, destClass)) {
                    throw new SAXException("Bad types (" + xsiClass + " -> " + destClass + ")"); // FIXME!
                }
            }
        } else {
            dser = context.getDeserializerForClass(destClass);
            if (dser == null) {
                dser = new DeserializerImpl();
            }
        }
    }

    dser.setDefaultType(type);

    dser.registerValueTarget(new RPCParamTarget(currentParam));

    if (log.isDebugEnabled()) {
        log.debug("Exit: RPCHandler.onStartChild()");
    }
    return (SOAPHandler) dser;
}