Skip to main content

A JAXB2 plugin to handle all-capital element names nicely

Posted by kohsuke on March 2, 2006 at 5:09 PM PST

Nicola Fagnani wrote a small but nice JAXB plugin that turns all capital element names like "FIRST_NAME" and "LAST_NAME" into a nice method name like "getFirstName" (the spec turns it into "getFIRSTNAME".) Besides being useful on its own, it's a good example of how you can programatically customize the XML name -> Java name conversion. I think writing a little code to do this is much more flexible than writing JAXB customization.

I'm asking him to move this plugin to JAXB2-commons, so that we can host a pre-built jar and etc there.

It also makes me wonder if it might be good if we let a plugin to be written in a scripting language. If a useful plugin like this could be written in this short code, then setting up a classpath, compiling, and packaging it up in a jar is actually a lot more work than writing it. If you can write it in Groovy (for example) and just pass that around, wouldn't it be more convenient? Or maybe all we need is a Maven goal to generate a plugin project template...