Hello,

My question is : Can we apply the same NameMapper to a bean reader ?

I thought it was possible but I can not read a bean that I have
serialized with the beanWriter using my own NameMapper.
Indeed the following code throws a NullPointerException at the last line:

        Writer writer = new StringWriter();
        writer.write(XML_HEADER);
        BeanWriter beanWriter = new BeanWriter(writer);
        
beanWriter.getXMLIntrospector().getConfiguration().setAttributesForPrimitives(false);
        beanWriter.getBindingConfiguration().setMapIDs(false);
        beanWriter.enablePrettyPrint();

        
beanWriter.getXMLIntrospector().getConfiguration().setElementNameMapper(new
MyOwnNameMapper());

        MyBean myBean = new MyBean();
        myBean.setValue("toto");
        beanWriter.write(myBean);

        System.out.println(writer.toString());
       // At this point My bean has a good looking element name

        MyBean myBean2 =null;
        BeanReader reader = new BeanReader();
        reader.registerBeanClass(MyBean.class);

        
beanReader.getXMLIntrospector().getConfiguration().setElementNameMapper(new
MyOwnNameMapper());

        ref2 = (CDAReference) beanReader.parse(new
StringReader(writer.toString()));
        assertEquals(ref.getValue(), ref2.getValue());


Help wanted.

Laurent.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to