Search in sources :

Example 1 with AbstractXMLStreamWriter

use of org.codehaus.jettison.AbstractXMLStreamWriter in project entando-core by entando.

the class ApsJSONUtils method createStreamWriter.

public static XMLStreamWriter createStreamWriter(OutputStream os, QName qname, boolean writeXsiType, Configuration config, boolean serializeAsArray, List<String> arrayKeys, boolean dropRootElement, String enc) throws Exception {
    MappedNamespaceConvention convention = new MappedNamespaceConvention(config);
    AbstractXMLStreamWriter xsw = new CDataMappedXMLStreamWriter(convention, new OutputStreamWriter(os, enc));
    if (serializeAsArray) {
        if (arrayKeys != null) {
            for (String key : arrayKeys) {
                xsw.serializeAsArray(key);
            }
        } else if (qname != null) {
            String key = getKey(convention, qname);
            xsw.serializeAsArray(key);
        }
    }
    XMLStreamWriter writer = !writeXsiType || dropRootElement ? new IgnoreContentJettisonWriter(xsw, writeXsiType, dropRootElement) : xsw;
    return writer;
}
Also used : DelegatingXMLStreamWriter(org.apache.cxf.staxutils.DelegatingXMLStreamWriter) AbstractXMLStreamWriter(org.codehaus.jettison.AbstractXMLStreamWriter) XMLStreamWriter(javax.xml.stream.XMLStreamWriter) AbstractXMLStreamWriter(org.codehaus.jettison.AbstractXMLStreamWriter) MappedNamespaceConvention(org.codehaus.jettison.mapped.MappedNamespaceConvention) OutputStreamWriter(java.io.OutputStreamWriter)

Example 2 with AbstractXMLStreamWriter

use of org.codehaus.jettison.AbstractXMLStreamWriter in project cxf by apache.

the class JSONUtils method createStreamWriter.

// CHECKSTYLE:OFF
public static XMLStreamWriter createStreamWriter(OutputStream os, QName qname, boolean writeXsiType, Configuration config, boolean serializeAsArray, List<String> arrayKeys, boolean dropRootElement, String enc) throws Exception {
    // CHECKSTYLE:ON
    MappedNamespaceConvention convention = new MappedNamespaceConvention(config);
    AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(convention, new OutputStreamWriter(os, enc));
    if (serializeAsArray) {
        if (arrayKeys != null) {
            for (String key : arrayKeys) {
                xsw.serializeAsArray(key);
            }
        } else if (qname != null) {
            String key = getKey(convention, qname);
            xsw.serializeAsArray(key);
        }
    }
    return !writeXsiType || dropRootElement ? new IgnoreContentJettisonWriter(xsw, writeXsiType, dropRootElement) : xsw;
}
Also used : AbstractXMLStreamWriter(org.codehaus.jettison.AbstractXMLStreamWriter) MappedNamespaceConvention(org.codehaus.jettison.mapped.MappedNamespaceConvention) MappedXMLStreamWriter(org.codehaus.jettison.mapped.MappedXMLStreamWriter) OutputStreamWriter(java.io.OutputStreamWriter)

Aggregations

OutputStreamWriter (java.io.OutputStreamWriter)2 AbstractXMLStreamWriter (org.codehaus.jettison.AbstractXMLStreamWriter)2 MappedNamespaceConvention (org.codehaus.jettison.mapped.MappedNamespaceConvention)2 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)1 DelegatingXMLStreamWriter (org.apache.cxf.staxutils.DelegatingXMLStreamWriter)1 MappedXMLStreamWriter (org.codehaus.jettison.mapped.MappedXMLStreamWriter)1