Class DefaultLocaleResolver

  • All Implemented Interfaces:
    LocaleResolver, RequestLocaleResolver

    public class DefaultLocaleResolver
    extends java.lang.Object
    implements LocaleResolver, RequestLocaleResolver
    The DefaultLocaleResolver resolves the request's Locale by calling the ServletRequest.getLocales() method, which generally will be the Servlet Container's implementation of this method and thus be based on the client's Accept-Language header.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.List<java.util.Locale> resolveLocale​(javax.servlet.http.HttpServletRequest request)
      Return a non-null but possibly empty list of Locale instances to consider for localization of the current request.
      java.util.List<java.util.Locale> resolveLocale​(SlingHttpServletRequest request)
      Return the Locales provided by the ServletRequest.getLocales() method collected in a List.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • DefaultLocaleResolver

        public DefaultLocaleResolver()
    • Method Detail

      • resolveLocale

        public java.util.List<java.util.Locale> resolveLocale​(SlingHttpServletRequest request)
        Return the Locales provided by the ServletRequest.getLocales() method collected in a List.
        Specified by:
        resolveLocale in interface LocaleResolver
        Parameters:
        request - The SlingHttpServletRequest providing hints and information for the Locale resolution.
        Returns:
        The list of Locales to use for internationalization of request processing
      • resolveLocale

        public java.util.List<java.util.Locale> resolveLocale​(javax.servlet.http.HttpServletRequest request)
        Description copied from interface: RequestLocaleResolver
        Return a non-null but possibly empty list of Locale instances to consider for localization of the current request. The list returned is assumed to be ordered by preference where the first entry is the preferred Locale and the last entry is the least preferred Locale.

        Returning an empty list is equivalent to returning a singleton list whose single entry is the ResourceBundleProvider.getDefaultLocale().

        Specified by:
        resolveLocale in interface RequestLocaleResolver
        Parameters:
        request - The HttpServletRequest providing hints and information for the Locale resolution.
        Returns:
        The list of Locales to use for internationalization of request processing
        See Also:
        RequestLocaleResolver.resolveLocale(javax.servlet.http.HttpServletRequest)