[jdom-interest] BeanMapper
    Alex Chaffee 
    guru at edamame.stinky.com
       
    Wed Sep 20 10:08:15 PDT 2000
    
    
  
Because there weren't enough XML Data Binding technologies already, I
just wrote one using JDOM.
org.jdom.contrib.beans.BeanMapper allows you to easily (I'd say
'trivially' but that would be taunting the gods) make a JDOM tree from
an existing JavaBean, and/or instantiate-and-fill one of your JavaBean
classes based on a JDOM tree.  By default it maps element names and
property names directly, but you can override that by setting
mappings; e.g. getFoo() could map to <foo>foovalue</foo> (the default)
or <bar>foovalue</bar> or <baz baf="foovalue">.
Usage:
BeanMapper mapper = new BeanMapper();
// Converting Bean to JDOM
Document doc = mapper.toDocument(mybean);
// Converting JDOM to Bean
TestBean mybean = mapper.toBean(doc);
It uses reflection, so it's not super-fast, but it's meant as a quick
way to get started if you've got a a lot of beans already written and
want to do XML import/export.
I seem to have misplaced my CVS password.  Jools, can you please
contact me about checking this in?  In the meantime, anyone who wants
to play, please email me privately.
 - A
-- 
Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/
    
    
More information about the jdom-interest
mailing list