Class LocaleChangeInterceptor


  • public class LocaleChangeInterceptor
    extends java.lang.Object
    Interceptor that allows for changing the current locale on every request, via a configurable request parameter (default parameter name: "locale").

    Created: 2016. 3. 13.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DEFAULT_LOCALE_PARAM_NAME
      Default name of the locale specification parameter: "locale".
      static java.lang.String DEFAULT_TIMEZONE_PARAM_NAME
      Default name of the timezone specification parameter: "timezone".
      protected Log log  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String[] getAllowedMethods()
      Return the configured HTTP methods.
      java.lang.String getLocaleParamName()
      Return the name of the parameter that contains a locale specification in a locale change request.
      java.lang.String getTimeZoneParamName()
      Return the name of the parameter that contains a timezone specification in a timezone change request.
      void handle​(Translet translet, LocaleResolver localeResolver)  
      boolean isIgnoreInvalidLocale()
      Return whether to ignore an invalid value for the locale parameter.
      void setIgnoreInvalidLocale​(boolean ignoreInvalidLocale)
      Set whether to ignore an invalid value for the locale parameter.
      void setLocaleParamName​(java.lang.String localeParamName)
      Set the name of the parameter that contains a locale specification in a locale change request.
      void setRequestMethods​(java.lang.String... requestMethods)
      Configure the request method(s) over which the locale can be changed.
      void setTimeZoneParamName​(java.lang.String timezoneParamName)
      Set the name of the parameter that contains a timezone specification in a locale change request.
      • Methods inherited from class java.lang.Object

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

      • DEFAULT_LOCALE_PARAM_NAME

        public static final java.lang.String DEFAULT_LOCALE_PARAM_NAME
        Default name of the locale specification parameter: "locale".
        See Also:
        Constant Field Values
      • DEFAULT_TIMEZONE_PARAM_NAME

        public static final java.lang.String DEFAULT_TIMEZONE_PARAM_NAME
        Default name of the timezone specification parameter: "timezone".
        See Also:
        Constant Field Values
      • log

        protected final Log log
    • Constructor Detail

      • LocaleChangeInterceptor

        public LocaleChangeInterceptor()
    • Method Detail

      • setLocaleParamName

        public void setLocaleParamName​(java.lang.String localeParamName)
        Set the name of the parameter that contains a locale specification in a locale change request. Default is "locale".
        Parameters:
        localeParamName - the locale parameter name
      • setTimeZoneParamName

        public void setTimeZoneParamName​(java.lang.String timezoneParamName)
        Set the name of the parameter that contains a timezone specification in a locale change request. Default is "timezone".
        Parameters:
        timezoneParamName - the timezone parameter name
      • getLocaleParamName

        public java.lang.String getLocaleParamName()
        Return the name of the parameter that contains a locale specification in a locale change request.
        Returns:
        the locale parameter name
      • getTimeZoneParamName

        public java.lang.String getTimeZoneParamName()
        Return the name of the parameter that contains a timezone specification in a timezone change request.
        Returns:
        the time zone parameter name
      • setRequestMethods

        public void setRequestMethods​(java.lang.String... requestMethods)
        Configure the request method(s) over which the locale can be changed.
        Parameters:
        requestMethods - the methods
      • getAllowedMethods

        public java.lang.String[] getAllowedMethods()
        Return the configured HTTP methods.
        Returns:
        the string [ ]
      • setIgnoreInvalidLocale

        public void setIgnoreInvalidLocale​(boolean ignoreInvalidLocale)
        Set whether to ignore an invalid value for the locale parameter.
        Parameters:
        ignoreInvalidLocale - whether ignoring invalid locale
      • isIgnoreInvalidLocale

        public boolean isIgnoreInvalidLocale()
        Return whether to ignore an invalid value for the locale parameter.
        Returns:
        whether ignoring invalid locale