Examples of ParticleInfo


Examples of org.apache.cxf.javascript.ParticleInfo

                xmlSchemaCollection.getSchemaByTargetNamespace(contextQName.getNamespaceURI());

            for (int i = 0; i < sequence.getItems().getCount(); i++) {
                code.append("// parameter " + inputParameterNames.get(i) + "\n");
                XmlSchemaObject sequenceItem = sequence.getItems().getItem(i);
                ParticleInfo itemInfo = ParticleInfo.forLocalItem(sequenceItem,
                                                                  wrapperSchema,
                                                                  xmlSchemaCollection,
                                                                  prefixAccumulator,
                                                                  contextQName);
                if (itemInfo.isArray()) {
                    code.append("// - array\n");
                }
               
                XmlSchemaType type = itemInfo.getType(); // null for an any.
                if (type instanceof XmlSchemaComplexType) {
                    QName baseName;
                    if (type.getQName() != null) {
                        baseName = type.getQName();
                    } else {
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

        }
        List<ParticleInfo> elements = new ArrayList<ParticleInfo>();
        String functionName = outputDeserializerFunctionName(outputMessage);
        code.append("function " + functionName + "(cxfjsutils, partElement) {\n");
        getElementsForParts(outputMessage, elements);
        ParticleInfo element = elements.get(0);
        XmlSchemaType type = null;
       
        if (isRPC) {
            utils.appendLine("cxfjsutils.trace('rpc element: ' + cxfjsutils.traceElementName(partElement));");
            utils.appendLine("partElement = cxfjsutils.getFirstElementChild(partElement);");
            utils.appendLine("cxfjsutils.trace('rpc element: ' + cxfjsutils.traceElementName(partElement));");
        }
       
        type = element.getType();
       
        if (!element.isEmpty()) {
            if (type instanceof XmlSchemaComplexType) {
                String typeObjectName = nameManager.getJavascriptName(element.getControllingName());
                utils
                    .appendLine("var returnObject = "
                                + typeObjectName
                                + "_deserialize (cxfjsutils, partElement);\n");
            } else if (type instanceof XmlSchemaSimpleType) {
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

        }

        utils.setXmlStringAccumulator("xml");
       
        if (isWrapped) {
            ParticleInfo elementInfo = ParticleInfo.forPartElement(inputWrapperElement,
                                                                 xmlSchemaCollection,
                                                                 "wrapperObj",
                                                                 wrapperXmlElementName);

            elementInfo.setContainingType(null);
            utils.generateCodeToSerializeElement(elementInfo, "", xmlSchemaCollection);
        } else {
            String operationXmlElement = null;
            if (isRPC) {
                operationXmlElement =
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

            }
           
            String partJavascriptVar =
                JavascriptUtils.javaScriptNameToken(mpi.getConcreteName().getLocalPart());
            String elementXmlRef = prefixAccumulator.xmlElementString(mpi.getConcreteName());
            ParticleInfo elementInfo = ParticleInfo.forPartElement(element,
                                                                 xmlSchemaCollection,
                                                                 partJavascriptVar,
                                                                 elementXmlRef);       
            // the type may have been recalculated above.
            elementInfo.setType(type);
            elementInfo.setEmpty(empty);
            elements.add(elementInfo);
        }
    }
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

        code.append("//\n");
        code.append("function " + typeObjectName + " () {\n");
        // to assist in debugging we put a type property into every object.
        utils.appendLine("this.typeMarker = '" + typeObjectName + "';");
        for (XmlSchemaObject thing : items) {
            ParticleInfo itemInfo = ParticleInfo.forLocalItem(thing,
                                                              xmlSchema,
                                                              xmlSchemaCollection,
                                                              prefixAccumulator,
                                                              type.getQName());
            constructOneItem(type, elementPrefix, typeObjectName, itemInfo);
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

     */
    protected void complexTypeSerializerBody(XmlSchemaComplexType type, String elementPrefix,
                                             JavascriptUtils bodyUtils) {
        List<XmlSchemaObject> items = XmlSchemaUtils.getContentElements(type, xmlSchemaCollection);
        for (XmlSchemaObject sequenceItem : items) {
            ParticleInfo itemInfo = ParticleInfo.forLocalItem(sequenceItem,
                                                              xmlSchema,
                                                              xmlSchemaCollection,
                                                              prefixAccumulator,
                                                              type.getQName());
               
            // If the item is 'any', it could be ANY of our top-level elements.
            if (itemInfo.isAny()) {
                serializeAny(itemInfo, bodyUtils);
            } else {
                bodyUtils.generateCodeToSerializeElement(itemInfo, "this._", xmlSchemaCollection);
            }
        }
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

        int nContentElements = contentElements.size();
        for (int i = 0; i < contentElements.size(); i++) {
            XmlSchemaObject contentElement = contentElements.get(i);
            utils.appendLine("cxfjsutils.trace('curElement: ' + cxfjsutils.traceElementName(curElement));");
            ParticleInfo itemInfo = ParticleInfo.forLocalItem(contentElement,
                                                              xmlSchema,
                                                              xmlSchemaCollection,
                                                              prefixAccumulator,
                                                              type.getQName());
            if (itemInfo.isAny()) {
                ParticleInfo nextItem = null;
                if (i != nContentElements - 1) {
                    XmlSchemaObject nextThing = contentElements.get(i + 1);
                    nextItem = ParticleInfo.forLocalItem(nextThing,
                                                         xmlSchema,
                                                         xmlSchemaCollection,
                                                         prefixAccumulator,
                                                         type.getQName());
                    // theoretically, you could have two anys with different
                    // namespaces.
                    if (nextItem.isAny()) {
                        unsupportedConstruct("MULTIPLE_ANY", type.getQName());
                    }
                }
                deserializeAny(type, itemInfo, nextItem);
            } else {
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

        utils.appendLine("var anyHolder = new org_apache_cxf_any_holder(anyURI, anyLocalPart, anyValue);");
        utils.appendLine("newobject.setAny(anyHolder);");
    }

    private void deserializeElement(XmlSchemaComplexType type, XmlSchemaObject thing) {
        ParticleInfo itemInfo = ParticleInfo.forLocalItem(thing,
                                                          xmlSchema,
                                                          xmlSchemaCollection,
                                                          prefixAccumulator,
                                                          type.getQName());
        XmlSchemaType itemType = itemInfo.getType();
        boolean simple = itemType instanceof XmlSchemaSimpleType
            || JavascriptUtils.notVeryComplexType(itemType);
        boolean mtomCandidate = JavascriptUtils.mtomCandidateType(itemType);
        String accessorName = "set" + StringUtils.capitalize(itemInfo.getJavascriptName());
        utils.appendLine("cxfjsutils.trace('processing " + itemInfo.getJavascriptName() + "');");
        XmlSchemaElement element = (XmlSchemaElement) itemInfo.getParticle();
        QName elementQName = XmlSchemaUtils.getElementQualifiedName(element, xmlSchema);
        String elementNamespaceURI = elementQName.getNamespaceURI();
        boolean elementNoNamespace = "".equals(elementNamespaceURI);
        XmlSchema elementSchema = null;
        if (!elementNoNamespace) {
            elementSchema = xmlSchemaCollection.getSchemaByTargetNamespace(elementNamespaceURI);
        }
        boolean qualified = !elementNoNamespace
                            && XmlSchemaUtils.isElementQualified(element,
                                                                 itemInfo.isGlobal(),
                                                                 xmlSchema,
                                                                 elementSchema);

        if (!qualified) {
            elementNamespaceURI = "";
        }
       
        String localName = elementQName.getLocalPart();
        String valueTarget = "item";

        if (itemInfo.isOptional() || itemInfo.isArray()) {
            utils.startIf("curElement != null && cxfjsutils.isNodeNamedNS(curElement, '"
                          + elementNamespaceURI + "', '" + localName + "')");
            if (itemInfo.isArray()) {
                utils.appendLine("item = [];");
                utils.startDo();
                valueTarget = "arrayItem";
                utils.appendLine("var arrayItem;");
            }
        }

        utils.appendLine("var value = null;");
        utils.startIf("!cxfjsutils.isElementNil(curElement)");
        if (itemInfo.isAnyType()) {
            // use our utility
            utils.appendLine(valueTarget + " = org_apache_cxf_deserialize_anyType(cxfjsutils, curElement);");
        } else if (simple) {
            if (mtomCandidate) {
                utils.appendLine(valueTarget + " = cxfjsutils.deserializeBase64orMom(curElement);");
            } else {
                utils.appendLine("value = cxfjsutils.getNodeText(curElement);");
                utils.appendLine(valueTarget
                                 + " = "
                                 + utils.javascriptParseExpression(itemType, "value") + ";");
            }
        } else {
            XmlSchemaComplexType complexType = (XmlSchemaComplexType)itemType;
            QName baseQName = complexType.getQName();
            if (baseQName == null) {
                baseQName = element.getQName();
            }

            String elTypeJsName = nameManager.getJavascriptName(baseQName);
            utils.appendLine(valueTarget
                             + " = "
                             + elTypeJsName
                             + "_deserialize(cxfjsutils, curElement);");
        }

        utils.endBlock(); // the if for the nil.
        if (itemInfo.isArray()) {
            utils.appendLine("item.push(arrayItem);");
            utils.appendLine("curElement = cxfjsutils.getNextElementSibling(curElement);");
            utils.endBlock();
            utils.appendLine("  while(curElement != null && cxfjsutils.isNodeNamedNS(curElement, '"
                             + elementNamespaceURI + "', '"
                             + localName + "'));");
        }
        utils.appendLine("newobject." + accessorName + "(item);");
        utils.appendLine("var item = null;");
        if (!itemInfo.isArray()) {
            utils.startIf("curElement != null");
            utils.appendLine("curElement = cxfjsutils.getNextElementSibling(curElement);");
            utils.endBlock();
        }
        if (itemInfo.isOptional() || itemInfo.isArray()) {
            utils.endBlock();
        }
    }
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

                                     XmlSchemaSequence sequence,
                                     final String elementPrefix,
                                     String typeObjectName,
                                     XmlSchemaObject thing) {

        ParticleInfo itemInfo = ParticleInfo.forLocalItem(thing,
                                                          schemaInfo.getSchema(),
                                                          xmlSchemaCollection,
                                                          prefixAccumulator,
                                                          type.getQName());
           
        String accessorSuffix = StringUtils.capitalize(itemInfo.getJavascriptName());

        String accessorName = typeObjectName + "_get" + accessorSuffix;
        String getFunctionProperty = typeObjectName + ".prototype.get" + accessorSuffix;
        String setFunctionProperty = typeObjectName + ".prototype.set" + accessorSuffix;
        accessors.append("//\n");
        accessors.append("// accessor is " + getFunctionProperty + "\n");
        accessors.append("// element get for " + itemInfo.getJavascriptName() + "\n");
        if (itemInfo.isAny()) {
            accessors.append("// - xs:any\n");
        } else {
            if (itemInfo.getType() != null) {
                accessors.append("// - element type is " + itemInfo.getType().getQName() + "\n");
            }
        }

        if (XmlSchemaUtils.isParticleOptional(itemInfo.getParticle())) {
            accessors.append("// - optional element\n");
        } else {
            accessors.append("// - required element\n");

        }

        if (XmlSchemaUtils.isParticleArray(itemInfo.getParticle())) {
            accessors.append("// - array\n");

        }

        if (itemInfo.isNillable()) {
            accessors.append("// - nillable\n");
        }

        accessors.append("//\n");
        accessors.append("// element set for " + itemInfo.getJavascriptName() + "\n");
        accessors.append("// setter function is is " + setFunctionProperty + "\n");
        accessors.append("//\n");
        accessors.append("function " + accessorName + "() { return this._"
                         + itemInfo.getJavascriptName() + ";}\n\n");
        accessors.append(getFunctionProperty + " = " + accessorName + ";\n\n");
        accessorName = typeObjectName + "_set" + accessorSuffix;
        accessors.append("function " + accessorName + "(value) { this._"
                         + itemInfo.getJavascriptName()
                         + " = value;}\n\n");
        accessors.append(setFunctionProperty + " = " + accessorName + ";\n");

        if (XmlSchemaUtils.isParticleOptional(itemInfo.getParticle())
            || (itemInfo.isNillable() && !XmlSchemaUtils.isParticleArray(itemInfo.getParticle()))) {
            utils.appendLine("this._" + itemInfo.getJavascriptName() + " = null;");
        } else if (XmlSchemaUtils.isParticleArray(itemInfo.getParticle())) {
            utils.appendLine("this._" + itemInfo.getJavascriptName() + " = [];");
        } else if (itemInfo.isAny() || itemInfo.getType() instanceof XmlSchemaComplexType) {
            // even for required complex elements, we leave them null.
            // otherwise, we could end up in a cycle or otherwise miserable. The
            // application code is responsible for this.
            utils.appendLine("this._" + itemInfo.getJavascriptName() + " = null;");
        } else {
            if (itemInfo.getDefaultValue() == null) {
                itemInfo.setDefaultValue(utils.getDefaultValueForSimpleType(itemInfo.getType()));
            }
            utils.appendLine("this._" + itemInfo.getJavascriptName() + " = "
                             + itemInfo.getDefaultValue() + ";");
        }
    }
View Full Code Here

Examples of org.apache.cxf.javascript.ParticleInfo

        XmlSchemaSequence sequence = XmlSchemaUtils.getSequence(type);

        for (int i = 0; i < sequence.getItems().getCount(); i++) {
            XmlSchemaObject sequenceItem = (XmlSchemaObject)sequence.getItems().getItem(i);
            ParticleInfo itemInfo = ParticleInfo.forLocalItem(sequenceItem,
                                                              schemaInfo.getSchema(),
                                                              xmlSchemaCollection,
                                                              prefixAccumulator,
                                                              type.getQName());
               
            // If the item is 'any', it could be ANY of our top-level elements.
            if (itemInfo.isAny()) {
                serializeAny(itemInfo, bodyUtils);
            } else {
                bodyUtils.generateCodeToSerializeElement(itemInfo, "this._", xmlSchemaCollection);
            }
        }
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.