net.sourceforge.wurfl.core.resource
Class ModelDevice

java.lang.Object
  extended by net.sourceforge.wurfl.core.resource.ModelDevice
All Implemented Interfaces:
Serializable

public class ModelDevice
extends Object
implements Serializable

This immutable class represent a device defined in WURFL repository.

This class represents the WURFL device defined in XML file and patches.

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

Nested Class Summary
static class ModelDevice.Builder
          Builder used to build ModelDevice instance.
 
Constructor Summary
protected ModelDevice()
          Protected Constructor for Builder
  ModelDevice(String userAgent, String id, String fallBack, boolean actualDeviceRoot, Map capabilities, Map groupsByCapability)
          Build ModelDevice.
 
Method Summary
 boolean defineCapability(String name)
          Return if this device define a capability.
 boolean defineGroup(String group)
          Return if this device define the given group.
 boolean equals(Object obj)
           
 Map getCapabilities()
          Return the capabilities defined by this device.
 Map getCapabilitiesForGroup(String group)
          Return the capabilities identifiers defined by a group.
 Set getCapabilitiesNamesForGroup(String group)
          Return the capabilities defined by the given group.
 String getCapability(String name)
          Return a capability value.
 String getFallBack()
          Return the identifier of the fallback device.
 String getGroupForCapability(String capability)
          Return the group defining the given capability.
 Set getGroups()
          Return the groups defined by this device.
 Map getGroupsByCapability()
          Return the capabilities identifiers and the defining groups.
 String getID()
          Return the uniques identifier string of this device.
 String getUserAgent()
          Return the user-agent string defined in this device.
 int hashCode()
           
 boolean isActualDeviceRoot()
          Return whether this device is root device.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ModelDevice

protected ModelDevice()
Protected Constructor for Builder


ModelDevice

public ModelDevice(String userAgent,
                   String id,
                   String fallBack,
                   boolean actualDeviceRoot,
                   Map capabilities,
                   Map groupsByCapability)
Build ModelDevice.

Parameters:
userAgent - User-Agent defined by this device
id - The identifier of this device.
fallBack - The identifier of fallback device
actualDeviceRoot - Define if this is a root device
capabilities - The defined capabilities
groupsByCapability - The groups mapped to capabilities name.
Method Detail

getUserAgent

public String getUserAgent()
Return the user-agent string defined in this device.
For definition of user-agent see User-Agent Wikipedia page.

Returns:
A String containing the user-agent defined for this device.

getID

public String getID()
Return the uniques identifier string of this device.

Returns:
A string containing this device identifier.

getFallBack

public String getFallBack()
Return the identifier of the fallback device. The fallback device is the device from this is derived. Only the generic device have not fallback.

Returns:
A string containing the identifier of this device fallback.

isActualDeviceRoot

public boolean isActualDeviceRoot()
Return whether this device is root device. A root device represent real device.

Returns:
true if is device is root, false otherwise.

getCapabilities

public Map getCapabilities()
Return the capabilities defined by this device. Capabilities are a list of features owned by this device.
For detailed description of capabilities see capabilities documentation at wurfl site.

Returns:
UnmodifiableMap containing the capabilities identifiers and values defined by this device.

getGroupsByCapability

public Map getGroupsByCapability()
Return the capabilities identifiers and the defining groups.

Returns:
A UnmodifiableMap of capability identifiers and the respective defining groups identifier.

defineCapability

public boolean defineCapability(String name)
Return if this device define a capability.

Parameters:
name - The capability identifier.
Returns:
True if this device define the given capability, false otherwise.

getCapability

public String getCapability(String name)
Return a capability value.

Parameters:
name - The name of capability to get value.
Returns:
The value of capability with given name.

defineGroup

public boolean defineGroup(String group)
Return if this device define the given group.

Parameters:
group - The group identifier to probe.
Returns:
True if this device define the given group, false otherwise.

getGroups

public Set getGroups()
Return the groups defined by this device.

Returns:
A Set containing the defined groups identifiers.

getGroupForCapability

public String getGroupForCapability(String capability)
Return the group defining the given capability.

Parameters:
capability - The capability to get defining group.
Returns:
A String containing the identifier of the defining group.

getCapabilitiesNamesForGroup

public Set getCapabilitiesNamesForGroup(String group)
Return the capabilities defined by the given group.

Parameters:
group - The group defining capabilities to get.
Returns:
A set containing the identifiers of the capabilities defined by the given group.

getCapabilitiesForGroup

public Map getCapabilitiesForGroup(String group)
Return the capabilities identifiers defined by a group.

Parameters:
group - The defining group of the capabilities to get.
Returns:
A Map containing the capabilities identifiers and values defined by the given group.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object


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