Module bus.http

Class UserAgent

java.lang.Object
org.miaixz.bus.http.metric.anget.UserAgent
Direct Known Subclasses:
Browser, Device, Engine, NOS

public class UserAgent extends Object
Represents a User-Agent, providing information about the browser, engine, OS, and device.
Since:
Java 17+
Author:
Kimi Liu
  • Constructor Details

    • UserAgent

      public UserAgent()
      Default constructor.
    • UserAgent

      public UserAgent(String name, String regex)
      Constructs a new UserAgent instance.
      Parameters:
      name - The name of the component.
      regex - The regex pattern for matching.
    • UserAgent

      public UserAgent(String name, Pattern pattern)
      Constructs a new UserAgent instance.
      Parameters:
      name - The name of the component.
      pattern - The regex pattern for matching.
  • Method Details

    • parse

      public static UserAgent parse(String text)
      Parses a User-Agent string and returns a UserAgent object.
      Parameters:
      text - The User-Agent string.
      Returns:
      A UserAgent object, or null if the input is blank.
    • isMatch

      public boolean isMatch(String content)
      Returns whether the given content contains a match for this component.
      Parameters:
      content - The User-Agent string.
      Returns:
      true if a match is found, false otherwise.
    • isUnknown

      public boolean isUnknown()
      Returns whether this component is unknown.
      Returns:
      true if this component is unknown, false otherwise.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object