Examples of BeanWriter


Examples of org.apache.commons.betwixt.io.BeanWriter

     * Description of the Method
     */
    protected void write(Object bean, Writer out)
        throws Exception
    {
        BeanWriter writer = new BeanWriter(out);
        writer.setXMLIntrospector(createXMLIntrospector());
        writer.enablePrettyPrint();
        writer.write(bean);
    }
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

    }
   
    protected void write(Object bean, Writer out) throws Exception {
        //SimpleLog log = new SimpleLog("[TestRSSRoundTrip:BeanWriter]");
        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
        BeanWriter writer = new BeanWriter(out);
        //writer.setLog(log);
        //log = new SimpleLog("[TestRSSRoundTrip:AbstractBeanWriter]");
        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
        //writer.setAbstractBeanWriterLog(log);
        writer.setWriteEmptyElements(true);
        writer.getXMLIntrospector().setAttributesForPrimitives(false);
        writer.setWriteIDs(false);
        writer.enablePrettyPrint();
        writer.write( bean );
    }
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

       
    public void write(Object bean) throws Exception {
        if ( bean == null ) {
            throw new Exception( "No bean read from the XML document!" );
        }
        BeanWriter writer = new BeanWriter();
        writer.getXMLIntrospector().setAttributesForPrimitives(false);
        writer.enablePrettyPrint();
        writer.write( bean );
    }
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

        houseTwo.setTenant(true);
        houses.addHouse(houseTwo);
       
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
        writer.getXMLIntrospector().setAttributesForPrimitives(true);
        writer.getXMLIntrospector().setWrapCollectionsInElement(false);
        writer.write("houses", houses);
       
        String xml = "<?xml version='1.0'?><houses>"
            + "<house tenant='false'>"
            + "<address street='Black Bull, 46 Briggate' city='Brighouse' country='England' code='HD6 1EF'/>"
            + "<householder forename='Samual' surname='Smith'/>"
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

        houseTwo.setTenant(true);
        houses.addHouse(houseTwo);
       
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
        writer.getXMLIntrospector().setAttributesForPrimitives(true);
        writer.getXMLIntrospector().setWrapCollectionsInElement(false);
        writer.write("houses", houses);
       
        String xml = "<?xml version='1.0'?><houses>"
            + "<house tenant='false'>"
            + "<address street='Black Bull, 46 Briggate' city='Brighouse' country='England' code='HD6 1EF'/>"
            + "<householder forename='Samual' surname='Smith'/>"
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

    }
   
    public void testWriteArray() throws Exception {
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
        writer.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true);
        writer.getBindingConfiguration().setMapIDs(false);
       
        LibraryBean libraryBean = new LibraryBean();
        libraryBean.addBook(new BookBean("Martin Fowler", "Refactoring", "Addision Wesley"));
        libraryBean.addBook(new BookBean("Ben Laurie", "Apache", "O'Reilly"));
        libraryBean.addBook(new BookBean("Kent Beck", "Test Driven Development", "Addision Wesley"));
       
        writer.write(libraryBean);
        String xml = out.toString();
        String expected = "<?xml version='1.0'?><LibraryBean>" +
            "<books>" +
            "<book author='Martin Fowler' title='Refactoring' publisher='Addision Wesley'/>" +
            "<book author='Ben Laurie' title='Apache' publisher='O&apos;Reilly'/>" +
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

    }
   
    public void testWriteArrayWithSetter() throws Exception {
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
        writer.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true);
        writer.getBindingConfiguration().setMapIDs(false);
       
       
        LibraryBeanWithArraySetter libraryBean = new LibraryBeanWithArraySetter();
        BookBean[] books = {
            new BookBean("Martin Fowler", "Refactoring", "Addision Wesley"),
            new BookBean("Ben Laurie", "Apache", "O'Reilly"),
            new BookBean("Kent Beck", "Test Driven Development", "Addision Wesley")};
        libraryBean.setBooks(books);
       
        writer.write(libraryBean);
        String xml = out.toString();
        String expected = "<?xml version='1.0'?><LibraryBeanWithArraySetter>" +
            "<books>" +
            "<BookBean author='Martin Fowler' title='Refactoring' publisher='Addision Wesley'/>" +
            "<BookBean author='Ben Laurie' title='Apache' publisher='O&apos;Reilly'/>" +
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

        houseTwo.setTenant(true);
        houses.addHouse(houseTwo);
       
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
    writer.getBindingConfiguration().setMapIDs(false);
        writer.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true);
        writer.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(false);
        writer.write("houses", houses);
       
        String xml = "<?xml version='1.0'?><houses>"
            + "<house tenant='false'>"
            + "<address street='Black Bull, 46 Briggate' city='Brighouse' country='England' code='HD6 1EF'/>"
            + "<householder forename='Samual' surname='Smith'/>"
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

       
    public void write(Object bean) throws Exception {
        if ( bean == null ) {
            throw new Exception( "No bean read from the XML document!" );
        }
        BeanWriter writer = new BeanWriter();
        writer.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(false);
        writer.enablePrettyPrint();
        writer.write( bean );
    }
View Full Code Here

Examples of org.apache.commons.betwixt.io.BeanWriter

        houseTwo.setTenant(true);
        houses.addHouse(houseTwo);
       
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
    writer.getBindingConfiguration().setMapIDs(false);
        writer.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true);
        writer.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(false);
        writer.write("houses", houses);
       
        String xml = "<?xml version='1.0'?><houses>"
            + "<house tenant='false'>"
            + "<address street='Black Bull, 46 Briggate' city='Brighouse' country='England' code='HD6 1EF'/>"
            + "<householder forename='Samual' surname='Smith'/>"
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.