net.sourceforge.wurfl.core
Class WURFLUtils

java.lang.Object
  extended by net.sourceforge.wurfl.core.WURFLUtils

public class WURFLUtils
extends Object

This is a interface to WURFL introspection methods. It is mainly used from developers. In general it is a facade class to WURFLModel.

Version:
$Id: WURFLUtils.java 432 2010-05-06 12:12:53Z filippo.deluca $
Author:
Fantayeneh Asres Gizaw, Filippo De Luca

Constructor Summary
WURFLUtils(WURFLModel model)
          Create a WURFLUtils instance from WURFLModel.
WURFLUtils(WURFLModel model, DeviceProvider deviceProvider)
          Create a WURFLUtils instance from WURFLModel.
 
Method Summary
 Set getAllCapabilities()
          Facade method of WURFLModel#getAllCapabilities().
 Set getAllDevices()
          Return all the Devices managed by the backend WURFLModel.
 Set getAllDevicesId()
          It is facade method for WURFLModel#getAllDevicesId().
 Set getAllGroups()
          It is a facade method of WURFLModel#getAllGroups().
 Set getAllModelDevices()
          It is facade method for WURFLModel#getAllDevices() .
 Set getCapabilitiesForGroup(String group)
          It is a facade method of WURFLModel#getCapabilitiesForGroup(String).
 Device getDeviceById(String id)
          Return a Device instance identified by the given identifier.
 String getGroupByCapability(String capability)
          Facade method of WURFLModel#getGroupByCapability(String).
 ModelDevice getModelDeviceAncestor(ModelDevice target)
          It is a facade method of WURFLModel#getDeviceAncestor(ModelDevice).
 ModelDevice getModelDeviceById(String id)
          Facade method of WURFLModel#getDeviceById(String).
 ModelDevice getModelDeviceFallback(ModelDevice target)
          It is a facade method of WURFLModel#getDeviceFallback(ModelDevice).
 List getModelDeviceHierarchy(ModelDevice root)
          It is facade method of WURFLModel#getDeviceHierarchy(ModelDevice).
 Set getModelDevices(Set ids)
          Facade method of WURFLModel#getDevices(Set).
 ModelDevice getModelDeviceWhereCapabilityIsDefined(ModelDevice target, String capability)
          It is facade method of WURFLModel#getDeviceWhereCapabilityIsDefined(ModelDevice, String).
 String getVersion()
          Facade method of WURFLModel.getVersion().
 boolean isCapabilityDefined(String capability)
          Facade method of WURFLModel#isCapabilityDefined(String).
 boolean isDeviceDefined(String id)
          Facade method of WURFLModel#isDeviceDefined(String).
 boolean isGroupDefined(String group)
          It is a facade method of WURFLModel#isGroupDefined(String).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WURFLUtils

public WURFLUtils(WURFLModel model)
Create a WURFLUtils instance from WURFLModel.

Parameters:
model - The backed WURFLModel instance.

WURFLUtils

public WURFLUtils(WURFLModel model,
                  DeviceProvider deviceProvider)
Create a WURFLUtils instance from WURFLModel.

Parameters:
model - The backend WURFLModel instance.
Method Detail

getVersion

public String getVersion()
Facade method of WURFLModel.getVersion().

It returns the version of the WURFL repository (root resource + patches).

Returns:
String representing version of underlying WURFL repository.

isDeviceDefined

public boolean isDeviceDefined(String id)
Facade method of WURFLModel#isDeviceDefined(String). It returns if a device with given identifier is defined by the backend WURFLModel.

Parameters:
id - The identifier of probing device.
Returns:
True if the device is defined in backend WURFLModel, false otherwise.

getModelDeviceById

public ModelDevice getModelDeviceById(String id)
                               throws DeviceNotDefinedException
Facade method of WURFLModel#getDeviceById(String). It returns a ModelDevice with given identifier.

Parameters:
id - The identifier of the ModelDevice to retrieve.
Returns:
A ModelDevice instance.
Throws:
DeviceNotDefinedException - if the device with given identifier is not defined by backend WURFLModel.

getModelDevices

public Set getModelDevices(Set ids)
                    throws DeviceNotDefinedException
Facade method of WURFLModel#getDevices(Set). It returns ModelDevices with given identifiers.

Parameters:
A - Set of String containing identifiers of ModelDevices to retrieve.
Returns:
Set of ModelDevice.
Throws:
DeviceNotDefinedException

getAllDevicesId

public Set getAllDevicesId()
It is facade method for WURFLModel#getAllDevicesId(). It returns all devices identifiers defined by backend WURFLModel.

Returns:
Set of String representing ModelDevices identifiers.

getAllModelDevices

public Set getAllModelDevices()
It is facade method for WURFLModel#getAllDevices() . It returns all ModelDevices defined by backend WURFLModel.

Returns:
Set of ModelDevice.

