java.lang.Object
edu.internet2.ndt.UserAgentTools

public class UserAgentToolsextends Object
Utility class for parsing user agent strings to extract browser and OS information.
  • Constructor Details

    • UserAgentTools

      public UserAgentTools()
      The parsers below are static and hold no configuration, so an instance carries nothing.
  • Method Details

    • getArray

      public static String[] getArray(String a, String b, String c)
      Bundle three parsed fields into the fixed-shape result array callers expect.
      Parameters:
      a - the browser name, or "?" when it could not be determined
      b - the browser version, or "?" when it could not be determined
      c - the operating system name, or "?" when it could not be determined
      Returns:
      a new three-element array holding a, b and c in that order
    • getBrowser

      public static String[] getBrowser(String userAgent)
      Extract the browser and OS fields from a User-Agent header.
      Parameters:
      userAgent - the raw header value, which is ignored here because NDT reports unknown for every field it does not recognize
      Returns:
      a three-element array of browser name, browser version and OS name, each "?" when the value is not one NDT knows