Example usage for javax.xml.namespace QName toString

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

Introduction

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

Prototype

public String toString() 

Source Link

Document

<p><code>String</code> representation of this <code>QName</code>.</p> <p>The commonly accepted way of representing a <code>QName</code> as a <code>String</code> was <a href="http://jclark.com/xml/xmlns.htm">defined</a> by James Clark.

Usage

From source file:org.apache.servicemix.jbi.cluster.engine.ClusterEngine.java

protected String getSelector() {
    if (selector == null) {
        Set<String> interfaces = new HashSet<String>();
        Set<String> services = new HashSet<String>();
        Set<String> endpoints = new HashSet<String>();

        for (ServiceEndpoint se : getAllEndpoints()) {
            // This endpoint is not a JBI endpoint, so we don't need to filter it out
            QName[] itfs = se.getInterfaces();
            if (itfs != null) {
                for (QName itf : itfs) {
                    interfaces.add(itf.toString());
                }//from  w w  w  .j a v  a2s .co m
            }
            services.add(se.getServiceName().toString());
            endpoints.add("{" + se.getServiceName().toString() + "}" + se.getEndpointName());
        }
        StringBuilder selector = new StringBuilder();
        if (!endpoints.isEmpty()) {
            selector.append("(");
            selector.append(JBI_MESSAGE).append(" = ").append(JBI_MESSAGE_IN).append(" AND (");
            if (!interfaces.isEmpty()) {
                selector.append(JBI_INTERFACE).append(" IN (");
                boolean first = true;
                for (String s : interfaces) {
                    if (!first) {
                        selector.append(", ");
                    } else {
                        first = false;
                    }
                    selector.append("'").append(s).append("'");
                }
                selector.append(")");
            }
            if (!interfaces.isEmpty()) {
                selector.append(" OR ");
            }
            selector.append(JBI_SERVICE).append(" IN (");
            boolean first = true;
            for (String s : services) {
                if (!first) {
                    selector.append(", ");
                } else {
                    first = false;
                }
                selector.append("'").append(s).append("'");
            }
            selector.append(")");
            selector.append(" OR ");
            selector.append(JBI_ENDPOINT).append(" IN (");
            first = true;
            for (String s : endpoints) {
                if (!first) {
                    selector.append(", ");
                } else {
                    first = false;
                }
                selector.append("'").append(s).append("'");
            }
            selector.append(")");
            selector.append(")");
            selector.append(")");
            selector.append(" OR ");
        }
        selector.append(PROPERTY_CLUSTER_NAME).append(" = '").append(name).append("'");
        this.selector = selector.toString();
    }
    return this.selector;
}

From source file:com.bradmcevoy.property.BeanPropertySource.java

@Override
public void setProperty(QName name, Object value, Resource r)
        throws NotAuthorizedException, PropertySetException {
    log.debug("setProperty: " + name + " = " + value);
    PropertyDescriptor pd = getPropertyDescriptor(r, name.getLocalPart());
    try {//from   w ww  .j a  v  a  2s . co  m
        pd.getWriteMethod().invoke(r, value);
    } catch (PropertySetException e) {
        throw e;
    } catch (Exception ex) {
        if (ex.getCause() instanceof NotAuthorizedException) {
            NotAuthorizedException na = (NotAuthorizedException) ex.getCause();
            throw na;
        } else if (ex.getCause() instanceof PropertySetException) {
            PropertySetException na = (PropertySetException) ex.getCause();
            throw na;
        } else {
            if (value == null) {
                log.error("Exception setting property: " + name.toString() + " to null");
            } else {
                log.error("Exception setting property: " + name.toString() + " to value: " + value + " class:"
                        + value.getClass());
            }
            throw new RuntimeException(name.toString(), ex);
        }
    }
}

From source file:org.eclipse.winery.repository.client.WineryRepositoryClient.java

