Package nl.basjes.parse.useragent
Class AbstractUserAgentAnalyzer
java.lang.Object
nl.basjes.parse.useragent.AbstractUserAgentAnalyzerDirect
nl.basjes.parse.useragent.AbstractUserAgentAnalyzer
- All Implemented Interfaces:
Serializable,Analyzer,AnalyzerPreHeater,AnalyzerConfigHolder
- Direct Known Subclasses:
UserAgentAnalyzer,UserAgentStringMatchMakerTester
public class AbstractUserAgentAnalyzer
extends AbstractUserAgentAnalyzerDirect
implements Serializable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAbstractUserAgentAnalyzer.AbstractUserAgentAnalyzerBuilder<UAA extends AbstractUserAgentAnalyzer,B extends AbstractUserAgentAnalyzer.AbstractUserAgentAnalyzerBuilder<UAA, B>> static interfacestatic interfacestatic classNested classes/interfaces inherited from class nl.basjes.parse.useragent.AbstractUserAgentAnalyzerDirect
AbstractUserAgentAnalyzerDirect.AbstractUserAgentAnalyzerDirectBuilder<UAA extends AbstractUserAgentAnalyzerDirect,B extends AbstractUserAgentAnalyzerDirect.AbstractUserAgentAnalyzerDirectBuilder<UAA, B>>, AbstractUserAgentAnalyzerDirect.HeaderSpecification -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intstatic final intprotected booleanFields inherited from class nl.basjes.parse.useragent.AbstractUserAgentAnalyzerDirect
clientHintsAnalyzerFields inherited from interface nl.basjes.parse.useragent.AnalyzerPreHeater
LOG, MAX_PRE_HEAT_ITERATIONS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidstatic voidconfigureKryo(Object kryoInstance) 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".voidintintparse(UserAgent.MutableUserAgent userAgent) Parses and analyzes the useragent string provided in the MutableUserAgent instance.voidsetCacheInstantiator(AbstractUserAgentAnalyzer.CacheInstantiator newCacheInstantiator) voidsetCacheSize(int newCacheSize) Sets the new size of the parsing cache.voidsetClientHintsCacheInstantiator(AbstractUserAgentAnalyzer.ClientHintsCacheInstantiator<?> clientHintsCacheInstantiator) voidsetClientHintsCacheSize(int newCacheSize) Sets the new size of the client hints parsing cache.toString()Methods inherited from class nl.basjes.parse.useragent.AbstractUserAgentAnalyzerDirect
configure, getAllMatchers, getAllPossibleFieldNames, getAllPossibleFieldNamesSorted, getAllSupportedHeaders, getConfig, getMatches, getMatchMaker, getTouchedMatchers, getUsedMatches, getWantedFieldNames, initializeMatchers, isSupportedClientHintHeader, isWantedField, loadResources, loadResources, parse, parse, reset, setVerbose, supportedClientHintHeadersMethods 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, getTestCases, getUserAgentMaxLengthMethods inherited from interface nl.basjes.parse.useragent.AnalyzerPreHeater
preHeat, preHeat, preHeat
-
Field Details
-
DEFAULT_PARSE_CACHE_SIZE
public static final int DEFAULT_PARSE_CACHE_SIZE- See Also:
-
cacheSize
protected int cacheSize -
wasBuilt
protected boolean wasBuilt
-
-
Constructor Details
-
AbstractUserAgentAnalyzer
protected AbstractUserAgentAnalyzer()
-
-
Method Details
-
destroy
public void destroy()Description copied from class:AbstractUserAgentAnalyzerDirectIn 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).- Overrides:
destroyin classAbstractUserAgentAnalyzerDirect
-
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:
kryoInstance- The instance of com.esotericsoftware.kryo.Kryo that needs to be configured.
-
disableCaching
public void disableCaching() -
setCacheSize
public void setCacheSize(int newCacheSize) Sets the new size of the parsing cache. Note that this will also wipe the existing cache.- Parameters:
newCacheSize- The size of the new LRU cache. As size of 0 will disable caching.
-
clearCache
public void clearCache() -
setCacheInstantiator
-
getCacheSize
public int getCacheSize() -
setClientHintsCacheSize
public void setClientHintsCacheSize(int newCacheSize) Sets the new size of the client hints parsing cache. Note that this will also wipe the existing cache.- Parameters:
newCacheSize- The size of the new LRU cache. As size of 0 will disable caching.
-
getClientHintsCacheSize
public int getClientHintsCacheSize() -
setClientHintsCacheInstantiator
public void setClientHintsCacheInstantiator(AbstractUserAgentAnalyzer.ClientHintsCacheInstantiator<?> clientHintsCacheInstantiator) -
parse
Description copied from class:AbstractUserAgentAnalyzerDirectParses 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.- Overrides:
parsein classAbstractUserAgentAnalyzerDirect- 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.
-
toString
- Overrides:
toStringin classAbstractUserAgentAnalyzerDirect
-