» FastWurfl

welcome

Welcome to the FastWurfl open source project. The project provides an interface to WURFL XML files and is written in Java.

overview

The most important features of this project are

FastWurfl is suitable for CPU- and memory-constrained environments which need access to the WURFL capabilities.

The library comes in two flavors: standard based on StAX and realtime based on Javolution.

setup

Setting up is straightforward:

// create wurfl factory
WurflFactory wurflFactory = new WurflFactoryImpl();

// create wurfl instance
Wurfl wurfl = wurflFactory.newInstance(new File("wurfl.xml"), "UTF-8");

// add patch file
wurflFactory.parsePatch(wurfl, new File("wurfl_patch.xml"), "UTF-8");

and setup is complete. Any number of patches may be added.

usage

Now that you have set up the wurfl instance, start accessing the capabilities:

// get a device using its WURFL id
ActiveWurflDevice activeDevice = wurfl.getActiveDevice("nokia_n95_ver1");

// get the bandwidth as a string
String bandwidthString = activeDevice.getStringCapability("max_data_rate");

Alternatively, use one of the convenience methods:

// get the bandwidth as a long with a default value fallback
long bandwidth = activeDevice.getLongCapability("max_data_rate", -1L);

device detection

In the same way as the original WURFL Java API, a device can be identified by its user-agent.

// create device factory based on wurfl instance
WurflDeviceFactory wurflDeviceFactory = new WurflDeviceFactoryImpl(wurfl);

// get the device from its user-agent
WurflDevice wurflDevice = wurflDeviceFactory.getDeviceFromUserAgent("NokiaN95");

// if no match, try the loose approach
if(wurflDevice == null) {
    wurflDevice = wurflDeviceFactory.getApproximatedDeviceFromUserAgent("NokiaN95");
}

The device-detection mechanism is the same as in the original WURFL API. If you require device detection from user-agents, then the latest WURFL Java API is probably your best option, as much energy has been spent on that issue.

other features

We managed to squeeze in a few extra essential features:

See the javadoc for additional documentation.

license

The FastWurfl library is released under the GPL v2 license.

feedback

Please tell us what you think! Use the forums or mailing lists. All feedback is valuable.

weblog