Package org.eclipse.birt.core.i18n

# Class ResourceHandle

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

public class ResourceHandle extends Object
Represents a set of resources for a given package and locale. This class will associate with a user session. Each user session has a single locale. This class assumes that the resources are in the same location as the class itself, and are named "Messages.properties", "Messages_xx.properties", etc.

Once stable, the application will not access a message that does not exist. To help get the system stable, this class raises an assertion if the message key refers to a missing exception. The class then returns the message key itself as the message.

This class primarily works with messages. It can be extended to work with other resources as the need arises.

See Also:
  - `ThreadResources`

## Field Summary

Fields
Modifier and Type
Field
Description
`protected com.ibm.icu.util.UResourceBundle`
`resources`
The actual resource bundle.

## Constructor Summary

Constructors
Constructor
Description
`ResourceHandle(com.ibm.icu.util.ULocale locale)`
Constructor.
`ResourceHandle(Locale locale)`
Deprecated.
since 2.1

## Method Summary

Modifier and Type
Method
Description
`String`
`getMessage(String key)`
Get a message given the message key.
`String`
`getMessage(String key, Object[] arguments)`
Get a message that has placeholders.
`ResourceBundle`
`getResourceBundle()`
Deprecated.
since 2.1
`com.ibm.icu.util.UResourceBundle`
`getUResourceBundle()`
Returns the resource bundle for the current locale.

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

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

## Field Details

### resources

protected com.ibm.icu.util.UResourceBundle resources
The actual resource bundle. The implementation assumes that Java will use a PropertyResourceBundle to access our files.

## Constructor Details

### ResourceHandle

public ResourceHandle(com.ibm.icu.util.ULocale locale)
Constructor.

Parameters:
  `locale` - the user's locale. If null, the default locale for the JVM will be used.

### ResourceHandle

@Deprecated public ResourceHandle(Locale locale)
Deprecated.
since 2.1

## Method Details

### getMessage

public 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.

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)`

### getMessage

public 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.

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[])`

### getUResourceBundle

public com.ibm.icu.util.UResourceBundle getUResourceBundle()
Returns the resource bundle for the current locale.

Returns:
  the resource bundle
See Also:
  - `ResourceBundle`

### getResourceBundle

@Deprecated public ResourceBundle getResourceBundle()
Deprecated.
since 2.1

Returns: