com.free2be.dimensions.device
Class DeviceFactory

java.lang.Object
  extended by com.free2be.dimensions.device.DeviceFactory
Direct Known Subclasses:
DeviceProfileFactory, SessionDeviceFactory, SimpleDeviceFactory, SimulationDeviceFactory

public abstract class DeviceFactory
extends java.lang.Object

A device factory is used to determine a calling device. There are various levels of confidence that each factory may have in determining it's ability to produce a quality device description. The factories are registered in order of preference to improve performance (some factories simply detect a predermined device so parsing descriptions and headers would not be necesary).


Nested Class Summary
static class DeviceFactory.ConfidenceLevel
          Confidence Levels are indicators that are used to determine how confident a factory is in providing an appropriate device.
 
Field Summary
protected static DeviceFactory.ConfidenceLevel CONTENT
          Indicates the type of content is known, but very little about the calling device is know such as the screen size.
protected static DeviceFactory.ConfidenceLevel DEFAULT
          Practically as good as no confidence, but regardless returns a device that represents the default for the system.
protected static DeviceFactory.ConfidenceLevel DEVICE
          Indicates the content type(s) are known and some information about the device is known, but not described in a disciplined or standard way.
protected static java.lang.Integer MINIMUM_LEVEL_FOR_FINAL
          This level represents the minimul confidence level that is needed for the factory dispatcher to give up looking.
protected static DeviceFactory.ConfidenceLevel MODEL
          Indicates the model of the device is known, but only from non-standard methods such as CC/PP.
protected static DeviceFactory.ConfidenceLevel NONE
          Simply doesn't offer any clues about the type of device.
protected static DeviceFactory.ConfidenceLevel OVERRIDE
          An indicator used to override whatever the calling device is...sometimes used for simulation.
protected static DeviceFactory.ConfidenceLevel PRE_DETERMINED
          Predetermined means the factory has found a persistant device for a caller.
protected static DeviceFactory.ConfidenceLevel STANDARD
          CC/PP is the W3C standard that describes almost every detail of a device and is the preferred method of device description.
 
Constructor Summary
DeviceFactory()
           
 
Method Summary
 void clearPersistantDevice(java.lang.Object informationSource)
          Sometimes a persistant device needs to be removed from persistance to "reset" the factory so to speak.
abstract  DeviceFactory.ConfidenceLevel getConfidenceLevel()
          Retrieves the confidence level this factory has in fulfilling the request based on the information provided during intialization.
abstract  Device getDevice()
          Retrieves a device to represent the calling client's device.
static DeviceFactory getDeviceFactory(java.lang.Object informationSource)
           
protected static java.util.TreeSet getFactories()
          Gets all the factories.
abstract  DeviceFactory.ConfidenceLevel getHighestConfidenceLevel()
          Returns the highest confidence level the implementing device factory can provide.
protected static java.util.LinkedList getPersistentFactories()
          This returns a list of persistant factories.
protected abstract  void initialize(java.lang.Object informationSource)
          initalizes a factory after default construction giving some object as the source of information to determine confidence and build devices.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NONE

protected static final DeviceFactory.ConfidenceLevel NONE
Simply doesn't offer any clues about the type of device. The only level that allows a null response when soliciting a device factory for a device.


DEFAULT

protected static final DeviceFactory.ConfidenceLevel DEFAULT
Practically as good as no confidence, but regardless returns a device that represents the default for the system. Any factory returning this confidence level MUST return a device when solicited.


CONTENT

protected static final DeviceFactory.ConfidenceLevel CONTENT
Indicates the type of content is known, but very little about the calling device is know such as the screen size.


DEVICE

protected static final DeviceFactory.ConfidenceLevel DEVICE
Indicates the content type(s) are known and some information about the device is known, but not described in a disciplined or standard way.


MODEL

protected static final DeviceFactory.ConfidenceLevel MODEL
Indicates the model of the device is known, but only from non-standard methods such as CC/PP.


STANDARD

protected static final DeviceFactory.ConfidenceLevel STANDARD
CC/PP is the W3C standard that describes almost every detail of a device and is the preferred method of device description. THis may be used to represent that other standards oriented description may be available.


PRE_DETERMINED

protected static final DeviceFactory.ConfidenceLevel PRE_DETERMINED
Predetermined means the factory has found a persistant device for a caller. (sometimes stored in HttpSessions This is high since it generally is the most efficient way of finding a detected device


OVERRIDE

protected static final DeviceFactory.ConfidenceLevel OVERRIDE
An indicator used to override whatever the calling device is...sometimes used for simulation.


MINIMUM_LEVEL_FOR_FINAL

protected static final java.lang.Integer MINIMUM_LEVEL_FOR_FINAL
This level represents the minimul confidence level that is needed for the factory dispatcher to give up looking. In other words, this much confidence is should be good enough for the system. Since there are multiple confidence levels above this level, then the factories that produce such levels should be sorted in order of abilities to minimize reduntant checks.

Constructor Detail

DeviceFactory

public DeviceFactory()
Method Detail

getDevice

public abstract Device getDevice()
Retrieves a device to represent the calling client's device.


getConfidenceLevel

public abstract DeviceFactory.ConfidenceLevel getConfidenceLevel()
Retrieves the confidence level this factory has in fulfilling the request based on the information provided during intialization.


getHighestConfidenceLevel

public abstract DeviceFactory.ConfidenceLevel getHighestConfidenceLevel()
Returns the highest confidence level the implementing device factory can provide. This method should be considered a static method and return a value upon empty construction.


initialize

protected abstract void initialize(java.lang.Object informationSource)
initalizes a factory after default construction giving some object as the source of information to determine confidence and build devices. The majority of the work should be done during this method since this is the method that should determine the actual confidence of building a device. No exception should ever be thrown from this. Any internal exceptions should simply return a confidence level of NONE when asked.

Parameters:
informationSource - any object that a factory may use to determine device (usually javax.servlet.HttpServletRequest).

getFactories

protected static java.util.TreeSet getFactories()
Gets all the factories. This needs to be made more efficient and generic by configuration.

Returns:
TreeSet containing all factories sorted by their highest confidence level first.

getPersistentFactories

protected static java.util.LinkedList getPersistentFactories()
This returns a list of persistant factories. This should be made more efficient and generic by configuring through system.

Returns:
LinkedList containing PersistentDeviceFactory implementations.

getDeviceFactory

public static DeviceFactory getDeviceFactory(java.lang.Object informationSource)
Parameters:
informationSource - ... any object that a factory may use for detection....Usually HttpServletRequest. See factory implementations for other possible instances.
Returns:
DeviceFactory that can best gather the details of the calling channel.

clearPersistantDevice

public void clearPersistantDevice(java.lang.Object informationSource)
Sometimes a persistant device needs to be removed from persistance to "reset" the factory so to speak. Call this with the information source and it will notify all persistant factories that are registered.

See Also:
PersistentDeviceFactory