Exemplo n.º 1
0
  // Compares the browser and its version against the supported variants
  private int _compareBrowserAndVersion(int browser, TrinidadAgent agent) {
    // If we don't have a browser specified, we match anything
    if (_agentVersions.isEmpty()) return _BROWSER_UNKNOWN_MATCH;

    // On the other hand, if we do have a browser specified, but
    // the client browser is not known, we don't have a match
    if (browser == TrinidadAgent.APPLICATION_UNKNOWN) return 0;

    // If we have browser exact match, compare versions
    Integer browserNum = Integer.valueOf(browser);
    if (_agentVersions.containsKey(browserNum)) {
      Set<Version> versions = _agentVersions.get(browserNum);
      if (versions.isEmpty()) return _BROWSER_EXACT_MATCH | _VERSION_UNKNOWN_MATCH;

      Version version = new Version(agent.getAgentVersion());

      for (Version av : versions) {
        if (av.compareTo(version) == 0) {
          return _BROWSER_EXACT_MATCH | _VERSION_EXACT_MATCH;
        }
      }

      return 0;
    }

    return 0;
  }