net.sourceforge.wurfl.core.matchers
Class AbstractMatcher

java.lang.Object
  extended by net.sourceforge.wurfl.core.matchers.AbstractMatcher
All Implemented Interfaces:
Matcher, ResourcePaths
Direct Known Subclasses:
AbstractSmartTVMatcher, AbstractUndefinedMatcher, AndroidMatcher, AppleMatcher, BenQMatcher, BlackBerryMatcher, BotMatcher, CatchAllMatcher, ChromeMatcher, DoCoMoMatcher, DynamicMatcher, FennecOnAndroidMatcher, FirefoxMatcher, HTCSpoofMatcher, JavaMidletMatcher, KDDIMatcher, KindleMatcher, LGMatcher, LGUPLUSMatcher, MaemoBrowserMatcher, MotorolaMatcher, MSIEMatcher, NecMatcher, NetFrontOnAndroidMatcher, NokiaMatcher, NokiaOviMatcher, OperaMatcher, OperaMiniMatcher, OperaMiniOnAndroidMatcher, OperaMobiOnAndroidMatcher, OperaTabletOnAndroidMatcher, PantechMatcher, ReksioMatcher, SafariMatcher, SamsungMatcher, SanyoMatcher, SonyEricssonMatcher, UCWEB7OnAndroidMatcher, VodafoneMatcher, WebOSMatcher, WindowsCEMatcher, WindowsMobileMatcher, WindowsMobileWebViewModeMatcher

public abstract class AbstractMatcher
extends Object
implements Matcher, ResourcePaths

Abstract implementation of Matcher.

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

Version:
$Id: AbstractMatcher.java 934 2012-03-27 13:34:26Z fulvio.crivellaro $

Field Summary
protected static boolean DEBUG
           
protected  org.slf4j.Logger detected
          Log detected
protected  InspectionManager inspectionManager
           
protected  boolean isDebugEnabled
          Log
protected static org.slf4j.Logger logger
           
protected  org.slf4j.Logger undetected
          Log undetected
 
Fields inherited from interface net.sourceforge.wurfl.core.resource.ResourcePaths
CATCH_ALL_RECOVERY_FILE, WURFL_CONFIG_FILE
 
Constructor Summary
AbstractMatcher(UserAgentNormalizer normalizer)
          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)
          Apply conclusive matching strategy, at least returns generic.
protected  String applyRecoveryMatch(WURFLRequest request)
          Match the given request using the recovery matching strategy.
 Filter getFilter()
           
 String getName()
           
protected  String lookForMatchingUserAgent(String userAgent)
          Match the given user-agent to collected user-agents.
 DeviceInfo match(WURFLRequest request)
          Applies the matching strategy.
 String normalize(String userAgent)
          delegate to inner normalizer.
 void setFilter(Filter filter)
           
 void setInspectionManager(InspectionManager inspectionManager)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sourceforge.wurfl.core.matchers.Matcher
canHandle
 

Field Detail

logger

protected static final org.slf4j.Logger logger

DEBUG

protected static final boolean DEBUG
See Also:
Constant Field Values

isDebugEnabled

protected final boolean isDebugEnabled
Log

See Also:
Constant Field Values

inspectionManager

protected InspectionManager inspectionManager

undetected

protected final org.slf4j.Logger undetected
Log undetected


detected

protected final org.slf4j.Logger detected
Log detected

Constructor Detail

AbstractMatcher

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

Parameters:
normalizer -
Method Detail

toString

public String toString()
Overrides:
toString in class Object

setInspectionManager

public final void setInspectionManager(InspectionManager inspectionManager)

setFilter

public final void setFilter(Filter filter)

getFilter

public final Filter getFilter()
Specified by:
getFilter in interface Matcher

match

public final DeviceInfo match(WURFLRequest request)
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)
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(String userAgent)
Match the given user-agent to collected user-agents.

Apply RIS(FS) to default(first slash).

Parameters:
userAgent - The user-agent to match against.
Returns:
The collected user-agent matching with given user-agent.

applyRecoveryMatch

protected String applyRecoveryMatch(WURFLRequest request)
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".

normalize

public final String normalize(String userAgent)
delegate to inner normalizer.

Specified by:
normalize in interface Matcher
Parameters:
userAgent -
Returns:

getName

public String getName()
Specified by:
getName in interface Matcher


Copyright © 2012 ScientiaMobile Inc.. All Rights Reserved.