Class FixedLocaleResolver

  • All Implemented Interfaces:
    LocaleResolver

    public class FixedLocaleResolver
    extends AbstractLocaleResolver
    LocaleResolver implementation that always returns a fixed default locale and optionally time zone. Default is the current JVM's default locale.

    Note: Does not support setLocale(Context), as the fixed locale and time zone cannot be changed.

    Created: 2016. 9. 5.

    • Constructor Detail

      • FixedLocaleResolver

        public FixedLocaleResolver​(java.util.Locale locale)
        Create a FixedLocaleResolver that exposes the given locale.
        Parameters:
        locale - the locale to expose
      • FixedLocaleResolver

        public FixedLocaleResolver​(java.util.Locale locale,
                                   java.util.TimeZone timeZone)
        Create a FixedLocaleResolver that exposes the given locale and time zone.
        Parameters:
        locale - the locale to expose
        timeZone - the time zone to expose
    • Method Detail

      • resolveLocale

        public java.util.Locale resolveLocale​(Translet translet)
        Description copied from interface: LocaleResolver
        Resolve the current locale via the given translet. Can return a default locale as fallback in any case.
        Parameters:
        translet - the translet to resolve the locale for
        Returns:
        the current locale (never null)
      • resolveTimeZone

        public java.util.TimeZone resolveTimeZone​(Translet translet)
        Description copied from interface: LocaleResolver
        Resolve the current timezone via the given translet. Can return a default timezone as fallback in any case.
        Parameters:
        translet - the translet to resolve the timezone for
        Returns:
        the current timezone (never null)
      • setLocale

        public void setLocale​(Translet translet,
                              java.util.Locale locale)
        Description copied from interface: LocaleResolver
        Set the current locale to the given one.
        Specified by:
        setLocale in interface LocaleResolver
        Overrides:
        setLocale in class AbstractLocaleResolver
        Parameters:
        translet - the translet to resolve the locale for
        locale - the new locale, or null to clear the locale
      • setTimeZone

        public void setTimeZone​(Translet translet,
                                java.util.TimeZone timeZone)
        Description copied from interface: LocaleResolver
        Set the current timezone to the given one.
        Specified by:
        setTimeZone in interface LocaleResolver
        Overrides:
        setTimeZone in class AbstractLocaleResolver
        Parameters:
        translet - the translet to resolve the locale for
        timeZone - the new timezone, or null to clear the timezone