Java.util.ResourceBundle.Control Class


Advertisements

Introduction

The java.util.ResourceBundle.Control class collaborates with the factory methods for loading resource bundles.Following are the important points about ResourceBundle.Control −

  • The class instance must be thread-safe if it's simultaneously used by multiple threads.

Class declaration

Following is the declaration for java.util.ResourceBundle.Control class −

public static class ResourceBundle.Control
   extends Object

Field

Following are the fields for java.util.ResourceBundle.Control class −

  • static int STANDARD_TIME − This is the constant for a mode of start or end time specified as standard time.

  • static List<String> FORMAT_CLASS − This is the format List containing "java.class".

  • static List<String> FORMAT_DEFAULT − This is the default format List, which contains the strings "java.class" and "java.properties", in this order.

  • static List<String> FORMAT_PROPERTIES − This is the properties-only format List containing "java.properties".

  • static long TTL_DONT_CACHE − This is the time-to-live constant for not caching loaded resource bundle instances.

  • static long TTL_NO_EXPIRATION_CONTROL − This is the time-to-live constant for disabling the expiration control for loaded resource bundle instances in the cache.

Class constructors

Sr.No. Constructor & Description
1

List<Locale> getCandidateLocales(String baseName, Locale locale)

This is the single constructor.

Class methods

Sr.No. Method & Description
1 List<Locale>getCandidateLocales(String baseName, Locale locale)

This method returns a List of Locales as candidate locales for baseName and locale.

2 static ResourceBundle.Control getControl(List<String> formats)

This method returns a ResourceBundle.Control in which the getFormats method returns the specified formats.

3 Locale getFallbackLocale(String baseName, Locale locale)

This method returns a Locale to be used as a fallback locale for further resource bundle searches by the ResourceBundle.getBundle factory method.

4 List<String> getFormats(String baseName)

This method returns a list of strings containing formats to be used to load resource bundles for the given baseName.

5 static ResourceBundle.Control getNoFallbackControl(List<String> formats)

This method returns a ResourceBundle.Control in which the getFormats method returns the specified formats and the getFallbackLocale method returns null.

6 long getTimeToLive(String baseName, Locale locale)

This method returns the time-to-live (TTL) value for resource bundles that are loaded under this ResourceBundle.Control.

7 boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)

This method determines if the expired bundle in the cache needs to be reloaded based on the loading time given by loadTime or some other criteria.

8 ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)

This method instantiates a resource bundle for the given bundle name of the given format and locale, using the given class loader if necessary.

9 String toBundleName(String baseName, Locale locale)

This method converts the given baseName and locale to the bundle name.

10 String toResourceName(String bundleName, String suffix)

This method converts the given bundleName to the form required by the ClassLoader.getResource method by replacing all occurrences of '.' in bundleName with '/' and appending a '.' and the given file suffix.

Methods inherited

This class inherits methods from the following classes −

  • java.util.Object
Advertisements