net.sourceforge.wurfl.core.handlers.matchers
Class AbstractMatcher

java.lang.Object
  extended by net.sourceforge.wurfl.core.handlers.matchers.AbstractMatcher
All Implemented Interfaces:
Matcher
Direct Known Subclasses:
AlcatelMatcher, AndroidMatcher, AOLMatcher, AppleMatcher, BenQMatcher, BlackBerryMatcher, BotMatcher, CatchAllMatcher, ChromeMatcher, DoCoMoMatcher, FirefoxMatcher, GrundigMatcher, HTCMatcher, KDDIMatcher, KonquerorMatcher, KyoceraMatcher, LGMatcher, MitsubishiMatcher, MotorolaMatcher, MSIEMatcher, NecMatcher, NokiaMatcher, OperaMatcher, OperaMiniMatcher, PanasonicMatcher, PantechMatcher, PhilipsMatcher, PortalmmmMatcher, QtekMatcher, SafariMatcher, SagemMatcher, SamsungMatcher, SanyoMatcher, SharpMatcher, SiemensMatcher, SonyEricssonMatcher, SPVMatcher, ToshibaMatcher, VodafoneMatcher, WindowsCEMatcher

public abstract class AbstractMatcher
extends Object
implements Matcher

Abstract implementation of Matcher.

It provides basic functionalities of matching. The matching strategy is:

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

Field Summary
protected  org.apache.commons.logging.Log detected
          Log detected
protected  org.apache.commons.logging.Log logger
          Log
protected  org.apache.commons.logging.Log undetected
          Log undetected
 
Constructor Summary
AbstractMatcher(Handler handler)
          Build AbstractMatcher by handler and collected devices by user-agent.
 
Method Summary
protected  String applyCatchAllRecoveryMatch(WURFLRequest request, FilteredDevices filteredDevices)
           Match the given request using the CatchAll strategy.
protected  String applyConclusiveMatch(WURFLRequest request, FilteredDevices filteredDevices)
          Apply conclusive matching strategy, at least returns generic.
protected  String applyRecoveryMatch(WURFLRequest request, FilteredDevices filteredDevices)
          Match the given request using the recovery matching strategy.
 boolean canHandle(WURFLRequest request)
          Return if this matcher can handle given request.
protected  String lookForMatchingUserAgent(SortedSet userAgentsSet, String userAgent)
          Match the given user-agent to collected user-agents.
 String match(WURFLRequest request, FilteredDevices filteredDevices)
          Applies the matching strategy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Log


undetected

protected final org.apache.commons.logging.Log undetected
Log undetected


detected

protected final org.apache.commons.logging.Log detected
Log detected

Constructor Detail

AbstractMatcher

public AbstractMatcher(Handler handler)
Build AbstractMatcher by handler and collected devices by user-agent.

Parameters:
handler - The handler used to decide if this class can handle the request.
Method Detail

canHandle

public boolean canHandle(WURFLRequest request)
Description copied from interface: Matcher
Return if this matcher can handle given request.

Specified by:
canHandle in interface Matcher
Parameters:
request - The WURFLRequest to check if can be handled.
Returns:
True if this matcher can handle given request.

match

public final String match(WURFLRequest request,
                          FilteredDevices filteredDevices)
Applies the matching strategy. this strategy is valid for every subclass.

The strategy is:

Specified by:
match in interface Matcher
Parameters:
request - The request to match.
Returns:
Return the matched device identifier.

applyConclusiveMatch

protected String applyConclusiveMatch(WURFLRequest request,
                                      FilteredDevices filteredDevices)
Apply conclusive matching strategy, at least returns generic.

Parameters:
request - The request used to applying matching strategy.
Returns:
The matched device identifiers.

lookForMatchingUserAgent

protected String lookForMatchingUserAgent(SortedSet userAgentsSet,
                                          String userAgent)
Match the given user-agent to collected user-agents.

Apply RIS(FS) to default.

Parameters:
userAgentsSet - A SortedSet of String containing user-agent string naturally ordered.
userAgent - The user-agent to match against.
Returns:
The collected user-agent matching with given user-agent.

applyRecoveryMatch

protected String applyRecoveryMatch(WURFLRequest request,
                                    FilteredDevices filteredDevices)
Match the given request using the recovery matching strategy.

Parameters:
request - The request to match.
Returns:
The device identifier matched from request, at least returns generic.

applyCatchAllRecoveryMatch

protected String applyCatchAllRecoveryMatch(WURFLRequest request,
                                            FilteredDevices filteredDevices)

Match the given request using the CatchAll strategy. The subclass can override this method, but must returns "generic" device al least.

TODO this method assumes the wurfl.xml + patch files contains the hard coded device's ids.

Parameters:
request - The request to match.
Returns:
the matched device's id, at least "generic".


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