Package java.util
Class ResourceBundle.Control
- java.lang.Object
-
- java.util.ResourceBundle.Control
-
- Enclosing class:
- ResourceBundle
public static class ResourceBundle.Control extends Object
ResourceBundle.Control is a static utility class defines ResourceBundle load access methods, its default access order is as the same as before. However users can implement their own control.- Since:
- 1.6
-
-
Field Summary
Fields Modifier and Type Field Description static List<String>FORMAT_CLASSa list defines java class formatstatic List<String>FORMAT_DEFAULTa list defines default formatstatic List<String>FORMAT_PROPERTIESa list defines property formatstatic longTTL_DONT_CACHEa constant that indicates cache will not be used.static longTTL_NO_EXPIRATION_CONTROLa constant that indicates cache will not be expired.
-
Constructor Summary
Constructors Modifier Constructor Description protectedControl()default constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Locale>getCandidateLocales(String baseName, Locale locale)Returns a list of candidate locales according tobaseNameinlocale.static ResourceBundle.ControlgetControl(List<String> formats)Returns a control according toformats.LocalegetFallbackLocale(String baseName, Locale locale)Returns the fallback locale forbaseNameinlocale.List<String>getFormats(String baseName)Returns a list of strings of formats according tobaseName.static ResourceBundle.ControlgetNoFallbackControl(List<String> formats)Returns a control according toformatswhose fallback locale is null.longgetTimeToLive(String baseName, Locale locale)Returns the time to live of the ResourceBundlebaseNameinlocale, default is TTL_NO_EXPIRATION_CONTROL.booleanneedsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)Returns true if the ResourceBundle needs to reload.ResourceBundlenewBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)Returns a new ResourceBundle.StringtoBundleName(String baseName, Locale locale)a utility method to answer the name of a resource bundle according to the given base name and localeStringtoResourceName(String bundleName, String suffix)a utility method to answer the name of a resource according to the given bundleName and suffix
-
-
-
Field Detail
-
TTL_DONT_CACHE
public static final long TTL_DONT_CACHE
a constant that indicates cache will not be used.- See Also:
- Constant Field Values
-
TTL_NO_EXPIRATION_CONTROL
public static final long TTL_NO_EXPIRATION_CONTROL
a constant that indicates cache will not be expired.- See Also:
- Constant Field Values
-
-
Method Detail
-
getControl
public static ResourceBundle.Control getControl(List<String> formats)
Returns a control according toformats.
-
getNoFallbackControl
public static ResourceBundle.Control getNoFallbackControl(List<String> formats)
Returns a control according toformatswhose fallback locale is null.
-
getCandidateLocales
public List<Locale> getCandidateLocales(String baseName, Locale locale)
Returns a list of candidate locales according tobaseNameinlocale.
-
getFormats
public List<String> getFormats(String baseName)
Returns a list of strings of formats according tobaseName.
-
getFallbackLocale
public Locale getFallbackLocale(String baseName, Locale locale)
Returns the fallback locale forbaseNameinlocale.
-
newBundle
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException
Returns a new ResourceBundle.- Parameters:
baseName- the base name to uselocale- the given localeformat- the format, default is "java.class" or "java.properties"loader- the classloader to usereload- whether to reload the resource- Returns:
- a new ResourceBundle according to the give parameters
- Throws:
IllegalAccessException- if we can not access resourcesInstantiationException- if we can not instantiate a resource classIOException- if other I/O exception happens
-
getTimeToLive
public long getTimeToLive(String baseName, Locale locale)
Returns the time to live of the ResourceBundlebaseNameinlocale, default is TTL_NO_EXPIRATION_CONTROL.
-
needsReload
public boolean needsReload(String baseName, Locale locale, String format, ClassLoader loader, ResourceBundle bundle, long loadTime)
Returns true if the ResourceBundle needs to reload.- Parameters:
baseName- the base name of the ResourceBundlelocale- the locale of the ResourceBundleformat- the format to loadloader- the ClassLoader to load resourcebundle- the ResourceBundleloadTime- the expired time- Returns:
- if the ResourceBundle needs to reload
-
toBundleName
public String toBundleName(String baseName, Locale locale)
a utility method to answer the name of a resource bundle according to the given base name and locale- Parameters:
baseName- the given base namelocale- the locale to use- Returns:
- the name of a resource bundle according to the given base name and locale
-
toResourceName
public final String toResourceName(String bundleName, String suffix)
a utility method to answer the name of a resource according to the given bundleName and suffix- Parameters:
bundleName- the given bundle namesuffix- the suffix- Returns:
- the name of a resource according to the given bundleName and suffix
-
-