Class HttpAcceptLanguageParser

java.lang.Object
ch.tocco.nice2.textresources.api.locale.HttpAcceptLanguageParser

public class HttpAcceptLanguageParser extends Object
Parser for the Accept-Language HTTP Header value. Example: "da, en-gb;q=0.8, en;q=0.7" See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
  • Method Details

    • parseIgnorePrio

      public static Set<Locale> parseIgnorePrio(String acceptLanguage) throws IllegalArgumentException
      Ingores the numbers but keeps the order.
      Parameters:
      acceptLanguage - (may be null)
      Returns:
      Ordered Set, may be empty
      Throws:
      IllegalArgumentException - on first parse or validation error
    • parseIgnorePrioNoEx

      public static Set<Locale> parseIgnorePrioNoEx(String acceptLanguage)
      Like parseIgnorePrio() but ignores any invalid entry thrown as IllegalArgumentException.
      Parameters:
      acceptLanguage - (may be null)
      Returns:
      Ordered Set, may be empty