Package com.aoindustries.util.i18n
Class BundleLookupThreadContext
- java.lang.Object
-
- com.aoindustries.util.i18n.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description BundleLookupMarkupgetLookupMarkup(String result)Gets the lookup markup for the given String ornullif not found.static BundleLookupThreadContextgetThreadContext(boolean createIfMissing)Gets the current context ornullif none set and none created.static voidremoveThreadContext()Removes any current context.voidreset()Removes all lookups stored in this context.
-
-
-
Method Detail
-
getThreadContext
public static BundleLookupThreadContext getThreadContext(boolean createIfMissing)
Gets the current context ornullif 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 ornullif not found.The string is looked-up by identity only: .equals() is not called. This is to give a more precise match to lookups.
-
-