Joda - Next Generation Beans


Joda Time
   Time home

Joda Primitives
   Primitives home

Joda Beans
   Beans home
   Problem statement
   Design overview
   Getting started
   Swing binding
   XML input/output
   XPath access
   API Javadoc











Joda XPath integration

Joda's XPath integration aims to ease the process of accessing data from the object model. The XPath engine used is Jaxen which has proved easy to use.

The XPath engine operates directly on the object model. This means that there is no intermediate step of converting the model to XML before querying takes place. This makes the search quite efficient.

Joda XPath

A Joda domain model bean can be queried using XPath easily:

  1. Create the XPath query
  2. Create the Joda domain model bean
  3. Query the bean
XPath xpath = new XPath("address[2]/town/text()");
Profile profile = (Profile) JodaFactory.create(Profile.class);
String str = (String) xpath.selectSingleNode(profile);

In this example, the xpath means get the text of the town of the second address of the object passed in. (In this case str will be null because no data was added to the profile. Jaxen is used internally to traverse the domain model and thus all Jaxen xpath support is available.

It is possible to extract text, property objects and beans using the XPath class. It is also possible to retrieve a list of results and not just one as shown above.

Current status

Joda currently supports standard XPath notation as supported by Jaxen. The todo list includes an implementation of a more Java-friendly (less XML like) syntax.