Module bus.http

Class Browser

java.lang.Object
org.miaixz.bus.http.metric.anget.UserAgent
org.miaixz.bus.http.metric.anget.Browser

public class Browser extends UserAgent
Represents a browser, parsed from a User-Agent string.
Since:
Java 17+
Author:
Kimi Liu
  • Field Details

    • UNKNOWN

      public static final Browser UNKNOWN
      Constant for an unknown browser.
    • OTHER_VERSION

      public static final String OTHER_VERSION
      A regex pattern for matching other browser versions.
      See Also:
    • BROWERS

      public static final List<Browser> BROWERS
      A list of supported browser types.
  • Constructor Details

    • Browser

      public Browser(String name, String rule, String regex)
      Constructs a new Browser instance.
      Parameters:
      name - The name of the browser.
      rule - The keyword or expression to match in the User-Agent string.
      regex - The regex for matching the version.
  • Method Details

    • addCustomBrowser

      public static void addCustomBrowser(String name, String rule, String regex)
      Adds a custom browser type to the list of supported browsers.
      Parameters:
      name - The name of the browser.
      rule - The keyword or expression to match.
      regex - The regex for matching the version.
    • getVersion

      public String getVersion(String text)
      Gets the version of the browser from a User-Agent string.
      Parameters:
      text - The User-Agent string.
      Returns:
      The version string, or null if not found.
    • isMobile

      public boolean isMobile()
      Returns whether this browser is a mobile browser.
      Returns:
      true if this is a mobile browser, false otherwise.