use of org.codehaus.jettison.mapped.MappedNamespaceConvention in project jersey by jersey.
the class Stax2JettisonFactory method createWriter.
public static XMLStreamWriter createWriter(final Writer writer, final JettisonConfig config) throws IOException {
switch(config.getNotation()) {
case BADGERFISH:
return new BadgerFishXMLStreamWriter(writer);
case MAPPED_JETTISON:
Configuration jmConfig;
if (null == config.getXml2JsonNs()) {
jmConfig = new Configuration();
} else {
jmConfig = new Configuration(config.getXml2JsonNs());
}
final MappedXMLStreamWriter result = new MappedXMLStreamWriter(new MappedNamespaceConvention(jmConfig), writer);
for (String array : config.getArrayElements()) {
result.serializeAsArray(array);
}
return result;
default:
return null;
}
}
use of org.codehaus.jettison.mapped.MappedNamespaceConvention in project GeoGig by boundlessgeo.
the class JettisonRepresentation method createWriter.
private XMLStreamWriter createWriter(Writer writer) {
final MediaType mediaType = getMediaType();
XMLStreamWriter xml;
if (mediaType.getSubType().equalsIgnoreCase("xml")) {
try {
xml = XMLOutputFactory.newFactory().createXMLStreamWriter(writer);
} catch (XMLStreamException ex) {
throw new RuntimeException(ex);
}
} else if (mediaType == MediaType.APPLICATION_JSON) {
xml = new MappedXMLStreamWriter(new MappedNamespaceConvention(), writer);
} else {
throw new RuntimeException("mediatype not handled " + mediaType);
}
return xml;
}
use of org.codehaus.jettison.mapped.MappedNamespaceConvention 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;
}
Aggregations