Class BundleLookupThreadContext


  • public final class BundleLookupThreadContext
    extends Object

    Each thread has a markup context associated with it. When set, bundle lookups will be recorded with any markup-context appropriate prefixes and suffixes added. This allows the use of a normal API while providing a mechanism for in-context translation interfaces to better integrate with the underlying resource bundles.

    Under concurrent programming, one context can end up being accessed concurrently by multiple threads, thus BundleLookupThreadContext is a thread-safe implementation.

    Bundle lookups are not guaranteed to be recorded, such as when in-context translation is disabled (production mode).

    • Method Detail

      • getThreadContext

        public static BundleLookupThreadContext getThreadContext​(boolean createIfMissing)
        Gets the current context or null if none set and none created.
      • removeThreadContext

        public static void removeThreadContext()
        Removes any current context.
      • reset

        public void reset()
        Removes all lookups stored in this context.
      • getLookupMarkup

        public BundleLookupMarkup getLookupMarkup​(String result)
        Gets the lookup markup for the given String or null if not found.

        The string is looked-up by identity only: .equals() is not called. This is to give a more precise match to lookups.