We’ve already added support for Java code generation to XBinder. Now, support for Android is coming soon. This will be useful to people in at least two camps:
- XBinder Java users who want to reuse code on Android
- Android application developers who want a data binding solution but find out that Android doesn’t include JAXB
For those who aren’t familiar with Android, it is the open source OS for mobile phones that originated with Google. And, it runs Java code – sort of. It actually has its own VM, called Dalvik, which runs Dalvik Excutable (DEX) code. Android tools convert Java byte code to DEX. So, basically, Java code can run on Android just by using this conversion tool.
The problem, for you and for us, is that Android doesn’t implement the full Java 5 API. Things like JAXB and StAX are missing. Thus, no data binding and no nice “pull parser”, streaming API for XML. Enter XBinder’s Android support.
Our Android support provides the missing pieces. Instead of JAXB, you use XBinder as your data binding solution. Given your XML Schema, XBinder generates classes that model your data, along with methods for encoding/decoding to/from XML. No more writing code to parse your XML (check out our comparison of coding with and without XBinder). Using the StAX API, XBinder does the parsing for you.
Now, if you are paying attention, you’ll notice that I said Android is missing StAX but XBinder uses it. This is one of the more interesting aspects of our Android support. One of those missing pieces that XBinder provides is an implementation of StAX (as complete an implementation as was required by XBinder). Of course, you are free to take your favorite StAX implementation, get it working on Android, and use it with XBinder. However, we think our implementation is special in that 1) it is ready to use and 2) it has a small footprint, thanks to XmlPull.
What is XmlPull? It is another “pull-parser” API very similar to StAX. While Android doesn’t come with StAX, it does come with an implementation of XmlPull. We kept our runtime small by implementing StAX as a thin layer over XmlPull. Thus, the bulk of what is needed is already present on the Android device.
XBinder’s Android support is expected to be available in a few weeks.