java.lang.Object
org.miaixz.bus.http.metric.anget.UserAgent
org.miaixz.bus.http.metric.anget.Browser
Represents a browser, parsed from a User-Agent string.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCustomBrowser(String name, String rule, String regex) Adds a custom browser type to the list of supported browsers.getVersion(String text) Gets the version of the browser from a User-Agent string.booleanisMobile()Returns whether this browser is a mobile browser.
-
Field Details
-
UNKNOWN
Constant for an unknown browser. -
OTHER_VERSION
A regex pattern for matching other browser versions.- See Also:
-
BROWERS
A list of supported browser types.
-
-
Constructor Details
-
Browser
Constructs a newBrowserinstance.- 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
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
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:
trueif this is a mobile browser,falseotherwise.
-