Package org.eclipse.persistence.jaxb

Examples of org.eclipse.persistence.jaxb.JAXBMarshaller$CharacterEscapeHandlerWrapper


    }

    @Override
    public void marshal(T object, XMLStreamWriter output,
            AttachmentMarshaller am) throws JAXBException {
        JAXBMarshaller marshaller = null;
        try {
            marshaller = parent.mpool.allocate();
            marshaller.setAttachmentMarshaller(am);
            marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT,
                    true);
            boolean isEx = (output instanceof XMLStreamWriterEx);
            if (mappingInfo != null) {
                if (isParameterizedType) {
                    JAXBTypeElement jte = new JAXBTypeElement(
                            mappingInfo.getXmlTagName(), object,
                            (ParameterizedType) mappingInfo.getType());
                    if (isEx) {
                        marshaller.marshal(jte, new NewStreamWriterRecord(
                                (XMLStreamWriterEx) output), mappingInfo);
                    } else {
                        marshaller.marshal(jte, output, mappingInfo);
                    }
                } else {
                    JAXBElement<T> elt = new JAXBElement<T>(
                            mappingInfo.getXmlTagName(),
                            (Class<T>) typeInfo.type, object);
                    if (isEx) {
                        marshaller.marshal(elt, new NewStreamWriterRecord(
                                (XMLStreamWriterEx) output), mappingInfo);
                    } else {
                        marshaller.marshal(elt, output, mappingInfo);
                    }
                }
            } else {
                if (isEx) {
                    marshaller.marshal(object, new NewStreamWriterRecord(
                            (XMLStreamWriterEx) output));
                } else {
                    marshaller.marshal(object, output);
                }
            }
        } finally {
            if (marshaller != null) {
                marshaller.setAttachmentMarshaller(null);
                parent.mpool.replace(marshaller);
            }
        }
    }
View Full Code Here


    // TODO NamespaceContext nsContext
    @Override
    public void marshal(T object, OutputStream output,
            NamespaceContext nsContext, AttachmentMarshaller am)
            throws JAXBException {
        JAXBMarshaller marshaller = null;

        try {
            marshaller = parent.mpool.allocate();
            marshaller.setAttachmentMarshaller(am);
            marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT,
                    true);
            if (mappingInfo != null) {
                if (isParameterizedType) {
                    JAXBTypeElement jte = new JAXBTypeElement(
                            mappingInfo.getXmlTagName(), object,
                            (ParameterizedType) mappingInfo.getType());
                    marshaller.marshal(jte, new StreamResult(output),
                            mappingInfo);
                } else {
                    JAXBElement<T> elt = new JAXBElement<T>(
                            mappingInfo.getXmlTagName(),
                            (Class<T>) mappingInfo.getType(), object);
                    // marshaller.marshal(elt, output);
                    // GAG missing
                    marshaller.marshal(elt, new StreamResult(output),
                            mappingInfo);
                }
            } else {
                marshaller.marshal(object, output);
            }
        } finally {
            if (marshaller != null) {
                marshaller.setAttachmentMarshaller(null);
                parent.mpool.replace(marshaller);
            }
        }
    }
View Full Code Here

        }
    }

    @Override
    public void marshal(T object, Node output) throws JAXBException {
        JAXBMarshaller marshaller = null;
        try {
            marshaller = parent.mpool.allocate();
            // marshaller.setAttachmentMarshaller(am);
            marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT,
                    true);
            if (mappingInfo != null) {
                if (isParameterizedType) {
                    JAXBTypeElement jte = new JAXBTypeElement(
                            mappingInfo.getXmlTagName(), object,
                            (ParameterizedType) mappingInfo.getType());
                    marshaller.marshal(jte, new DOMResult(output), mappingInfo);
                } else {
                    JAXBElement<T> elt = new JAXBElement<T>(
                            mappingInfo.getXmlTagName(),
                            (Class<T>) mappingInfo.getType(), object);
                    // marshaller.marshal(elt, output);
                    marshaller.marshal(elt, new DOMResult(output), mappingInfo);
                }
            } else {
                marshaller.marshal(object, output);
            }
        } finally {
            if (marshaller != null) {
                marshaller.setAttachmentMarshaller(null);
                parent.mpool.replace(marshaller);
            }
        }
    }
View Full Code Here

    }

    @Override
    public void marshal(T object, ContentHandler contentHandler,
            AttachmentMarshaller am) throws JAXBException {
        JAXBMarshaller marshaller = null;
        try {
            marshaller = parent.mpool.allocate();
            marshaller.setAttachmentMarshaller(am);
            marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT,
                    true);
            if (mappingInfo != null) {
                if (isParameterizedType) {
                    JAXBTypeElement jte = new JAXBTypeElement(
                            mappingInfo.getXmlTagName(), object,
                            (ParameterizedType) mappingInfo.getType());
                    marshaller.marshal(jte, new SAXResult(contentHandler),
                            mappingInfo);
                } else {
                    JAXBElement<T> elt = new JAXBElement<T>(
                            mappingInfo.getXmlTagName(),
                            (Class<T>) mappingInfo.getType(), object);
                    // marshaller.marshal(elt, contentHandler);

                    // GAG missing
                    marshaller.marshal(elt, new SAXResult(contentHandler),
                            mappingInfo);

                    // marshaller.marshal(elt, contentHandler, mappingInfo);
                }
            } else {
                marshaller.marshal(object, contentHandler);
            }
        } finally {
            if (marshaller != null) {
                marshaller.setAttachmentMarshaller(null);
                parent.mpool.replace(marshaller);
            }
        }
    }
View Full Code Here

        }
    }

    @Override
    public void marshal(T object, Result result) throws JAXBException {
        JAXBMarshaller marshaller = null;
        try {
            marshaller = parent.mpool.allocate();
            marshaller.setAttachmentMarshaller(null);
            marshaller.setProperty(javax.xml.bind.Marshaller.JAXB_FRAGMENT,
                    true);
            if (mappingInfo != null) {
                if (isParameterizedType) {
                    JAXBTypeElement jte = new JAXBTypeElement(
                            mappingInfo.getXmlTagName(), object,
                            (ParameterizedType) mappingInfo.getType());
                    marshaller.marshal(jte, result, mappingInfo);
                } else {
                    JAXBElement<T> elt = new JAXBElement<T>(
                            mappingInfo.getXmlTagName(),
                            (Class<T>) mappingInfo.getType(), object);
                    // marshaller.marshal(elt, result);
                    marshaller.marshal(elt, result, mappingInfo);
                }
            } else {
                TypeMappingInfo tmi = null;
                if (object instanceof JAXBElement) {
                    QName q = ((JAXBElement) object).getName();
                    JAXBContext ctx = (JAXBContext) parent.getJAXBContext();

                    Map<TypeMappingInfo, QName> mtq = ctx
                            .getTypeMappingInfoToSchemaType();
                    for (Map.Entry<TypeMappingInfo, QName> es : mtq.entrySet()) {
                        if (q.equals(es.getValue())) {
                            tmi = es.getKey();
                            break;
                        }

                    }
                }
                if (tmi != null) {
                    marshaller.marshal(object, result, tmi);
                } else {
                    marshaller.marshal(object, result);
                }
            }
        } finally {
            if (marshaller != null) {
                marshaller.setAttachmentMarshaller(null);
                parent.mpool.replace(marshaller);
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.eclipse.persistence.jaxb.JAXBMarshaller$CharacterEscapeHandlerWrapper

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.