Class AbstractUserAgentAnalyzerDirect

java.lang.Object
nl.basjes.parse.useragent.AbstractUserAgentAnalyzerDirect
All Implemented Interfaces:
Serializable, Analyzer, AnalyzerPreHeater, AnalyzerConfigHolder
Direct Known Subclasses:
AbstractUserAgentAnalyzer, UserAgentAnalyzerDirect

public abstract class AbstractUserAgentAnalyzerDirect extends Object implements Analyzer, AnalyzerConfigHolder, AnalyzerPreHeater, Serializable
See Also:
  • Field Details

  • Constructor Details

    • AbstractUserAgentAnalyzerDirect

      protected AbstractUserAgentAnalyzerDirect()
  • Method Details

    • getConfig

      @Nonnull public AnalyzerConfig getConfig()
      Description copied from interface: AnalyzerConfigHolder
      Obtain the config for this analyzer.
      Specified by:
      getConfig in interface AnalyzerConfigHolder
      Returns:
      The instance of the config used by this analyzer.
    • getPreheatTestCases

      public List<TestCase> getPreheatTestCases()
      Specified by:
      getPreheatTestCases in interface AnalyzerPreHeater
    • getMatchMaker

      protected UserAgentStringMatchMaker getMatchMaker()
    • configureKryo

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

      public void loadResources(String resourceString)
    • loadResources

      public void loadResources(String resourceString, boolean showLoadMessages, boolean optionalResources)
    • initializeMatchers

      public void initializeMatchers()
    • getAllPossibleFieldNames

      public Set<String> getAllPossibleFieldNames()
    • getAllPossibleFieldNamesSorted

      public List<String> getAllPossibleFieldNamesSorted()
    • setVerbose

      public void setVerbose(boolean newVerbose)
    • reset

      public void reset()
      Resets the state of the Analyzer to the default state.
    • parse

      @Nonnull public UserAgent.ImmutableUserAgent parse(String userAgentString)
      Parses and analyzes the provided useragent string
      Specified by:
      parse in interface Analyzer
      Parameters:
      userAgentString - The User-Agent String that is to be parsed and analyzed
      Returns:
      An ImmutableUserAgent record that holds all the results.
    • parse

      @Nonnull public UserAgent.ImmutableUserAgent parse(Map<String,String> requestHeaders)
      Parses and analyzes the provided useragent string
      Specified by:
      parse in interface Analyzer
      Parameters:
      requestHeaders - A map of all useful request Headers: the "User-Agent" and all Client Hints: "Sec-Ch-Ua"*
      Returns:
      An ImmutableUserAgent record that holds all the results.
    • 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:
      inputUserAgent - 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.
    • supportedClientHintHeaders

      public List<String> supportedClientHintHeaders()
    • isSupportedClientHintHeader

      public boolean isSupportedClientHintHeader(String header)
    • getAllSupportedHeaders

    • isWantedField

      public boolean isWantedField(String fieldName)
    • getWantedFieldNames

      public Set<String> getWantedFieldNames()
    • configure

      protected void configure(AnalyzerConfig pAnalyzerConfig, boolean pShowMatcherStats, boolean pDelayInitialization)
    • getMatches

      public List<MatchesList.Match> 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

      public List<MatchesList.Match> getUsedMatches(UserAgent.MutableUserAgent userAgent)
    • getAllMatchers

      public List<Matcher> getAllMatchers()
    • getTouchedMatchers

      public MatcherList getTouchedMatchers()
    • toString

      public String toString()
      Overrides:
      toString in class Object