Class UserAgentStringMatchMaker
java.lang.Object
nl.basjes.parse.useragent.analyze.UserAgentStringMatchMaker
- All Implemented Interfaces:
Serializable,MatchMaker,Analyzer,AnalyzerPreHeater,AnalyzerConfigHolder
public class UserAgentStringMatchMaker
extends Object
implements MatchMaker, AnalyzerConfigHolder, AnalyzerPreHeater, Serializable
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface nl.basjes.parse.useragent.analyze.MatchMaker
MatchMaker.Dummy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intprotected UserAgentTreeFlattenerstatic final intFields inherited from interface nl.basjes.parse.useragent.AnalyzerPreHeater
MAX_PRE_HEAT_ITERATIONS -
Constructor Summary
ConstructorsConstructorDescriptionUserAgentStringMatchMaker(AnalyzerConfig analyzerConfig, boolean showMatcherStats, boolean delayInitialization) -
Method Summary
Modifier and TypeMethodDescriptionstatic voidconfigureKryo(Object kryo) This is used to configure the provided Kryo instance if Kryo serialization is desired.voiddestroy()In some cases it was found that simply dereferencing the instance and letting the GC clean it all up was "too hard".voidstatic StringfirstCharactersForPrefixHash(String input, int maxChars) static intfirstCharactersForPrefixHashLength(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) intvoidvoidinformMeAbout(MatcherAction matcherAction, String keyPattern) voidinformMeAboutPrefix(MatcherAction matcherAction, String treeName, String prefix) voidbooleanisWantedField(String fieldName) voidloadResources(String resourceString) voidloadResources(String resourceString, boolean showLoadMessages, boolean optionalResources) voidlookingForRange(String treeName, WordRangeVisitor.Range range) parse(UserAgent.MutableUserAgent userAgent) Parses and analyzes the useragent string provided in the MutableUserAgent instance.voidreceivedInput(Matcher matcher) voidreset()Resets the state of the Analyzer to the default state.voidsetFieldCalculators(List<FieldCalculator> newFieldCalculators) voidsetVerbose(boolean newVerbose) toString()protected voidMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface nl.basjes.parse.useragent.config.AnalyzerConfigHolder
dropTests, getLookups, getLookupSets, getNumberOfTestCases, getTestCasesMethods inherited from interface nl.basjes.parse.useragent.AnalyzerPreHeater
preHeat, preHeat, preHeat
-
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:AnalyzerConfigHolderObtain the config for this analyzer.- Specified by:
getConfigin 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:
lookingForRangein interfaceMatchMaker
-
firstCharactersForPrefixHashLength
-
firstCharactersForPrefixHash
-
informMeAboutPrefix
- Specified by:
informMeAboutPrefixin interfaceMatchMaker
-
getRequiredPrefixLengths
- Specified by:
getRequiredPrefixLengthsin interfaceMatchMaker
-
informMeAbout
- Specified by:
informMeAboutin interfaceMatchMaker
-
setVerbose
public void setVerbose(boolean newVerbose) -
getUserAgentMaxLength
public int getUserAgentMaxLength()- Specified by:
getUserAgentMaxLengthin interfaceAnalyzerConfigHolder
-
receivedInput
- Specified by:
receivedInputin 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:
getRequiredInformRangesin interfaceMatchMaker
-
inform
- Specified by:
informin 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
-