Package org.metatype.sxc.util

Examples of org.metatype.sxc.util.XoXMLStreamWriterImpl


        XMLStreamWriter writer = null;
        try {
            final XMLOutputFactory xof = getXmOutputFactory();
            writer = xof.createXMLStreamWriter(streamResult.getOutputStream(), "UTF-8");
            writer = new PrettyPrintXMLStreamWriter(writer);
            final XoXMLStreamWriter w = new XoXMLStreamWriterImpl(writer);

            try {
                w.writeStartDocument("UTF-8", null);

                // write xsi:type if there is no default root element for this type

                final RuntimeContext context = new RuntimeContext((ExtendedMarshaller) null);

                try {

                    final QName name = objectType.getXmlRootElement();

                    // open element
                    w.writeStartElementWithAutoPrefix(name.getNamespaceURI(), name.getLocalPart());

                    objectType.write(w, object, context);

                    w.writeEndElement();
                } catch (Exception e) {
                    if (e instanceof JAXBException) {
                        // assume event handler has already been notified
                        throw (JAXBException) e;
                    }
                    if (e instanceof RuntimeXMLStreamException) {
                        // simply unwrap and handle below
                        e = ((RuntimeXMLStreamException) e).getCause();
                    }

                    if (e instanceof XMLStreamException) {
                        final Throwable cause = e.getCause();
                        if (cause instanceof JAXBException) {
                            throw (JAXBException) e;
                        }
                        throw new MarshalException(cause == null ? e : cause);
                    }
                    throw new MarshalException(e);

                }

                w.writeEndDocument();
            } catch (final Exception e) {
                throw new MarshalException(e);
            }

View Full Code Here


        XMLStreamWriter writer = null;
        try {
            final XMLOutputFactory xof = getXmOutputFactory();
            writer = xof.createXMLStreamWriter(streamResult.getOutputStream(), "UTF-8");
            writer = new PrettyPrintXMLStreamWriter(writer);
            final XoXMLStreamWriter w = new XoXMLStreamWriterImpl(writer);

            try {
                w.writeStartDocument("UTF-8", null);

                // write xsi:type if there is no default root element for this type

                final RuntimeContext context = new RuntimeContext((ExtendedMarshaller) null);

                try {

                    final QName name = objectType.getXmlRootElement();

                    // open element
                    w.writeStartElementWithAutoPrefix(name.getNamespaceURI(), name.getLocalPart());

                    objectType.write(w, object, context);

                    w.writeEndElement();
                } catch (Exception e) {
                    if (e instanceof JAXBException) {
                        // assume event handler has already been notified
                        throw (JAXBException) e;
                    }
                    if (e instanceof RuntimeXMLStreamException) {
                        // simply unwrap and handle below
                        e = ((RuntimeXMLStreamException) e).getCause();
                    }

                    if (e instanceof XMLStreamException) {
                        final Throwable cause = e.getCause();
                        if (cause instanceof JAXBException) {
                            throw (JAXBException) e;
                        }
                        throw new MarshalException(cause == null ? e : cause);
                    }
                    throw new MarshalException(e);

                }

                w.writeEndDocument();
            } catch (final Exception e) {
                throw new MarshalException(e);
            }

View Full Code Here

            w.close();
        }
    }

    public void write(XMLStreamWriter writer, T o) throws Exception {
        write(new XoXMLStreamWriterImpl(writer), o);
    }
View Full Code Here

    public void write(XMLStreamWriter writer, T o) throws Exception {
        write(new XoXMLStreamWriterImpl(writer), o);
    }

    public void write(XMLStreamWriter writer, T o, RuntimeContext context) throws Exception {
        write(new XoXMLStreamWriterImpl(writer), o, context);
    }
View Full Code Here

    protected XMLOutputFactory getXMLOutputFactory() {
        return XmlFactories.getXof();
    }
   
    public void write(XMLStreamWriter xsr, Object o) throws Exception {
        write(new XoXMLStreamWriterImpl(xsr), o);
    }
View Full Code Here

    public void write(XMLStreamWriter xsr, Object o) throws Exception {
        write(new XoXMLStreamWriterImpl(xsr), o);
    }
   
    public void write(XMLStreamWriter xsr, Object o,  Map<String, Object> properties) throws Exception {
        write(new XoXMLStreamWriterImpl(xsr), o, properties);
    }   
View Full Code Here

        XMLStreamWriter writer = null;
        try {
            final XMLOutputFactory xof = getXmOutputFactory();
            writer = xof.createXMLStreamWriter(streamResult.getOutputStream(), "UTF-8");
            writer = new PrettyPrintXMLStreamWriter(writer);
            XoXMLStreamWriter w = new XoXMLStreamWriterImpl(writer);

            try {
                w.writeStartDocument("UTF-8", null);

                // write xsi:type if there is no default root element for this type

                final RuntimeContext context = new RuntimeContext((ExtendedMarshaller) null);

                try {

                    QName name = objectType.getXmlRootElement();

                    // open element
                    w.writeStartElementWithAutoPrefix(name.getNamespaceURI(), name.getLocalPart());

                    objectType.write(w, object, context);

                    w.writeEndElement();
                } catch (Exception e) {
                    if (e instanceof JAXBException) {
                        // assume event handler has already been notified
                        throw (JAXBException) e;
                    }
                    if (e instanceof RuntimeXMLStreamException) {
                        // simply unwrap and handle below
                        e = ((RuntimeXMLStreamException) e).getCause();
                    }

                    if (e instanceof XMLStreamException) {
                        Throwable cause = e.getCause();
                        if (cause instanceof JAXBException) {
                            throw (JAXBException) e;
                        }
                        throw new MarshalException(cause == null ? e : cause);
                    }
                    throw new MarshalException(e);

                }

                w.writeEndDocument();
            } catch (Exception e) {
                throw new MarshalException(e);
            }

View Full Code Here

TOP

Related Classes of org.metatype.sxc.util.XoXMLStreamWriterImpl

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.