getModelDeviceHierarchy

public List getModelDeviceHierarchy(ModelDevice root)
                             throws DeviceNotInModelException
It is facade method of WURFLModel#getDeviceHierarchy(ModelDevice). It returns a ModelDevice hierarchy. To know how is hierarchy defined look at WURFLModel#getDeviceHierarchy(ModelDevice).

Parameters:
root - The ModelDevice root of hierarchy.
Returns:
A List representing the root ModelDevice hierarchy.
Throws:
DeviceNotInModelException - If the root ModelDevice is not contained in backend WURFLModel.

getModelDeviceFallback

public ModelDevice getModelDeviceFallback(ModelDevice target)
                                   throws DeviceNotInModelException
It is a facade method of WURFLModel#getDeviceFallback(ModelDevice). It returns the target's fallback ModelDevice.

Parameters:
target - The ModelDevice device to get ModelDevice fallback from.
Returns:
A ModelDevice instance, fallback of the root.
Throws:
DeviceNotInModelException - If the root is not contained in backend WURFLModel.

getModelDeviceAncestor

public ModelDevice getModelDeviceAncestor(ModelDevice target)
                                   throws DeviceNotInModelException
It is a facade method of WURFLModel#getDeviceAncestor(ModelDevice). It returns a ModelDevice is ancestor for the given device. To know how is defined ancestor look at WURFLModel#getDeviceAncestor(ModelDevice).

Parameters:
target - The device to get ancestor from.
Returns:
A root ModelDevice instance.
Throws:
DeviceNotInModelException - If the target ModelDevice is not contained in backend WURFLModel.

isCapabilityDefined

public boolean isCapabilityDefined(String capability)
Facade method of WURFLModel#isCapabilityDefined(String). It returns if the given capability is defined in backend WURFLModel.

Parameters:
capability - The name of capability to check against.
Returns:
True if the given capability is defined in WURFL, false otherwise.
Throws:
IllegalArgumentException - if capabilityName is null.

getAllCapabilities

public Set getAllCapabilities()
Facade method of WURFLModel#getAllCapabilities(). It returns all the capabilities defined in the backend WURFLModel.

Returns:
A Set of String containing all capabilities defined by backend WURFLModel.

getGroupByCapability

public String getGroupByCapability(String capability)
                            throws CapabilityNotDefinedException
Facade method of WURFLModel#getGroupByCapability(String). Return the identifier of group define the given capability.

Parameters:
capability - The name of capability.
Returns:
The defining group identifier.
Throws:
CapabilityNotDefinedException - If the backend WURFLModel do not define the capability capability.

getModelDeviceWhereCapabilityIsDefined

public ModelDevice getModelDeviceWhereCapabilityIsDefined(ModelDevice target,
                                                          String capability)
                                                   throws CapabilityNotDefinedException,
                                                          DeviceNotInModelException
It is facade method of WURFLModel#getDeviceWhereCapabilityIsDefined(ModelDevice, String). It returns the ModelDevice where a capability is defined upon the target ModelDevice hierarchy.

Parameters:
target - The ModelDevice from which start the search of the definition of capability.
capability - The capability identifier to search.
Returns:
A ModelDevice instances, in the target hierarchy, defining the given capability
Throws:
CapabilityNotDefinedException - If the given capability is not defined upon the target hierarchy.
DeviceNotInModelException - If the target ModelDevice is not contained in backend WURFLModel.

isGroupDefined

public boolean isGroupDefined(String group)
It is a facade method of WURFLModel#isGroupDefined(String). It returns if a group with given identifier is defined in backend WURFLModel.

Parameters:
group - the group identifier to probe.
Returns:
True if the given group is defined, false otherwise.

getAllGroups

public Set getAllGroups()
It is a facade method of WURFLModel#getAllGroups(). It return all identifiers of groups defined by backend WURFLModel.

Returns:
A Set of String containing the identifier of the groups defined by backend WURFLModel.

getCapabilitiesForGroup

public Set getCapabilitiesForGroup(String group)
                            throws GroupNotDefinedException
It is a facade method of WURFLModel#getCapabilitiesForGroup(String). It returns all capabilities identifier defined by given group in the backend WURFLModel.

Parameters:
group - The identifier of defining group.
Returns:
A Set of String containing the identifiers of the capabilities defined by given group.
Throws:
GroupNotDefinedException - If the given group is not defined by backend WURFLModel.

getDeviceById

public Device getDeviceById(String id)
                     throws DeviceNotDefinedException
Return a Device instance identified by the given identifier.

Parameters:
id - The identifier of Device to get.
Throws:
DeviceNotDefinedException

getAllDevices

public Set getAllDevices()
Return all the Devices managed by the backend WURFLModel.

Returns:
Set of Device.


Copyright © 2008-2010 WURFL-Pro srl. All Rights Reserved.