/**
 * {@inheritDoc}/*from   www . j a  v a  2s. c o  m*/
 *
 * Does NOT check for global QName uniqueness, only in the scope of all
 * artifact templates
 */
@Override
public void createArtifactTemplate(QName qname, QName artifactType) throws QNameAlreadyExistsException {
    WebResource artifactTemplates = this.primaryWebResource.path("artifacttemplates");
    MultivaluedMap<String, String> map = new MultivaluedMapImpl();
    map.putSingle("namespace", qname.getNamespaceURI());
    map.putSingle("name", qname.getLocalPart());
    map.putSingle("type", artifactType.toString());
    ClientResponse response = artifactTemplates.type(MediaType.APPLICATION_FORM_URLENCODED)
            .accept(MediaType.TEXT_PLAIN).post(ClientResponse.class, map);
    if (response.getClientResponseStatus() != ClientResponse.Status.CREATED) {
        // TODO: pass ClientResponse.Status somehow
        // TODO: more fine grained checking for error message. Not all
        // failures are that the QName already exists
        LOGGER.debug(String.format("Error %d when creating id %s from URI %s", response.getStatus(),
                qname.toString(), this.primaryWebResource.getURI().toString()));
        throw new QNameAlreadyExistsException();
    }
    // no further return is made
}

From source file:eu.artist.postmigration.eubt.executiontrace.abstractor.SOAPTraceAbstractor.java

private OMElement generateIndependentOriginalResponse(OMElement element) throws Exception {
    SOAP11Factory factory = new SOAP11Factory();

    if (SOAPHelper.hasElementChildren(element)) {
        // has more children --> recursively add each child
        SourceElement sourceElement = wsMigrationTraceHandler.getSourceElement(
                element.getNamespace().getNamespaceURI(), element.getLocalName(),
                SOAPHelper.obtainImmediateChildNodesAndValues(element));
        List<TargetElement> targetElements = wsMigrationTraceHandler.getTargetElements(sourceElement);
        Iterator<?> elementChildrenIterator = element.getChildElements();
        // has more children --> check if element exists a corresponding source element, if so add children, if not skip
        while (targetElements.size() > 0 && elementChildrenIterator.hasNext()) {
            QName elementName = null;
            if (element.getParent() instanceof SOAPBody) {
                // operation level element
                elementName = new QName(element.getNamespace().getNamespaceURI(),
                        targetElements.get(0).getElementName(), element.getNamespace().getPrefix());
            } else {
                // below operation level element
                elementName = new QName(element.getNamespace().getNamespaceURI(), element.getLocalName(),
                        element.getNamespace().getPrefix());
            }/*w w w  .  j  a  v a 2  s .  c  o m*/
            OMElement independentElement = factory.createOMElement(elementName);
            OMElement matchingChildElement = (OMElement) elementChildrenIterator.next();
            independentElement.addChild(generateIndependentOriginalResponse(matchingChildElement));
            return independentElement;
        } // while there are children of element
    } else {
        // no more children (leaf(s) reached) --> add matching parameters
        OMElement parameterContainer = factory.createOMElement(element.getQName());
        Map<String, String> parameterNamesAndValues = SOAPHelper.obtainImmediateChildNodesAndValues(element);
        SourceElement matchingSourceElement = obtainMatchingSourceElement(element, parameterNamesAndValues);

        if (matchingSourceElement != null) {
            for (SourceParameter sourceParameter : matchingSourceElement.getParameters()) {
                // obtain corresponding target parameter(s)
                MultiMap<TargetElement, TargetParameter> targetElementParameterMap = wsMigrationTraceHandler
                        .getTargetParameters(matchingSourceElement, sourceParameter);
                for (Object targetParameterObject : targetElementParameterMap.values()) {
                    TargetParameter targetParameter = (TargetParameter) targetParameterObject;
                    // check if target parameter links to given source parameter (i.e., the source parameter's target parameter list must match with the iterating target parameter)
                    for (TargetParameter matchingTargetParameter : sourceParameter.getTargetParameter()) {
                        if (matchingTargetParameter.equals(targetParameter) && parameterContainer
                                .getChildrenWithLocalName(sourceParameter.getParameterName())
                                .hasNext() != true) {
                            // matching target parameter that is not yet there found --> add it
                            String parameterValueString = parameterNamesAndValues
                                    .get(sourceParameter.getParameterName());
                            QName parameterName = new QName(targetParameter.getParameterName());
                            OMElement parameter = factory.createOMElement(parameterName);
                            OMText parameterValue = factory.createOMText(parameter, parameterValueString);
                            parameter.addChild(parameterValue);
                            parameterContainer.addChild(parameter);
                        }
                    }
                } // for each source parameter object
            } // for each target parameter
        } else {
            // the target is a parameter (not an element, e.g. in case of <result>..</result>)
            QName parameterName = new QName(((OMElement) element.getFirstOMChild()).getLocalName());
            String parameterValueString = parameterNamesAndValues.get(parameterName.toString());
            OMElement parameter = factory.createOMElement(parameterName);
            OMText parameterValue = factory.createOMText(parameter, parameterValueString);
            parameter.addChild(parameterValue);
            parameterContainer.addChild(parameter);
        }

        return parameterContainer;
    } // else

    return null; // unreachable?
}

