Class LocaleUtilInternal


  • public final class LocaleUtilInternal
    extends java.lang.Object
    Locale utility methods.
    Since:
    8.1.0
    Version:
    $Revision$ $Date$
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String LOCALE_COOKIE_NAME
      Locale cookie name.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.json.simple.JSONObject extractJsonObject​(LocaleConfig locale)
      Transform Locale to JsonObject Example: { "label" : "português (Brasil)", "value" : "pt_BR" }
      static boolean isCurrentLocaleValid​(ChannelConfig channel)
      Returns whether the session locale is valid for a given channel.
      static void markSessionLocaleToBeUpdated​(javax.servlet.http.HttpServletRequest request)
      Marks the session to have the locale updated.
      static void markSessionLocaleUpdated​(javax.servlet.http.HttpServletRequest request)
      Mark the session as having the locale updated.
      static java.util.Locale selectLocale​(javax.servlet.http.HttpServletRequest request, ChannelConfig channel)
      Returns the selected locale for a given channel and request.
      static void setCookie​(java.util.Locale locale, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
      Sets the locale cookie using the given locale as value.
      static boolean shouldUpdateSessionLocale​(javax.servlet.http.HttpServletRequest request)
      Returns whether the session locale should be updated.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • LOCALE_COOKIE_NAME

        public static final java.lang.String LOCALE_COOKIE_NAME
        Locale cookie name.
        Since:
        8.1.0
        See Also:
        Constant Field Values
    • Constructor Detail

      • LocaleUtilInternal

        public LocaleUtilInternal()
    • Method Detail

      • selectLocale

        public static java.util.Locale selectLocale​(javax.servlet.http.HttpServletRequest request,
                                                    ChannelConfig channel)
                                             throws PortalException
        Returns the selected locale for a given channel and request.
        Parameters:
        request - the request.
        channel - the channel.
        Returns:
        the selected locale for a given channel and request.
        Throws:
        PortalException
        Since:
        8.1.0
      • setCookie

        public static void setCookie​(java.util.Locale locale,
                                     javax.servlet.http.HttpServletRequest request,
                                     javax.servlet.http.HttpServletResponse response)
        Sets the locale cookie using the given locale as value.
        Parameters:
        locale - the locale.
        request - the request.
        response - the response.
        Since:
        8.1.0
      • shouldUpdateSessionLocale

        public static boolean shouldUpdateSessionLocale​(javax.servlet.http.HttpServletRequest request)
        Returns whether the session locale should be updated.
        Parameters:
        request - the request.
        Returns:
        whether the session locale should be updated.
        Since:
        8.1.0
      • markSessionLocaleToBeUpdated

        public static void markSessionLocaleToBeUpdated​(javax.servlet.http.HttpServletRequest request)
        Marks the session to have the locale updated.
        Parameters:
        request - the request.
        Since:
        8.1.0
      • markSessionLocaleUpdated

        public static void markSessionLocaleUpdated​(javax.servlet.http.HttpServletRequest request)
        Mark the session as having the locale updated.
        Parameters:
        request - the request.
        Since:
        8.1.0
      • isCurrentLocaleValid

        public static boolean isCurrentLocaleValid​(ChannelConfig channel)
                                            throws PortalException
        Returns whether the session locale is valid for a given channel.
        Parameters:
        channel - the channel.
        Returns:
        whether the session locale is valid for a given channel.
        Throws:
        PortalException
        Since:
        8.1.0
      • extractJsonObject

        public static org.json.simple.JSONObject extractJsonObject​(LocaleConfig locale)
        Transform Locale to JsonObject Example: { "label" : "português (Brasil)", "value" : "pt_BR" }
        Parameters:
        locale -
        Returns:
        Since:
        8.1.0