/** * Construct a JettisonMappedXmlDriver with configuration. This constructor has been added * by special request of Jettison users to support JSON generated by older Jettison * versions. if the driver is setup to ignore the XStream hints for JSON arrays, there is * neither support from XStream's side nor are there any tests to ensure this mode. * * @param config the Jettison configuration * @param useSerializeAsArray flag to use XStream's hints for collections and arrays * @since 1.4 */ public JettisonMappedXmlDriver(final Configuration config, final boolean useSerializeAsArray) { mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); this.useSerializeAsArray = useSerializeAsArray; }
public HierarchicalStreamWriter createWriter(final Writer writer) { try { if (useSerializeAsArray) { return new JettisonStaxWriter(new QNameMap(), mof.createXMLStreamWriter(writer), getNameCoder(), convention); } else { return new StaxWriter(new QNameMap(), mof.createXMLStreamWriter(writer), getNameCoder()); } } catch (final XMLStreamException e) { throw new StreamException(e); } }
@Override protected XMLStreamWriter getJSONWriter(Writer writer, MessageContext messageContext) throws XMLStreamException { return new MappedXMLOutputFactory(JSONUtil.getNS2JNSMap( messageContext.getAxisService())).createXMLStreamWriter(writer); } }
@Override protected XMLStreamWriter getJSONWriter(Writer writer, MessageContext messageContext) throws XMLStreamException { return new MappedXMLOutputFactory(JSONUtil.getNS2JNSMap( messageContext.getAxisService())).createXMLStreamWriter(writer); } }
public MappedDOMDocumentSerializer(OutputStream output, Configuration con) { super(output, new MappedXMLOutputFactory(con)); }
break; case xmlMapped: marshaller.marshal(data, new MappedXMLOutputFactory(getNamespacesToPrefixes()).createXMLStreamWriter(outStream)); break; case badgerfish:
public HierarchicalStreamWriter createWriter(final OutputStream output) { try { if (useSerializeAsArray) { return new JettisonStaxWriter(new QNameMap(), mof.createXMLStreamWriter(output), getNameCoder(), convention); } else { return new StaxWriter(new QNameMap(), mof.createXMLStreamWriter(output), getNameCoder()); } } catch (final XMLStreamException e) { throw new StreamException(e); } }
public JettisonMappedXmlDriver() { final HashMap nstjsons = new HashMap(); mof = new MappedXMLOutputFactory(nstjsons); mif = new MappedXMLInputFactory(nstjsons); }
break; case xmlMapped: marshaller.marshal(data, new MappedXMLOutputFactory(getNamespacesToPrefixes()).createXMLStreamWriter(outStream)); break; case badgerfish:
protected HierarchicalStreamWriter createHierarchicalStreamWriter(Exchange exchange, Object body, OutputStream stream) throws XMLStreamException { if (isPrettyPrint()) { try { // the json spec. expects UTF-8 as the default encoding return new JsonWriter(new OutputStreamWriter(stream, "UTF-8")); } catch (UnsupportedEncodingException uee) { throw new XMLStreamException(uee); } } return new StaxWriter(new QNameMap(), mof.createXMLStreamWriter(stream)); }
public JsonDataFormat() { final Map<?, ?> nstjsons = new HashMap<>(); mof = new MappedXMLOutputFactory(nstjsons); mif = new MappedXMLInputFactory(nstjsons); }
case xmlMapped: data = prepareForJAXBMarshalling(data, request); marshaller.marshal(data, new MappedXMLOutputFactory(getNamespacesToPrefixes()).createXMLStreamWriter(outStream)); break; case badgerfish:
public HierarchicalStreamWriter createWriter(final OutputStream output) { try { if (useSerializeAsArray) { return new JettisonStaxWriter(new QNameMap(), mof.createXMLStreamWriter(output), convention); } else { return new StaxWriter(new QNameMap(), mof.createXMLStreamWriter(output)); } } catch (final XMLStreamException e) { throw new StreamException(e); } }
public XStreamConverter() { this.classMapper = new DefaultClassMapper(); Map nstjsons = new HashMap(); this.outputFactory = new MappedXMLOutputFactory(nstjsons); this.inputFactory = new MappedXMLInputFactory(nstjsons); this.objectMapper = new XStream(); }
public HierarchicalStreamWriter createWriter(final Writer writer) { try { if (useSerializeAsArray) { return new JettisonStaxWriter(new QNameMap(), mof.createXMLStreamWriter(writer), convention); } else { return new StaxWriter(new QNameMap(), mof.createXMLStreamWriter(writer)); } } catch (final XMLStreamException e) { throw new StreamException(e); } }
public XStreamConverter() { this.classMapper = new DefaultClassMapper(); Map nstjsons = new HashMap(); this.outputFactory = new MappedXMLOutputFactory(nstjsons); this.inputFactory = new MappedXMLInputFactory(nstjsons); this.objectMapper = new XStream(); }
public HierarchicalStreamWriter createWriter(final Writer writer) { try { return new StaxWriter(new QNameMap(), mof.createXMLStreamWriter(writer)); } catch (final XMLStreamException e) { throw new StreamException(e); } }
public JettisonMappedXmlDriver(final Configuration config, final boolean useSerializeAsArray) { mof = new MappedXMLOutputFactory(config); mif = new MappedXMLInputFactory(config); convention = new MappedNamespaceConvention(config); this.useSerializeAsArray = useSerializeAsArray; }
public HierarchicalStreamWriter createWriter(final Writer writer) { try { return new JettisonStaxWriter(new QNameMap(), mof.createXMLStreamWriter(writer), convention); } catch (final XMLStreamException e) { throw new StreamException(e); } }
import org.codehaus.jettison.mapped.MappedXMLOutputFactory; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLEventWriter; import javax.xml.stream.XMLInputFactory; import java.io.StringReader; import java.util.HashMap; public class Main { public static void main(String[] args) throws Exception { String xml = "<root><foo>foo string</foo><bar><x>1</x><y>5</y></bar></root>"; XMLEventReader reader = XMLInputFactory.newInstance() .createXMLEventReader(new StringReader(xml)); XMLEventWriter writer = new MappedXMLOutputFactory(new HashMap()) .createXMLEventWriter(System.out); writer.add(reader); writer.close(); reader.close(); } }