public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException { return new MappedXMLStreamWriter(convention, writer); } }
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; } }
public XMLStreamWriter createXMLStreamWriter(Writer writer) throws XMLStreamException { return new MappedXMLStreamWriter(convention, writer); } }
public void marshal(Object o, Writer writer) throws JAXBException { MappedXMLStreamWriter mapped = new MappedXMLStreamWriter(convention, writer); marshaller.marshal(o, mapped); }
private String marshall(Object object) throws JAXBException { try { StringWriter writer = new StringWriter(); MappedXMLStreamWriter mappedXMLStreamWriter = new MappedXMLStreamWriter(convention, writer); // AbstractXMLStreamWriter mappedXMLStreamWriter = new BadgerFishXMLStreamWriter(writer); marshaller.marshal(object, mappedXMLStreamWriter); return writer.toString(); } catch (JAXBException e) { log.error("Error marshalling Object: " + object, e); throw e; } } }
jmConfig = new Configuration(config.getXml2JsonNs()); return new MappedXMLStreamWriter(new MappedNamespaceConvention(jmConfig), writer); default: return null;
private static String convertToJSON(Element rootElement) throws Exception { Configuration config = new Configuration(); config.setTypeConverter(new SimpleConverter()); MappedNamespaceConvention con = new MappedNamespaceConvention(config); StringWriter strWriter = new StringWriter(); AbstractXMLStreamWriter w = new MappedXMLStreamWriter(con, strWriter); w.writeStartDocument(); converToJSON(rootElement, w); w.writeEndDocument(); w.close(); strWriter.close(); String jsonString = strWriter.toString(); StringWriter wr = new StringWriter(); StringEscapeUtils.unescapeJavaScript(wr, jsonString); String result = wr.toString(); return result; }
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; }
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; }
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); } } XMLStreamWriter writer = !writeXsiType || dropRootElement ? new IgnoreContentJettisonWriter(xsw, writeXsiType, dropRootElement) : xsw; return writer; }
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; } }
public static XMLStreamWriter createWriter(Writer writer, JsonConfiguration config, boolean writingList) throws IOException { switch (config.getNotation()) { case NATURAL: final JsonGenerator rawGenerator = new JsonFactory().createJsonGenerator(writer); if (config.isHumanReadableFormatting()) { rawGenerator.useDefaultPrettyPrinter(); } final JsonGenerator bodyGenerator = writingList ? JacksonArrayWrapperGenerator.createArrayWrapperGenerator(rawGenerator, config.isRootUnwrapping() ? 0 : 1) : rawGenerator; if (config.isRootUnwrapping()) { return new Stax2JacksonWriter(JacksonRootStrippingGenerator.createRootStrippingGenerator(bodyGenerator, writingList ? 2 : 1), config); } else { return new Stax2JacksonWriter(bodyGenerator, config); } case MAPPED: return JsonXmlStreamWriter.createWriter(writer, config); case BADGERFISH: return new BadgerFishXMLStreamWriter(writer); case MAPPED_JETTISON: Configuration jmConfig; if (null == config.getXml2JsonNs()) { jmConfig = new Configuration(); } else { jmConfig = new Configuration(config.getXml2JsonNs()); } return new MappedXMLStreamWriter(new MappedNamespaceConvention(jmConfig), writer); default: return null; } }
jmConfig = new Configuration(config.getXml2JsonNs()); return new MappedXMLStreamWriter(new MappedNamespaceConvention(jmConfig), writer); default: return null;
jmConfig = new Configuration(config.getXml2JsonNs()); return new MappedXMLStreamWriter(new MappedNamespaceConvention(jmConfig), writer); default: return null;