Class LocaleContextManager

    • Constructor Detail

      • LocaleContextManager

        public LocaleContextManager()
    • Method Detail

      • getCurrentLocale

        public static Locale getCurrentLocale()
        Returns:
        The Locale for the current thread, or null if no context was initialized.
        See Also:
        getCurrentLocaleOrDefault()
      • getCurrentLocaleOrDefault

        public static Locale getCurrentLocaleOrDefault()
        Returns:
        The Locale for the current thread, or Locale.getDefault() if no context was initialized.
        See Also:
        Locale.getDefault()
      • initializeNewContext

        public Context<Locale> initializeNewContext​(Locale value)
        Registers the given Locale value as the current Locale for the active thread until the returned context is closed again.
        Specified by:
        initializeNewContext in interface ContextManager<Locale>
        Parameters:
        value - The new current Locale.
        Returns:
        The context to be closed again by the caller to remove this locale as current locale.
      • getActiveContext

        public Context<Locale> getActiveContext()
        Description copied from interface: ContextManager
        The currently active context, or null if no context is active.
        Specified by:
        getActiveContext in interface ContextManager<Locale>
        Returns:
        The active Locale context or null if no such context is active in the current thread.
      • clear

        public static void clear()
        Unconditionally removes the active context (and any parents).

        This is useful for boundary filters, whose Threads may be returned to some threadpool.

      • toString

        public String toString()
        Overrides:
        toString in class Object
        Returns:
        String representation for this context manager.