Package org.codehaus.jettison.mapped

Examples of org.codehaus.jettison.mapped.MappedXMLStreamWriter


                                                     boolean serializeAsArray,
                                                     List<String> arrayKeys,
                                                     boolean dropRootElement) throws Exception {
       
        MappedNamespaceConvention convention = new PrefixRespectingMappedNamespaceConvention(config);
        AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
                                            convention,
                                            new OutputStreamWriter(os, UTF8));
        if (serializeAsArray) {
            if (arrayKeys != null) {
                for (String key : arrayKeys) {
                    xsw.serializeAsArray(key);
                }
            } else {
                String key = getKey(convention, qname);
                xsw.serializeAsArray(key);
            }
        }
        XMLStreamWriter writer = !writeXsiType || dropRootElement
            ? new IgnoreContentJettisonWriter(xsw, writeXsiType,
                                              dropRootElement ? qname : null) : xsw;
View Full Code Here


                                                     boolean serializeAsArray,
                                                     List<String> arrayKeys,
                                                     boolean dropRootElement) throws Exception {
       
        MappedNamespaceConvention convention = new PrefixRespectingMappedNamespaceConvention(config);
        AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
                                            convention,
                                            new OutputStreamWriter(os, UTF8));
        if (serializeAsArray) {
            if (arrayKeys != null) {
                for (String key : arrayKeys) {
                    xsw.serializeAsArray(key);
                }
            } else {
                String key = getKey(convention, qname);
                xsw.serializeAsArray(key);
            }
        }
        XMLStreamWriter writer = !writeXsiType || dropRootElement
            ? new IgnoreContentJettisonWriter(xsw, writeXsiType,
                                              dropRootElement ? qname : null) : xsw;
View Full Code Here

                if (null == config.getXml2JsonNs()) {
                    jmConfig = new Configuration();
                } else {
                    jmConfig = new Configuration(config.getXml2JsonNs());
                }
                return new MappedXMLStreamWriter(new MappedNamespaceConvention(jmConfig), writer);
            default:
                return null;
        }
    }
View Full Code Here

                if (null == config.getXml2JsonNs()) {
                    jmConfig = new Configuration();
                } else {
                    jmConfig = new Configuration(config.getXml2JsonNs());
                }
                return new MappedXMLStreamWriter(
                        new MappedNamespaceConvention(jmConfig), writer);
            default:
                return null;
        }
    }
View Full Code Here

                                                     boolean serializeAsArray,
                                                     List<String> arrayKeys,
                                                     boolean dropRootElement) throws Exception {
       
        MappedNamespaceConvention convention = new PrefixRespectingMappedNamespaceConvention(config);
        AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
                                            convention,
                                            new OutputStreamWriter(os, UTF8));
        if (serializeAsArray) {
            if (arrayKeys != null) {
                for (String key : arrayKeys) {
                    xsw.serializeAsArray(key);
                }
            } else {
                String key = getKey(convention, qname);
                xsw.serializeAsArray(key);
            }
        }
        XMLStreamWriter writer = !writeXsiType || dropRootElement
            ? new IgnoreContentJettisonWriter(xsw, writeXsiType,
                                              dropRootElement ? qname : null) : xsw;
View Full Code Here

        if (writeXsiType) {
            namespaceMap.putIfAbsent(XSI_URI, XSI_PREFIX);
        }
        Configuration c = new Configuration(namespaceMap);
        MappedNamespaceConvention convention = new MappedNamespaceConvention(c);
        AbstractXMLStreamWriter xsw = new MappedXMLStreamWriter(
                                            convention,
                                            new OutputStreamWriter(os, UTF8));
        if (serializeAsArray) {
            if (arrayKeys != null) {
                for (String key : arrayKeys) {
                    xsw.seriliazeAsArray(key);
                }
            } else {
                String key = getKey(convention, qname);
                xsw.seriliazeAsArray(key);
            }
        }
        XMLStreamWriter writer = !writeXsiType || dropRootElement
            ? new IgnoreContentJettisonWriter(xsw, writeXsiType,
                                              dropRootElement ? qname : null) : xsw;
View Full Code Here

                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;
    }
View Full Code Here

                } catch (XMLStreamException ex) {
                    throw new RuntimeException(ex);
                }
                callback = null; // this doesn't make sense
            } else if (mediaType == MediaType.APPLICATION_JSON) {
                xml = new MappedXMLStreamWriter(new MappedNamespaceConvention(), writer);
            } else {
                throw new RuntimeException("mediatype not handled " + mediaType);
            }
            return xml;
        }
View Full Code Here

      xmlToJsonNamespaces.put("http://www.example.org/b/Test", "test");
      xmlToJsonNamespaces.put("http://www.example.org/a/TestCanonical", "can");
      config.setXmlToJsonNamespaces(xmlToJsonNamespaces);
      MappedNamespaceConvention con = new MappedNamespaceConvention(config);
      StringWriter writer = new StringWriter();
      XMLStreamWriter xmlStreamWriter = new MappedXMLStreamWriter(con, writer);

      Marshaller marshaller = jc.createMarshaller();
      marshaller.marshal(JAXBXmlTypeProvider.wrapInJAXBElement(result, TestExtends.class), xmlStreamWriter);
      return writer.toString();
   }
View Full Code Here

   }

   public void marshal(Object o, Writer writer)
           throws JAXBException
   {
      MappedXMLStreamWriter mapped = new MappedXMLStreamWriter(convention, writer);
      marshaller.marshal(o, mapped);
   }
View Full Code Here

TOP

Related Classes of org.codehaus.jettison.mapped.MappedXMLStreamWriter

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.