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
Modifier and TypeClassDescriptionstatic class
AbstractUserAgentAnalyzer.AbstractUserAgentAnalyzerBuilder<UAA extends AbstractUserAgentAnalyzer,
B extends AbstractUserAgentAnalyzer.AbstractUserAgentAnalyzerBuilder<UAA, B>> static interface
static interface
static class
Nested 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
Modifier and TypeFieldDescriptionprotected int
static final int
protected boolean
Fields inherited from class nl.basjes.parse.useragent.AbstractUserAgentAnalyzerDirect
clientHintsAnalyzer
Fields inherited from interface nl.basjes.parse.useragent.AnalyzerPreHeater
LOG, MAX_PRE_HEAT_ITERATIONS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
static void
configureKryo
(Object kryoInstance) 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
int
int
parse
(UserAgent.MutableUserAgent userAgent) Parses and analyzes the useragent string provided in the MutableUserAgent instance.void
setCacheInstantiator
(AbstractUserAgentAnalyzer.CacheInstantiator newCacheInstantiator) void
setCacheSize
(int newCacheSize) Sets the new size of the parsing cache.void
setClientHintsCacheInstantiator
(AbstractUserAgentAnalyzer.ClientHintsCacheInstantiator<?> clientHintsCacheInstantiator) void
setClientHintsCacheSize
(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, supportedClientHintHeaders
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, getNumberOfTestCases, getTestCases, getUserAgentMaxLength
Methods 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:AbstractUserAgentAnalyzerDirect
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).- Overrides:
destroy
in 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:AbstractUserAgentAnalyzerDirect
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.- Overrides:
parse
in 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:
toString
in classAbstractUserAgentAnalyzerDirect
-