Examples of ElementWriter


Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

                if (part.getXmlSchema() instanceof XmlSchemaElement
                    && ((XmlSchemaElement)part.getXmlSchema()).getMinOccurs() == 0) {
                    //skip writing minOccurs=0 stuff if obj is null
                    return;
                } else if (type.isNillable()) {
                    ElementWriter writer = new ElementWriter(output);
                    MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
                    w2.writeXsiNil();
                    w2.close();
                    return;
                }
            }
            ElementWriter writer = new ElementWriter(output);
            // outerType is only != null for a flat array.
            if (outerType == null) {
                MessageWriter w2 = writer.getElementWriter(part != null ? part.getConcreteName()
                    : type.getSchemaType());
                type.writeObject(obj, w2, context);
                w2.close();
            } else {
                // it has better be an array (!)
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, new Context());
        writer.close();
        writer.flush();

        bos.close();
       
        StaxBuilder builder = new StaxBuilder();
        Document doc = builder.build(new ByteArrayInputStream(bos.toByteArray()));
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, new Context());
        writer.close();
        writer.flush();

        bos.close();
       
        StaxBuilder builder = new StaxBuilder();
        Document doc = builder.build(new ByteArrayInputStream(bos.toByteArray()));
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

        Element element = createElement("urn:Bean", "root", "b");
        MapNamespaceContext namespaces = new MapNamespaceContext();
        for (Map.Entry<String, String> entry : getNamespaces().entrySet()) {
            namespaces.addNamespace(entry.getKey(), entry.getValue());
        }
        ElementWriter rootWriter = getElementWriter(element, namespaces);
        Context context = getContext();

        // get Type based on the object instance
        assertNotNull("type is null", type);

        // write the ref
        SoapRefType soapRefType = new SoapRefType(type);
        MessageWriter cwriter = rootWriter.getElementWriter(soapRefType.getSchemaType());
        soapRefType.writeObject(instance, cwriter, context);
        cwriter.close();

        // write the trailing blocks (referenced objects)
        trailingBlocks.writeBlocks(rootWriter, context);
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, getContext());
        writer.close();
        writer.flush();

        bos.close();
       
        Document doc = DOMUtils.readXml(new ByteArrayInputStream(bos.toByteArray()));
        Element element = doc.getDocumentElement();
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, getContext());
        writer.close();
        writer.flush();

        bos.close();

        Document doc = StaxUtils.read(new ByteArrayInputStream(bos.toByteArray()));
        Element element = doc.getDocumentElement();
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

        context.setAttachments(attachments);
        type = TypeUtil.getWriteType(databinding.getAegisContext(), obj, type);
        try {
            W3CDOMStreamWriter domWriter = new W3CDOMStreamWriter(output);
            ElementWriter writer = new ElementWriter(domWriter);
            MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
            if (type.isNillable() && type.isWriteOuter() && obj == null) {
                w2.writeXsiNil();
                w2.close();
                return;
            }
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

                if (part.getXmlSchema() instanceof XmlSchemaElement
                    && ((XmlSchemaElement)part.getXmlSchema()).getMinOccurs() == 0) {
                    //skip writing minOccurs=0 stuff if obj is null
                    return;
                } else if (type.isNillable() && type.isWriteOuter()) {
                    ElementWriter writer = new ElementWriter(output);
                    MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
                    w2.writeXsiNil();
                    w2.close();
                    return;
                }
            }
            ElementWriter writer = new ElementWriter(output);
            MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
            type.writeObject(obj, w2, context);
            w2.close();
        } catch (DatabindingException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

        if (obj == null) {
            if (optional) { // minOccurs = 0
                return;
            }
            if (aegisType.isNillable() && aegisType.isWriteOuter()) {
                ElementWriter writer = new ElementWriter(output);
                MessageWriter w2 = writer.getElementWriter(elementName);
                w2.writeXsiNil();
                w2.close();
                return;
            }
        }
       
        ElementWriter writer = new ElementWriter(output);
        MessageWriter w2 = writer.getElementWriter(elementName);
        if (getContext().isWriteXsiTypes()
            && aegisType != null
            && aegisType.getSchemaType() != null) {
            // if we know the type, write it. We are standalone, and the reader needs it.
            w2.writeXsiType(aegisType.getSchemaType());
View Full Code Here

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter

        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, getContext());
        writer.close();
        writer.flush();

        bos.close();
       
        StaxBuilder builder = new StaxBuilder();
        Document doc = builder.build(new ByteArrayInputStream(bos.toByteArray()));
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.