Examples of XoXMLStreamWriterImpl


Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

                throw new MarshalException("Object must be annotated with @XmlRootElement or be a JAXBElement!");
            }
           
            Boolean frag = (Boolean) getProperty(Marshaller.JAXB_FRAGMENT);
           
            XoXMLStreamWriter w = new XoXMLStreamWriterImpl(xsw);
            if (frag == null || !frag) {
                w.writeStartDocument();
            }
           
            JAXBElement jaxbElement = null;
            if (o instanceof JAXBElement) {
                jaxbElement = (JAXBElement) o;
            }
           
            if (jaxbElement != null) {
                QName n = jaxbElement.getName();
                w.writeStartElement("",  n.getLocalPart(), n.getNamespaceURI());
                // TODO: we should check to see if a NS is already written here
                w.writeDefaultNamespace(n.getNamespaceURI());
               
                o = jaxbElement.getValue();
            }
           
            if (o == null) {
                w.writeXsiNil();
            } else {
                Class c = o.getClass();
                if (c == String.class) {
                    w.writeCharacters((String) o);
                } else if (c == Boolean.class) {
                    w.writeBoolean((Boolean) o);
                } else if (c == Byte.class) {
                    w.writeByte((Byte) o);
                } else if (c == Double.class) {
                    w.writeDouble((Double) o);
                } else if (c == Float.class) {
                    w.writeFloat((Float) o);
                } else if (c == Long.class) {
                    w.writeLong((Long) o);
                } else if (c == Integer.class) {
                    w.writeInt((Integer) o);
                } else if (c == Short.class) {
                    w.writeShort((Short) o);
                } else if (c == Duration.class) {
                    w.writeCharacters(((Duration) o).toString());
                } else if (c == XMLGregorianCalendar.class) {
                    w.writeCharacters(((XMLGregorianCalendar) o).toXMLFormat());
                } else if (c == byte[].class) {
                    BinaryUtils.encodeBytes(w, (byte[]) o);
                } else {
                    context.createWriter().write(w, o);
                }
            }
           
            if (jaxbElement != null) {
                w.writeEndElement();
            }
           
            if (frag == null || !frag) {
                w.writeEndDocument();
            }
        } catch (Exception e) {
            if (e instanceof JAXBException) {
                throw (JAXBException) e;
            } else if (e instanceof RuntimeException) {
View Full Code Here

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

        try {
            if (!introspector.isElement(o)) {
                throw new MarshalException("Object must be annotated with @XmlRootElement or be a JAXBElement!");
            }
           
            XoXMLStreamWriter w = new XoXMLStreamWriterImpl(xsw);
            if (writeStartAndEnd) {
                w.writeStartDocument();
            }
           
            JAXBElement jaxbElement = null;
            if (o instanceof JAXBElement) {
                jaxbElement = (JAXBElement) o;
            }
           
            if (jaxbElement != null) {
                QName n = jaxbElement.getName();
                w.writeStartElement("",  n.getLocalPart(), n.getNamespaceURI());
                // TODO: we should check to see if a NS is already written here
                w.writeDefaultNamespace(n.getNamespaceURI());
               
                o = jaxbElement.getValue();
            }
           
            if (o == null) {
                w.writeXsiNil();
            } else {
                Class c = o.getClass();
                if (c == String.class) {
                    w.writeCharacters((String) o);
                } else if (c == Boolean.class) {
                    w.writeBoolean((Boolean) o);
                } else if (c == Byte.class) {
                    w.writeByte((Byte) o);
                } else if (c == Double.class) {
                    w.writeDouble((Double) o);
                } else if (c == Float.class) {
                    w.writeFloat((Float) o);
                } else if (c == Long.class) {
                    w.writeLong((Long) o);
                } else if (c == Integer.class) {
                    w.writeInt((Integer) o);
                } else if (c == Short.class) {
                    w.writeShort((Short) o);
                } else if (c == Duration.class) {
                    w.writeCharacters(((Duration) o).toString());
                } else if (c == XMLGregorianCalendar.class) {
                    w.writeCharacters(((XMLGregorianCalendar) o).toXMLFormat());
                } else if (c == byte[].class) {
                    BinaryUtils.encodeBytes(w, (byte[]) o);
                } else {
                    context.createWriter().write(w, o);
                }
            }
           
            if (jaxbElement != null) {
                w.writeEndElement();
            }
           
            if (writeStartAndEnd) {
                w.writeEndDocument();
            }
        } catch (Exception e) {
            if (e instanceof JAXBException) {
                throw (JAXBException) e;
            } else if (e instanceof RuntimeException) {
View Full Code Here

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

        if (isFormattedOutput()) {
            writer = new PrettyPrintXMLStreamWriter(writer);
        }

        // writer with out custom extension
        XoXMLStreamWriter w = new XoXMLStreamWriterImpl(writer);

        try {
            // if the is not a fragment, write the document header
            if (!isFragment()) {
                w.writeStartDocument(getEncoding(), null);
            }

            // write xsi:type if there is no default root element for this type
            boolean writeXsiType = true;
            if (jaxbElement instanceof JAXBElement) {
                writeXsiType = ((JAXBElement)jaxbElement).isTypeSubstituted();
            } else {
                JAXBObject jaxbObject = introspector.getJaxbMarshaller(jaxbElement.getClass());
                if (jaxbObject != null) {
                    writeXsiType = jaxbObject.getXmlRootElement() == null && jaxbObject.getXmlType() != null;
                }
            }

            write(jaxbElement, w, new RuntimeContext(this), true, writeXsiType);

            if (!isFragment()) {
                w.writeEndDocument();
            }
        } catch (XMLStreamException e) {
            throw new MarshalException(e);
        }
    }
View Full Code Here

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

            w.close();
        }
    }

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

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

    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

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

        }
        return xof;
    }
   
    public void write(XMLStreamWriter xsr, Object o) throws Exception {
        write(new XoXMLStreamWriterImpl(xsr), o);
    }
View Full Code Here

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

    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

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

        write(w, o);
        w.close();
    }
   
    public void write(XMLStreamWriter xsr, Object o) throws Exception {
        write(new XoXMLStreamWriterImpl(xsr), o);
    }
View Full Code Here

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

    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

Examples of com.envoisolutions.sxc.util.XoXMLStreamWriterImpl

        write(w, o);
        w.close();
    }
   
    public void write(XMLStreamWriter xsr, Object o) throws Exception {
        write(new XoXMLStreamWriterImpl(xsr), o);
    }
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.