From source file:eu.artist.postmigration.eubt.executiontrace.abstractor.SOAPTraceAbstractor.java

private OMElement generateIndependentMigratedResponse(OMElement element) {
    SOAP11Factory factory = new SOAP11Factory();

    if (SOAPHelper.hasElementChildren(element)) {
        // has more children --> recursively add each child
        TargetElement targetElement = wsMigrationTraceHandler.getTargetElement(
                element.getNamespace().getNamespaceURI(), element.getLocalName(),
                SOAPHelper.obtainImmediateChildNodesAndValues(element));
        List<SourceElement> sourceElements = wsMigrationTraceHandler.getSourceElements(targetElement);
        Iterator<?> elementChildrenIterator = element.getChildElements();
        // has more children --> check if element exists a corresponding target element, if so add children, if not skip
        while (sourceElements.size() > 0 && elementChildrenIterator.hasNext()) {
            QName elementName = new QName(element.getNamespace().getNamespaceURI(), element.getLocalName(),
                    element.getNamespace().getPrefix());
            OMElement independentElement = factory.createOMElement(elementName);
            OMElement matchingChildElement = (OMElement) elementChildrenIterator.next();
            independentElement.addChild(generateIndependentMigratedResponse(matchingChildElement));
            return independentElement;
        }/*from   w  w w.j  a v a  2s  . c  om*/
    } else {
        // no more children (leaf(s) reached) --> add matching parameters
        OMElement parameterContainer = factory.createOMElement(element.getQName());
        Map<String, String> parameterNamesAndValues = SOAPHelper.obtainImmediateChildNodesAndValues(element);
        TargetElement matchingTargetElement = obtainMatchingTargetElement(element, parameterNamesAndValues);

        if (matchingTargetElement != null) {
            for (TargetParameter targetParameter : matchingTargetElement.getParameters()) {
                // obtain corresponding source parameter(s)
                MultiMap<SourceElement, SourceParameter> sourceElementParameterMap = wsMigrationTraceHandler
                        .getSourceParameters(matchingTargetElement, targetParameter);
                for (Object sourceParameterObject : sourceElementParameterMap.values()) {
                    SourceParameter sourceParameter = (SourceParameter) sourceParameterObject;
                    // check if source parameter links to given target parameter (i.e., the source parameter's target parameter list must contain the given target parameter)
                    for (TargetParameter matchingTargetParameter : sourceParameter.getTargetParameter()) {
                        if (matchingTargetParameter.equals(targetParameter)) {
                            // matching target parameter found --> add it
                            String parameterValueString = parameterNamesAndValues
                                    .get(targetParameter.getParameterName());
                            QName parameterName = new QName(targetParameter.getParameterName());
                            OMElement parameter = factory.createOMElement(parameterName);
                            OMText parameterValue = factory.createOMText(parameter, parameterValueString);
                            parameter.addChild(parameterValue);
                            parameterContainer.addChild(parameter);
                        } // if target parameter matches
                    } // for each matching target parameter
                } // for each source parameter object
            } // for each target parameter
        } else {
            // the target is a parameter (not an element, e.g. in case of <result>boolean</result>)
            QName parameterName = new QName(((OMElement) element.getFirstOMChild()).getLocalName());
            String parameterValueString = parameterNamesAndValues.get(parameterName.toString());
            OMElement parameter = factory.createOMElement(parameterName);
            OMText parameterValue = factory.createOMText(parameter, parameterValueString);
            parameter.addChild(parameterValue);
            parameterContainer.addChild(parameter);
        }

        return parameterContainer;
    } // else

    return null; // unreachable?
}

