net.sourceforge.wurfl.wurflapi
Class CapabilityMatrix

java.lang.Object
  |
  +--net.sourceforge.wurfl.wurflapi.CapabilityMatrix

public class CapabilityMatrix
extends java.lang.Object

Author:
Luca Passani

Big matrix of (device,capability) pairs. The matrix is derived from WURFL. Conceptually, the capability matrix can be seen as the value of all capabilities for all devices.
The actual implementation does not build the whole matrix, though.
A real huge matrix would be too expensive in terms of memory and time (hundreds of thousands of elements), so the CapabilityMatrix is really just a cache of the most commonly used (device/capability) pairs. This makes a lot of sense since:
  1. most probably people don't do MMS, WAP, ringtones, wap-push, J2me development all at the same time
  2. given a country, 80% or more of the device in the WURFL are not relevant for that country
The implication of this is that the average developer will need under 2% of the capability/device info in the WURFL, so there is no reason to squander memory and time. The CapabilityMatrix also offers some utility methods that can be handy at times: isCapabilityIn(), isDescendentOf() and isCapabilityDefinedInDevice().

Method Summary
 java.lang.String getCapabilityForDevice(java.lang.String devID, java.lang.String capa)
          Given a capability name and a device, return the value of the capability for that device.
 boolean isCapabilityDefinedInDevice(java.lang.String devID, java.lang.String capaName)
          Given a device ID and a capability name, returns false -> if the value of the capability is derived by following
the fallback for the device
true -> if the value of the capability is defined in the device.
 boolean isCapabilityIn(java.lang.String capa)
          Given a capability name, check if the capability is one of the capabilities available in the WURFL
 boolean isDescendentOf(java.lang.String descendent, java.lang.String ancestor)
          Given two device IDs (descendent and ancestor), check if the former falls back into the latter or not.
This featture has been added because requested, but it is usually better not to refer to device IDs explicitly in the code.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getCapabilityForDevice

public java.lang.String getCapabilityForDevice(java.lang.String devID,
                                               java.lang.String capa)
Given a capability name and a device, return the value of the capability for that device.


isCapabilityIn

public boolean isCapabilityIn(java.lang.String capa)
Given a capability name, check if the capability is one of the capabilities available in the WURFL


isDescendentOf

public boolean isDescendentOf(java.lang.String descendent,
                              java.lang.String ancestor)
Given two device IDs (descendent and ancestor), check if the former falls back into the latter or not.
This featture has been added because requested, but it is usually better not to refer to device IDs explicitly in the code. Use the patch file to identify devices with a common root.


isCapabilityDefinedInDevice

public boolean isCapabilityDefinedInDevice(java.lang.String devID,
                                           java.lang.String capaName)
Given a device ID and a capability name, returns false -> if the value of the capability is derived by following
the fallback for the device
true -> if the value of the capability is defined in the device. This API is probably only useful if you are building an utility to browse the WURFL.



Copyright © 2003,2004 Luca Passani.