Is there an efficient way to programatically generate a list of supported devices based on a set of required capabilities using the WURFL APIs?
For example I have two versions of an application; one that runs on Nokia Series60 version 2 handsets (Symbian 7/8) and a different version that runs on Nokia Series60 version 3 handsets (Symbian 9). I need to get all such handset from the WURFL to present as on a 'supported handsets' page as well as check UAs of users who attempt to download so I can pass them the correct version of the application.
Conceptually I think I am looking for something like this:
return all devices that have capabilities :=
device_os == Symbian OS
&& nokia_series == 60
&& (nokia_edition == 2 || nokia_edition == 3)
I am looking to do this in Java.
I suggest using the new Java WURFL API to load and trawl through the capabilities database. It's pretty flexible that way, you should be able to implement your pseudo-code pretty quickly.
All the other answers talked about how to use the Java WURFL API. However, to speed up the search at runtime, I'd recommend storing a hashmap or dictionary in memory mapping the user agent string (or a trimmed down version of the original string) to its corresponding device info. The total amount of data should not be that big - merely on the order of megabytes. Also, the WURFL data is fairly static, so one can preprocess the entire dataset offline to build the hashmap. I usually preprocess and update the hashmap periodically, serialize the object, and load it during runtime.
I'm not aware of an API for this task. I've had to deal with this myself and ended up coding a public site to handle it: http://wurfl.ditherandbicker.com/
Since the base WURFL XML file is built for portability, a device's full capability matrix must be derived by reading from a variable number of "fall back devices". Many other WURFL-based projects behave the same way. In my experience you really need to translate the default, nested, data structure into a flat one if you hope to get any decent speed with your searches. Of course at that point you lose the portability benefits.