From source file:microsoft.exchange.webservices.data.core.EwsXmlReader.java

/**
 * Read attribute value from QName.//from   ww  w.  j a v a 2 s  . c  o  m
 *
 * @param qName QName of the attribute
 * @return Attribute Value
 * @throws Exception thrown if attribute value can not be read
 */
private String readAttributeValue(QName qName) throws Exception {
    if (this.presentEvent.isStartElement()) {
        StartElement startElement = this.presentEvent.asStartElement();
        Attribute attr = startElement.getAttributeByName(qName);
        if (null != attr) {
            return attr.getValue();
        } else {
            return null;
        }
    } else {
        String errMsg = String.format("Could not fetch attribute %s", qName.toString());
        throw new Exception(errMsg);
    }
}

From source file:com.sap.dirigible.runtime.agent.WsApplyHandler.java

private void addWebService(String remoteFile, HttpServletRequest request) throws IOException {

    logger.debug("entering: " + this.getClass().getCanonicalName() + " -> " //$NON-NLS-1$ //$NON-NLS-2$
            + "addWebService"); //$NON-NLS-1$

    InputStream wsMetaDataIn = getRemoteFile(remoteFile, request);

    // {"address":"/publish_address","wsdl":"/projectXXX/fileXXX.wsdl","serviceName":"{http://example.com}ServiceXXX","processorType":"CAMEL","processor":"direct:camel_idXXX"}

    String wsMetaData = IOUtils.toString(wsMetaDataIn);

    logger.debug("WS Metadata: " + wsMetaData); //$NON-NLS-1$

    JsonParser parser = new JsonParser();
    JsonObject wsService = (JsonObject) parser.parse(wsMetaData);
    String address = wsService.get(PARAMETER_ADDRESS).getAsString();
    String wsdl = wsService.get(PARAMETER_WSDL).getAsString();
    String serviceName = wsService.get(PARAMETER_SERVICE_NAME).getAsString();
    QName serviceQName = QName.valueOf(serviceName);
    String processorType = wsService.get(PARAMETER_PROCESSOR_TYPE).getAsString();
    String processor = wsService.get(PARAMETER_PROCESSOR).getAsString();
    InputStream wsdlIn = getRemoteFile(wsdl, request);
    File wsdlFile = createTempWsdlFile(wsdl, wsdlIn);

    try {//from  ww w.  jav  a 2s . co m
        // create provider service implementor - retrieve and redirect the
        // message
        Object implementor = new WsEndpointProviderImplementor(getConfigurationAgent(), processorType,
                processor);

        // stop the endpoint if already published
        stopIfPublished(address);

        EndpointImpl jaxwsEndpoint = new EndpointImpl(CXFBusFactory.getDefaultBus(), implementor, (String) null,
                wsdlFile.getCanonicalPath());
        jaxwsEndpoint.setServiceName(serviceQName);
        jaxwsEndpoint.setAddress(address);
        jaxwsEndpoint.getProperties().put(ConfigurationCommands.PROPERTY_REPOSITORY_LOCATION, remoteFile);
        jaxwsEndpoint.getProperties().put(ConfigurationCommands.PROPERTY_EXPOSED_AT, new Date());
        jaxwsEndpoint.publish();

        logger.debug(String.format(
                ENDPOINT_WITH_PROCESSOR_TYPE_S_AND_PROCESSOR_S_AND_FORMAT_S_AND_Q_NAME_S_AT_ADDRESS_S_HAS_BEEN_PUBLISHED_SUCCESSFULLY,
                processorType, processor, serviceQName.toString(), address));
    } finally {
        clean(wsdlFile);
    }

    logger.debug("exiting: " + this.getClass().getCanonicalName() + " -> " //$NON-NLS-1$ //$NON-NLS-2$
            + "addWebService"); //$NON-NLS-1$
}

