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:
  • 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 class AbstractUserAgentAnalyzerDirect
    • configureKryo

      public static void configureKryo(Object kryoInstance)
      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

      public void setCacheInstantiator(AbstractUserAgentAnalyzer.CacheInstantiator newCacheInstantiator)
    • 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 class AbstractUserAgentAnalyzerDirect
      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

      public String toString()
      Overrides:
      toString in class AbstractUserAgentAnalyzerDirect