Package org.eclipse.birt.core.i18n

# Class ThreadResources

java.lang.Object
org.eclipse.birt.core.i18n.ThreadResources

public class ThreadResources extends Object
Provides access to a resource bundle associated with this thread. The application calls `setThreadLocale` to set the locale for the thread, then calls the `getMessage` methods.

See Also:
  - `ResourceHandle`

## Constructor Summary

Constructors
Constructor
Description
`ThreadResources()`

## Method Summary

Modifier and Type
Method
Description
`static Locale`
`getLocale()`
Deprecated.
since 2.1
`static String`
`getMessage(String key)`
Get a message given the message key.
`static String`
`getMessage(String key, Object[] arguments)`
Get a message that has placeholders.
`static com.ibm.icu.util.ULocale`
`getULocale()`
Get the locale of current user-thread.
`static void`
`setLocale(com.ibm.icu.util.ULocale locale)`
Set the locale of current user-thread.
`static void`
`setLocale(Locale locale)`
Deprecated.
since 2.1

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ThreadResources

public ThreadResources()

## Method Details

### setLocale

public static void setLocale(com.ibm.icu.util.ULocale locale)
Set the locale of current user-thread. This method should be called before access to any localized message. Call with null to clear the thread locale.

Parameters:
  `locale` - Locale of the current thread.

### setLocale

@Deprecated public static void setLocale(Locale locale)
Deprecated.
since 2.1

### getULocale

public static com.ibm.icu.util.ULocale getULocale()
Get the locale of current user-thread.

Returns:
  Locale of the current thread.

### getLocale

@Deprecated public static Locale getLocale()
Deprecated.
since 2.1

Returns:

### getMessage

public static String getMessage(String key)
Get a message given the message key. An assertion will be raised if the message key does not exist in the resource bundle. The locale must have previously been set for this thread.

Parameters:
  `key` - the message key
Returns:
  the localized message for that key and the locale set in the constructor. Returns the key itself if the message was not found.
See Also:
  - `ResourceBundle.getString(String)`
  - `ResourceHandle.getMessage(String)`

### getMessage

public static String getMessage(String key, Object[] arguments)
Get a message that has placeholders. An assertion will be raised if the message key does not exist in the resource bundle. The locale must have previously been set for this thread.

Parameters:
  `key` - the message key
  `arguments` - the set of arguments to be plugged into the message
Returns:
  the localized message for that key and the locale set in the constructor. Returns the key itself if the message was not found.
See Also:
  - `ResourceBundle.getString(String)`
  - `MessageFormat.format(String, Object[])`
  - `ResourceHandle.getMessage(String, Object[])`