From source file:org.eclipse.winery.repository.client.WineryRepositoryClient.java

/**
 * {@inheritDoc}//from  w ww .jav  a  2s  .c  om
 */
@Override
public void createComponent(QName qname, Class<? extends TOSCAComponentId> idClass)
        throws QNameAlreadyExistsException {
    WebResource resource = this.primaryWebResource.path(Util.getRootPathFragment(idClass));
    MultivaluedMap<String, String> map = new MultivaluedMapImpl();
    map.putSingle("namespace", qname.getNamespaceURI());
    map.putSingle("name", qname.getLocalPart());
    ClientResponse response = resource.type(MediaType.APPLICATION_FORM_URLENCODED).accept(MediaType.TEXT_PLAIN)
            .post(ClientResponse.class, map);
    if (response.getClientResponseStatus() != ClientResponse.Status.CREATED) {
        // TODO: pass ClientResponse.Status somehow
        // TODO: more fine grained checking for error message. Not all failures are that the QName already exists
        LOGGER.debug(String.format("Error %d when creating id %s from URI %s", response.getStatus(),
                qname.toString(), this.primaryWebResource.getURI().toString()));
        throw new QNameAlreadyExistsException();
    }
    // no further return is made
}

From source file:com.avalara.avatax.services.base.ser.BeanDeserializer.java

/**
 * Deserializer interface called on each child element encountered in
 * the XML stream./*from   www  .  j a  v  a2  s. c  om*/
 * @param namespace is the namespace of the child element
 * @param localName is the local name of the child element
 * @param prefix is the prefix used on the name of the child element
 * @param attributes are the attributes of the child element
 * @param context is the deserialization context.
 * @return is a Deserializer to use to deserialize a child (must be
 * a derived class of SOAPHandler) or null if no deserialization should
 * be performed.
 */
