commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "James Strachan" <>
Subject Re: [Betwixt] Documentation
Date Mon, 19 Nov 2001 10:35:15 GMT
Hi Robert

By all means dive in and add comments whereever you think is a good idea.
The best way to get a feel for what betwixt can do right now is looking at
the JUnit test cases in src/test/*.

I've been a bit side tracked with Messenger and dom4j lately but I'd like to
get back to betwixt very soon (a week or so) to do a bean Navigator for
Jaxen. Also it'd be interesting to see how easy it would be to use betwixt
to generate digester rules from a bean class.

Betwixt uses introspection to determine a default XML representation model
for a bean (which can be overridden by providing a custom XMLBeanInfo class
in the same way as BeanInfo in the Java Beans spec).

e.g. Here's the code that given any Class could determine what elements &
attributes are available in XML...

Class aClass = ...;
XMLIntrospector introspector = new XMLIntrospector();
XMLBeanInfo xmlInfo = introspector.introspect( aClass );

// root element
XMLElementDescriptor root = xmlInfo.getElementDescriptor();

// attributes of root
XMLElementDescriptor[] attributes = root.getAttributeDescriptors();

// child elements
XMLElementDescriptor[] elements = root.getElementDescriptors();

Though I must admit that right now betwixt is a little one directional; the
ElementDescriptor & AttributeDescriptor take an Expression that when
evaluated on a bean will return an object - so its an abstraction on getting
a property name, iterating or calling a method etc. This allows a very
flexible mappings to occur - such as
mapping a Map using the entrySet() method etc. Though this may make it a
little harder to write an XML -> Object generator, such as to generate
digester rules.

----- Original Message -----
From: "robert burrell donkin" <>
> hi james
> i'm quite keen to take a look at betwixt but the documentation's a bit
> sparse.
> i could probably create some documentation patches if you like (since i'll
> probably end up writing java doc comments in order to understand it
> ..)
> - robert

Do You Yahoo!?
Get your free address at

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message