Package org.apache.cxf.aegis.xml

Examples of org.apache.cxf.aegis.xml.MessageWriter


        }
      
    }

    protected void writeElement(QName name, Object value, Type type, MessageWriter writer, Context context) {
        MessageWriter cwriter = getWriter(writer, name, type);

        type.writeObject(value, cwriter, context);

        cwriter.close();
    }
View Full Code Here


        cwriter.close();
    }

    private MessageWriter getWriter(MessageWriter writer, QName name, Type type) {
        MessageWriter cwriter;
        if (type.isAbstract()) {
            cwriter = writer.getElementWriter(name);
        } else {
            cwriter = writer.getElementWriter(name);
        }
View Full Code Here

    public void writeObject(Object object, MessageWriter writer,
                            Context context) throws DatabindingException {
        // add the content type attribute even if we are going to fall back.
        String contentType = getContentType(object, context);
        if (contentType != null && useXmimeBinaryType) {
            MessageWriter ctWriter = writer.getAttributeWriter(XML_MIME_CONTENT_TYPE);
            ctWriter.writeValue(contentType);
        }

        if (!context.isMtomEnabled()) {
            fallbackDelegate.writeObject(getBytes(object), writer, context);
            return;
        }
       
        Collection<Attachment> attachments = context.getAttachments();
        if (attachments == null) {
            attachments = new ArrayList<Attachment>();
            context.setAttachments(attachments);
        }

        String id = AttachmentUtil.createContentID(getSchemaType().getNamespaceURI());

        Attachment att = createAttachment(object, id);

        attachments.add(att);
       
        MessageWriter include = writer.getElementWriter(XOP_INCLUDE);
        MessageWriter href = include.getAttributeWriter(XOP_HREF);
        href.writeValue("cid:" + id);

        include.close();
    }
View Full Code Here

                    && ((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 != null ? part.getConcreteName()
                : type.getSchemaType());
            type.writeObject(obj, w2, context);
            w2.close();
        } catch (DatabindingException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

    @Override
    public void writeObject(Object object, MessageWriter writer, Context context)
        throws DatabindingException {
        if (null == object) {
            MessageWriter nilWriter = writer.getAttributeWriter(XSI_NIL);

            nilWriter.writeValue("true");

            nilWriter.close();
        } else {
            Type type = determineType(context, object.getClass());

            if (null == type) {
                TypeMapping tm = context.getTypeMapping();
View Full Code Here

            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());
        }
        aegisType.writeObject(obj, w2, context);
        w2.close();
    }
View Full Code Here

            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());
        }
        aegisType.writeObject(obj, w2, context);
        w2.close();
    }
View Full Code Here

        testWrite(doc);
    }

    public void write(MessageWriter writer) {
        MessageWriter nons = writer.getElementWriter("nons");
        nons.writeValue("nons");
        nons.close();

        MessageWriter intval = writer.getElementWriter("int");
        intval.writeValueAsInt(new Integer(10000));
        intval.close();

        MessageWriter child1 = writer.getElementWriter("child1", "urn:child1");
        MessageWriter att1 = child1.getAttributeWriter("att1");
        att1.writeValue("att1");
        att1.close();
        MessageWriter att2 = child1.getAttributeWriter("att2", "");
        att2.writeValue("att2");
        att2.close();
        MessageWriter att3 = child1.getAttributeWriter("att3", "urn:att3");
        att3.writeValue("att3");
        att3.close();
        MessageWriter att4 = child1.getAttributeWriter("att4", null);
        att4.writeValue("att4");
        att4.close();

        child1.close();

        writer.close();
    }
View Full Code Here

        // get AegisType 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);

        // log xml for debugging
View Full Code Here

    public void writeObject(Object object, MessageWriter writer,
                            Context context) throws DatabindingException {
        // add the content type attribute even if we are going to fall back.
        String contentType = getContentType(object, context);
        if (contentType != null && useXmimeBinaryType) {
            MessageWriter ctWriter = writer.getAttributeWriter(XML_MIME_CONTENT_TYPE);
            ctWriter.writeValue(contentType);
        }

        if (!context.isMtomEnabled()) {
            fallbackDelegate.writeObject(getBytes(object), writer, context);
            return;
        }
       
        Collection<Attachment> attachments = context.getAttachments();
        if (attachments == null) {
            attachments = new ArrayList<Attachment>();
            context.setAttachments(attachments);
        }

        String id = AttachmentUtil.createContentID(getSchemaType().getNamespaceURI());

        Attachment att = createAttachment(object, id);

        attachments.add(att);
       
        MessageWriter include = writer.getElementWriter(XOP_INCLUDE);
        MessageWriter href = include.getAttributeWriter(XOP_HREF);
        href.writeValue("cid:" + id);

        include.close();
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.aegis.xml.MessageWriter

Copyright © 2018 www.massapicom. 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.