public SOAPHandler onStartChild(String namespace, String localName, String prefix, Attributes attributes,
        DeserializationContext context) throws SAXException {
    handleMixedContent();

    BeanPropertyDescriptor propDesc = null;
    FieldDesc fieldDesc = null;

    SOAPConstants soapConstants = context.getSOAPConstants();
    String encodingStyle = context.getEncodingStyle();
    boolean isEncoded = Constants.isSOAP_ENC(encodingStyle);

    QName elemQName = new QName(namespace, localName);
    // The collectionIndex needs to be reset for Beans with multiple arrays
    if ((prevQName == null) || (!prevQName.equals(elemQName))) {
        collectionIndex = -1;
    }

    boolean isArray = false;
    QName itemQName = null;
    if (typeDesc != null) {
        // Lookup the name appropriately (assuming an unqualified
        // name for SOAP encoding, using the namespace otherwise)
        String fieldName = typeDesc.getFieldNameForElement(elemQName, isEncoded);
        propDesc = (BeanPropertyDescriptor) propertyMap.get(fieldName);
        fieldDesc = typeDesc.getFieldByName(fieldName);

        if (fieldDesc != null) {
            ElementDesc element = (ElementDesc) fieldDesc;
            isArray = element.isMaxOccursUnbounded();
            itemQName = element.getItemQName();
        }
    }

    if (propDesc == null) {
        // look for a field by this name.
        propDesc = (BeanPropertyDescriptor) propertyMap.get(localName);
    }

    // try and see if this is an xsd:any namespace="##any" element before
    // reporting a problem
    if (propDesc == null || (((prevQName != null) && prevQName.equals(elemQName)
            && !(propDesc.isIndexed() || isArray) && getAnyPropertyDesc() != null))) {
        // try to put unknown elements into a SOAPElement property, if
        // appropriate
        prevQName = elemQName;
        propDesc = getAnyPropertyDesc();
        if (propDesc != null) {
            try {
                MessageElement[] curElements = (MessageElement[]) propDesc.get(value);
                int length = 0;
                if (curElements != null) {
                    length = curElements.length;
                }
                MessageElement[] newElements = new MessageElement[length + 1];
                if (curElements != null) {
                    System.arraycopy(curElements, 0, newElements, 0, length);
                }
                MessageElement thisEl = context.getCurElement();

                newElements[length] = thisEl;
                propDesc.set(value, newElements);
                // if this is the first pass through the MessageContexts
                // make sure that the correct any element is set,
                // that is the child of the current MessageElement, however
                // on the first pass this child has not been set yet, so
                // defer it to the child SOAPHandler
                if (!localName.equals(thisEl.getName())) {
                    return new SOAPHandler(newElements, length);
                }
                return new SOAPHandler();
            } catch (Exception e) {
                throw new SAXException(e);
            }
        }
    }

    if (propDesc == null) {
        // The exception was changed to return null so deserialization doesn't fail if it gets an unexpected element.
        // This allows extending the api without breaking existing clients.  It's normal .Net behavior.
        return null;
        // No such field
        //            throw new SAXException(
        //                    Messages.getMessage("badElem00", javaType.getName(),
        //                                         localName));
    }

    prevQName = elemQName;
    // Get the child's xsi:type if available
    QName childXMLType = context.getTypeFromAttributes(namespace, localName, attributes);

    String href = attributes.getValue(soapConstants.getAttrHref());
    Class fieldType = propDesc.getType();

    // If no xsi:type or href, check the meta-data for the field
    if (childXMLType == null && fieldDesc != null && href == null) {
        childXMLType = fieldDesc.getXmlType();
        if (itemQName != null) {
            // This is actually a wrapped literal array and should be
            // deserialized with the ArrayDeserializer
            childXMLType = Constants.SOAP_ARRAY;
            fieldType = propDesc.getActualType();
        } else {
            childXMLType = fieldDesc.getXmlType();
        }
    }

    // Get Deserializer for child, default to using DeserializerImpl
    Deserializer dSer = getDeserializer(childXMLType, fieldType, href, context);

    // It is an error if the dSer is not found - the only case where we
    // wouldn't have a deserializer at this point is when we're trying
    // to deserialize something we have no clue about (no good xsi:type,
    // no good metadata).
    if (dSer == null) {
        dSer = context.getDeserializerForClass(propDesc.getType());
    }

    // Fastpath nil checks...
    if (context.isNil(attributes)) {
        if (propDesc != null && (propDesc.isIndexed() || isArray)) {
            if (!((dSer != null) && (dSer instanceof ArrayDeserializer))) {
                collectionIndex++;
                dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc, collectionIndex));
                addChildDeserializer(dSer);
                return (SOAPHandler) dSer;
            }
        }
        return null;
    }

    if (dSer == null) {
        throw new SAXException(Messages.getMessage("noDeser00", childXMLType.toString()));
    }

    if (constructorToUse != null) {
        if (constructorTarget == null) {
            constructorTarget = new ConstructorTarget(constructorToUse, this);
        }
        dSer.registerValueTarget(constructorTarget);
    } else if (propDesc.isWriteable()) {
        // If this is an indexed property, and the deserializer we found
        // was NOT the ArrayDeserializer, this is a non-SOAP array:
        // <bean>
        //   <field>value1</field>
        //   <field>value2</field>
        // ...
        // In this case, we want to use the collectionIndex and make sure
        // the deserialized value for the child element goes into the
        // right place in the collection.

        // Register value target
        if ((itemQName != null || propDesc.isIndexed() || isArray) && !(dSer instanceof ArrayDeserializer)) {
            collectionIndex++;
            dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc, collectionIndex));
        } else {
            // If we're here, the element maps to a single field value,
            // whether that be a "basic" type or an array, so use the
            // normal (non-indexed) BeanPropertyTarget form.
            collectionIndex = -1;
            dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc));
        }
    }

    // Let the framework know that we need this deserializer to complete
    // for the bean to complete.
    addChildDeserializer(dSer);

    return (SOAPHandler) dSer;
}

