Package org.apache.commons.betwixt.strategy

Examples of org.apache.commons.betwixt.strategy.HyphenatedNameMapper


        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0' encoding='UTF-8'?>");
       
        BeanWriter writer = new BeanWriter( out );
    writer.getBindingConfiguration().setMapIDs(false);
        writer.getXMLIntrospector().getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        writer.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(false);
       
        writer.write( bean );
       
        String xml = "<?xml version='1.0' encoding='UTF-8'?>"
View Full Code Here


        doTest(new DefaultNameMapper(), "default name mapper");
    }

    public void testHyphenatedNameMapper() throws Exception {
//        testLog.debug("Testing hyphenated name mapper");
        doTest(new HyphenatedNameMapper(), "hyphenated name mapper");
    }
View Full Code Here

            + "</example-bean>";
       
       
        BeanReader reader = new BeanReader();
        //reader.setLog(log);
        reader.getXMLIntrospector().getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        reader.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(false);
        reader.registerBeanClass( ExampleBean.class );
       
        StringReader in = new StringReader( xml );
        ExampleBean out = (ExampleBean) reader.parse( in );
View Full Code Here

        out.write("<?xml version='1.0'?>");
        writer = new BeanWriter(out);
        writer.setWriteEmptyElements(true);
        writer.getXMLIntrospector().getConfiguration().setWrapCollectionsInElement(true);
        writer.getBindingConfiguration().setMapIDs(false);
        writer.getXMLIntrospector().getConfiguration().setElementNameMapper(new HyphenatedNameMapper(false));
        writer.write(bean);
       
        xml = "<?xml version='1.0'?><no-adder-bean><things>"
         + "<name-bean><name>Sugar</name></name-bean>"
         + "<name-bean><name>Spice</name></name-bean>"
View Full Code Here

     * mapper is set.
     */
    public void testCreateDescriptorWithHyphenatedElementNameMapper() throws Exception {
        XMLIntrospector introspector = new XMLIntrospector();
        introspector.getConfiguration().setAttributesForPrimitives(false);
        introspector.getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        BeanInfo beanInfo = Introspector.getBeanInfo(CustomerBean.class);

        NodeDescriptor nickNameProperty = createDescriptor("nickName", beanInfo, introspector);
        assertNotNull("nickName property not found", nickNameProperty);
        assertEquals("nick name property", "nick-name", nickNameProperty.getLocalName());
View Full Code Here

        out.write("<?xml version='1.0'?>");
       
        BeanWriter writer = new BeanWriter(out);
    writer.getBindingConfiguration().setMapIDs(false);
        XMLIntrospector introspector = writer.getXMLIntrospector();
        introspector.getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        introspector.getConfiguration().setAttributesForPrimitives(false);
       
        writer.write("party", bean);

        String xml = "<?xml version='1.0'?><party>"
View Full Code Here

        out.write("<?xml version='1.0'?>");
       
        BeanWriter writer = new BeanWriter(out);
    writer.getBindingConfiguration().setMapIDs(false);
        XMLIntrospector introspector = writer.getXMLIntrospector();
        introspector.getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        introspector.getConfiguration().setAttributesForPrimitives(false);
       
        writer.write(bean);
       
        String xml = "<?xml version='1.0'?><party-bean>"
View Full Code Here

        out.write("<?xml version='1.0'?>");
       
        BeanWriter writer = new BeanWriter(out);
        writer.setBindingConfiguration(configuration);
        XMLIntrospector introspector = writer.getXMLIntrospector();
        introspector.getConfiguration().setElementNameMapper(new HyphenatedNameMapper());
        introspector.getConfiguration().setAttributesForPrimitives(false);
       
        writer.write("party", bean);

        String xml = "<?xml version='1.0'?><party>"
View Full Code Here

                    + "<CHILD><NAME>Poseidon</NAME></CHILD>"
                    + "<CHILD><NAME>Zeus</NAME></CHILD>"
                    + "</CHILDREN></DOUBLE_LINKED_PARENT_BEAN>";
                   
        BeanReader reader = new BeanReader();
        reader.getXMLIntrospector().getConfiguration().setElementNameMapper(new HyphenatedNameMapper(true, "_"));
        reader.registerBeanClass(DoubleLinkedParentBean.class);
        DoubleLinkedParentBean bean = (DoubleLinkedParentBean) reader.parse(new StringReader(xml));
       
        assertNotNull("Bean read", bean);
        assertEquals("Cronus", "Parent name", bean.getName());
View Full Code Here

    }
  
    private String generateOrderLineSchema() throws Exception {
        SchemaTranscriber transcriber = new SchemaTranscriber();
        transcriber.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(true);
        transcriber.getXMLIntrospector().getConfiguration().setAttributeNameMapper(new HyphenatedNameMapper());
        Schema schema = transcriber.generate(OrderLineBean.class);
       
        StringWriter out = new StringWriter();
        out.write("<?xml version='1.0'?>");
        BeanWriter writer = new BeanWriter(out);
View Full Code Here

TOP

Related Classes of org.apache.commons.betwixt.strategy.HyphenatedNameMapper

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.