Package javax.xml.bind

Examples of javax.xml.bind.JAXBContext.createMarshaller()


   {
      Class<?> c = t.getDeclaredType();
      try
      {
         JAXBContext jaxbctx = getJAXBContext(c, mediaType);
         Marshaller m = jaxbctx.createMarshaller();
         // Must respect application specified character set.
         String charset = mediaType.getParameters().get("charset");
         if (charset != null)
            m.setProperty(Marshaller.JAXB_ENCODING, charset);
View Full Code Here


        producer.close();
    }
   
    private String writeBook(Book b) throws Exception {
        JAXBContext c = JAXBContext.newInstance(new Class[]{Book.class});
        Marshaller m = c.createMarshaller();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        m.marshal(b, bos);
        return bos.toString();
    }
}
View Full Code Here

   
        Factory factory = Abdera.getNewFactory();
        JAXBContext jc = jaxbProvider.getJAXBContext(cls, cls);
       
        StringWriter writer = new StringWriter();
        jc.createMarshaller().marshal(o, writer);
       
        Content ct = factory.newContent(Content.Type.XML);
        ct.setValue(writer.toString());
        e.setContentElement(ct);
    }
View Full Code Here

        return (Book)u.unmarshal(is);
    }
   
    private String writeBook(Book b) throws Exception {
        JAXBContext c = JAXBContext.newInstance(new Class[]{Book.class});
        Marshaller m = c.createMarshaller();
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        m.marshal(b, bos);
        return bos.toString();
    }
   
View Full Code Here

       
        Class<?> objClazz = JAXBElement.class.isAssignableFrom(cls)
                            ? ((JAXBElement)obj).getDeclaredType() : cls;
                           
        JAXBContext context = getJAXBContext(objClazz, genericType);
        Marshaller marshaller = context.createMarshaller();
        if (enc != null) {
            marshaller.setProperty(Marshaller.JAXB_ENCODING, enc);
        }
        if (marshallerListener != null) {
            marshaller.setListener(marshallerListener);
View Full Code Here

                Element hdr = getHeaderFactory().getHeader(message.getVersion());               
                JAXBContext jaxbContext =
                    VersionTransformer.getExposedJAXBContext(
                                                     maps.getNamespaceURI());
                Marshaller marshaller = jaxbContext.createMarshaller();
                QName duplicate = maps.getDuplicate();
                marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
                encodeAsExposed(maps,
                                message,
                                maps.getAction(),
View Full Code Here

        System.out.println("Found routes: " + list);

        // now lets marshall to XML
        JAXBContext context = JAXBContext.newInstance(RoutesType.class.getPackage().getName());
        StringWriter out = new StringWriter();
        context.createMarshaller().marshal(routes, out);
        String xml = out.toString();
        System.out.println("XML is: " + xml);
    }

    @Override
View Full Code Here

            try {
                return parentTypeConverter.convertTo(type, source);
            } catch (NoTypeConversionAvailableException e) {
                // lets try a stream
                StringWriter buffer = new StringWriter();
                Marshaller marshaller = context.createMarshaller();
                marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, isPrettyPrint() ? Boolean.TRUE : Boolean.FALSE);
                marshaller.marshal(value, buffer);
                return parentTypeConverter.convertTo(type, buffer.toString());
            }
        }
View Full Code Here

    }

    @Converter
    public Document toDocument(@HasAnnotation(XmlRootElement.class)Object value) throws JAXBException, ParserConfigurationException {
        JAXBContext context = getJaxbContext(value);
        Marshaller marshaller = context.createMarshaller();

        Document doc = getJaxbConverter().createDocument();
        marshaller.marshal(value, doc);
        return doc;
    }
View Full Code Here

       
        Class<?> objClazz = JAXBElement.class.isAssignableFrom(cls)
                            ? ((JAXBElement<?>)obj).getDeclaredType() : cls;
                           
        JAXBContext context = getJAXBContext(objClazz, genericType);
        Marshaller marshaller = context.createMarshaller();
        if (enc != null) {
            marshaller.setProperty(Marshaller.JAXB_ENCODING, enc);
        }
        if (marshallerListener != null) {
            marshaller.setListener(marshallerListener);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.