From source file:com.polarion.alm.ws.client.internal.encoding.BeanDeserializer.java

/**
 * Deserializer interface called on each child element encountered in the
 * XML stream./*  ww  w. j  a v  a 2s .  co m*/
 * 
 * @param namespace
 *            is the namespace of the child element
 * @param localName
 *            is the local name of the child element
 * @param prefix
 *            is the prefix used on the name of the child element
 * @param attributes
 *            are the attributes of the child element
 * @param context
 *            is the deserialization context.
 * @return is a Deserializer to use to deserialize a child (must be a
 *         derived class of SOAPHandler) or null if no deserialization
 *         should be performed.
 */
public SOAPHandler onStartChild(String namespace, String localName, String prefix, Attributes attributes,
        DeserializationContext context) throws SAXException {
    handleMixedContent();

    BeanPropertyDescriptor propDesc = null;
    FieldDesc fieldDesc = null;

    SOAPConstants soapConstants = context.getSOAPConstants();
    String encodingStyle = context.getEncodingStyle();
    boolean isEncoded = Constants.isSOAP_ENC(encodingStyle);

    QName elemQName = new QName(namespace, localName);
    // The collectionIndex needs to be reset for Beans with multiple arrays
    if ((prevQName == null) || (!prevQName.equals(elemQName))) {
        collectionIndex = -1;
    }

    boolean isArray = false;
    QName itemQName = null;
    if (typeDesc != null) {
        // Lookup the name appropriately (assuming an unqualified
        // name for SOAP encoding, using the namespace otherwise)
        String fieldName = typeDesc.getFieldNameForElement(elemQName, isEncoded);
        propDesc = (BeanPropertyDescriptor) propertyMap.get(fieldName);
        fieldDesc = typeDesc.getFieldByName(fieldName);

        if (fieldDesc != null) {
            ElementDesc element = (ElementDesc) fieldDesc;
            isArray = element.isMaxOccursUnbounded();
            itemQName = element.getItemQName();
        }
    }

    if (propDesc == null) {
        // look for a field by this name.
        propDesc = (BeanPropertyDescriptor) propertyMap.get(localName);
    }

    // try and see if this is an xsd:any namespace="##any" element before
    // reporting a problem
    if (propDesc == null || (((prevQName != null) && prevQName.equals(elemQName)
            && !(propDesc.isIndexed() || isArray) && getAnyPropertyDesc() != null))) {
        // try to put unknown elements into a SOAPElement property, if
        // appropriate
        prevQName = elemQName;
        propDesc = getAnyPropertyDesc();
        if (propDesc != null) {
            try {
                MessageElement[] curElements = (MessageElement[]) propDesc.get(value);
                int length = 0;
                if (curElements != null) {
                    length = curElements.length;
                }
                MessageElement[] newElements = new MessageElement[length + 1];
                if (curElements != null) {
                    System.arraycopy(curElements, 0, newElements, 0, length);
                }
                MessageElement thisEl = context.getCurElement();

                newElements[length] = thisEl;
                propDesc.set(value, newElements);
                // if this is the first pass through the MessageContexts
                // make sure that the correct any element is set,
                // that is the child of the current MessageElement, however
                // on the first pass this child has not been set yet, so
                // defer it to the child SOAPHandler
                if (!localName.equals(thisEl.getName())) {
                    return new SOAPHandler(newElements, length);
                }
                return new SOAPHandler();
            } catch (Exception e) {
                throw new SAXException(e);
            }
        }
    }

    if (propDesc == null) {
        log.warn(Messages.getMessage("badElem00", javaType.getName(), localName));
        return null;
    }

    prevQName = elemQName;
    // Get the child's xsi:type if available
    QName childXMLType = context.getTypeFromAttributes(namespace, localName, attributes);

    String href = attributes.getValue(soapConstants.getAttrHref());
    Class fieldType = propDesc.getType();

    // If no xsi:type or href, check the meta-data for the field
    if (childXMLType == null && fieldDesc != null && href == null) {
        childXMLType = fieldDesc.getXmlType();
        if (itemQName != null) {
            // This is actually a wrapped literal array and should be
            // deserialized with the ArrayDeserializer
            childXMLType = Constants.SOAP_ARRAY;
            fieldType = propDesc.getActualType();
        } else {
            childXMLType = fieldDesc.getXmlType();
        }
    }

    // Get Deserializer for child, default to using DeserializerImpl
    Deserializer dSer = getDeserializer(childXMLType, fieldType, href, context);

    // It is an error if the dSer is not found - the only case where we
    // wouldn't have a deserializer at this point is when we're trying
    // to deserialize something we have no clue about (no good xsi:type,
    // no good metadata).
    if (dSer == null) {
        dSer = context.getDeserializerForClass(propDesc.getType());
    }

    // Fastpath nil checks...
    if (context.isNil(attributes)) {
        if (propDesc != null && (propDesc.isIndexed() || isArray)) {
            if (!((dSer != null) && (dSer instanceof ArrayDeserializer))) {
                collectionIndex++;
                dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc, collectionIndex));
                addChildDeserializer(dSer);
                return (SOAPHandler) dSer;
            }
        }
        return null;
    }

    if (dSer == null) {
        throw new SAXException(Messages.getMessage("noDeser00", childXMLType.toString()));
    }

    if (constructorToUse != null) {
        if (constructorTarget == null) {
            constructorTarget = new ConstructorTarget(constructorToUse, this);
        }
        dSer.registerValueTarget(constructorTarget);
    } else if (propDesc.isWriteable()) {
        // If this is an indexed property, and the deserializer we found
        // was NOT the ArrayDeserializer, this is a non-SOAP array:
        // <bean>
        // <field>value1</field>
        // <field>value2</field>
        // ...
        // In this case, we want to use the collectionIndex and make sure
        // the deserialized value for the child element goes into the
        // right place in the collection.

        // Register value target
        if ((itemQName != null || propDesc.isIndexed() || isArray) && !(dSer instanceof ArrayDeserializer)) {
            collectionIndex++;
            dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc, collectionIndex));
        } else {
            // If we're here, the element maps to a single field value,
            // whether that be a "basic" type or an array, so use the
            // normal (non-indexed) BeanPropertyTarget form.
            collectionIndex = -1;
            dSer.registerValueTarget(new BeanPropertyTarget(value, propDesc));
        }
    }

    // Let the framework know that we need this deserializer to complete
    // for the bean to complete.
    addChildDeserializer(dSer);

    return (SOAPHandler) dSer;
}