Class UserAgentStringMatchMaker
java.lang.Object
nl.basjes.parse.useragent.analyze.UserAgentStringMatchMaker
- All Implemented Interfaces:
Serializable
,MatchMaker
,AnalyzerConfigHolder
public class UserAgentStringMatchMaker
extends Object
implements MatchMaker, AnalyzerConfigHolder, Serializable
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface nl.basjes.parse.useragent.analyze.MatchMaker
MatchMaker.Dummy
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
protected UserAgentTreeFlattener
static final int
-
Constructor Summary
ConstructorDescriptionUserAgentStringMatchMaker
(AnalyzerConfig analyzerConfig, boolean showMatcherStats, boolean delayInitialization) -
Method Summary
Modifier and TypeMethodDescriptionstatic void
configureKryo
(Object kryo) This is used to configure the provided Kryo instance if Kryo serialization is desired.void
destroy()
In some cases it was found that simply dereferencing the instance and letting the GC clean it all up was "too hard".void
static String
firstCharactersForPrefixHash
(String input, int maxChars) static int
firstCharactersForPrefixHashLength
(String input, int maxChars) Obtain the config for this analyzer.This function is used only for analyzing which patterns that could possibly be relevant were actually relevant for the matcher actions.getRequiredInformRanges
(String treeName) getRequiredPrefixLengths
(String treeName) getUsedMatches
(UserAgent.MutableUserAgent userAgent) int
void
void
informMeAbout
(MatcherAction matcherAction, String keyPattern) void
informMeAboutPrefix
(MatcherAction matcherAction, String treeName, String prefix) void
boolean
isWantedField
(String fieldName) void
loadResources
(String resourceString) void
loadResources
(String resourceString, boolean showLoadMessages, boolean optionalResources) void
lookingForRange
(String treeName, WordRangeVisitor.Range range) parse
(UserAgent.MutableUserAgent userAgent) Parses and analyzes the useragent string provided in the MutableUserAgent instance.void
receivedInput
(Matcher matcher) void
reset()
Resets the state of the Analyzer to the default state.void
setFieldCalculators
(List<FieldCalculator> newFieldCalculators) void
setVerbose
(boolean newVerbose) toString()
protected void
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface nl.basjes.parse.useragent.config.AnalyzerConfigHolder
dropTests, getLookups, getLookupSets, getTestCases
-
Field Details
-
wantedFieldNames
-
flattener
-
DEFAULT_USER_AGENT_MAX_LENGTH
public static final int DEFAULT_USER_AGENT_MAX_LENGTH- See Also:
-
MAX_PREFIX_HASH_MATCH
public static final int MAX_PREFIX_HASH_MATCH- See Also:
-
-
Constructor Details
-
UserAgentStringMatchMaker
public UserAgentStringMatchMaker(AnalyzerConfig analyzerConfig, boolean showMatcherStats, boolean delayInitialization)
-
-
Method Details
-
getAllMatchers
-
getTouchedMatchers
-
getConfig
Description copied from interface:AnalyzerConfigHolder
Obtain the config for this analyzer.- Specified by:
getConfig
in interfaceAnalyzerConfigHolder
- Returns:
- The instance of the config used by this analyzer.
-
configureKryo
This is used to configure the provided Kryo instance if Kryo serialization is desired. The expected type here is Object because otherwise the Kryo library becomes a mandatory dependency on any project that uses Yauaa.- Parameters:
kryo
- The instance of com.esotericsoftware.kryo.Kryo that needs to be configured.
-
destroy
public void destroy()In some cases it was found that simply dereferencing the instance and letting the GC clean it all up was "too hard". To assist in these kinds of problem cases this method will wipe the internal data structures as much as possible. After calling this method this instance becomes unusable and cannot be 'repaired'. Normal applications will never need this. Simply dereferencing the analyzer will clean everything, no memory leaks (that we know of). -
loadResources
-
loadResources
public void loadResources(String resourceString, boolean showLoadMessages, boolean optionalResources) -
finalizeLoadingRules
public void finalizeLoadingRules() -
initializeMatchers
public void initializeMatchers() -
getAllPossibleFieldNames
-
getAllPossibleFieldNamesSorted
-
lookingForRange
- Specified by:
lookingForRange
in interfaceMatchMaker
-
firstCharactersForPrefixHashLength
-
firstCharactersForPrefixHash
-
informMeAboutPrefix
- Specified by:
informMeAboutPrefix
in interfaceMatchMaker
-
getRequiredPrefixLengths
- Specified by:
getRequiredPrefixLengths
in interfaceMatchMaker
-
informMeAbout
- Specified by:
informMeAbout
in interfaceMatchMaker
-
setVerbose
public void setVerbose(boolean newVerbose) -
getUserAgentMaxLength
public int getUserAgentMaxLength()- Specified by:
getUserAgentMaxLength
in interfaceAnalyzerConfigHolder
-
receivedInput
- Specified by:
receivedInput
in interfaceMatchMaker
-
reset
public void reset()Resets the state of the Analyzer to the default state. -
parse
Parses and analyzes the useragent string provided in the MutableUserAgent instance. NOTE: This method is internally synchronized because the way the analyzer works is not reentrant.- Parameters:
userAgent
- The MutableUserAgent instance that is to be parsed and that gets all results- Returns:
- An ImmutableUserAgent copy of the results that is suitable for further usage and caching.
-
isWantedField
-
getWantedFieldNames
-
setFieldCalculators
-
getRequiredInformRanges
- Specified by:
getRequiredInformRanges
in interfaceMatchMaker
-
inform
- Specified by:
inform
in interfaceMatchMaker
-
verifyCalculatorDependencyOrdering
protected void verifyCalculatorDependencyOrdering() -
getMatches
This function is used only for analyzing which patterns that could possibly be relevant were actually relevant for the matcher actions.- Returns:
- The list of Matches that were possibly relevant.
-
getUsedMatches
-
toString
-