java.lang.Object
io.sf.jclf.util.locale.ObjectBundle
Map of localized objects.
The objects have been initialized with the contents of the files following the schema:
baseName.ext, baseName.locale.ext
-
Constructor Summary
ConstructorDescriptionObjectBundle
(String path, ResourceFactory rf) All subclasses constructors MUST call loadDefaultFile().ObjectBundle
(String baseName, String ext, ResourceFactory rf) -
Method Summary
Modifier and TypeMethodDescriptionget()
Get the object for the default locale.Get the object associated to the given locale.Get the base name of the resource managed by this bundle.Get the best object associated to the given locale.getBestLocale
(Enumeration<Locale> locales) Gets the locale with the best support from those inloc
getBestLocale
(Locale[] loc) Gets the locale with the best support from those inloc
Get the default locale.Get the extension associated to this bundle.long
Get the last time the resource factory was last modified.protected void
void
setDefaultLocale
(Locale locale) Set the default locale.toString()
-
Constructor Details
-
ObjectBundle
All subclasses constructors MUST call loadDefaultFile().- Parameters:
path
- Path to default file, optionally including an extension. Separates the extension assuming a '.' as separator.rf
- the resource factory.- Throws:
IOException
- if there is a problem loading the default locale file.
-
ObjectBundle
- Parameters:
baseName
- Path to default file, without the extension.ext
- the extension (can be null if none)rf
- the resource factory.- Throws:
IOException
- if there is a problem loading the default locale file.
-
-
Method Details
-
getExtension
Get the extension associated to this bundle.- Returns:
- the extension, or null if none.
-
getLastModified
public long getLastModified()Get the last time the resource factory was last modified.- Returns:
- the last time (in milliseconds) the resource factory was last modified.
-
get
Get the object for the default locale.- Returns:
- Object for the default locale.
-
getBest
Get the best object associated to the given locale.- Parameters:
locale
- the locale.- Returns:
- the object associated to the locale, or the one for the default locale if the object could not be loaded for the given locale.
-
get
Get the object associated to the given locale.- Parameters:
locale
- the locale.- Returns:
- the object associated to the locale, or null if the object could not be loaded.
-
getBestLocale
Gets the locale with the best support from those inloc
- Parameters:
loc
- the array with the accepted locales.- Returns:
- the best locale from loc, or the default one if the best cannot be found.
-
getBestLocale
Gets the locale with the best support from those inloc
- Parameters:
locales
- the Enumeration with the accepted locales.- Returns:
- the best locale from locales, or the default one if the best cannot be found.
-
loadDefaultFile
- Throws:
IOException
-
getDefaultLocale
Get the default locale. If no default locale was explicitly set, the system's default locale will be returned.- Returns:
- the default locale.
-
setDefaultLocale
Set the default locale.- Parameters:
locale
- the locale.
-
getBaseName
Get the base name of the resource managed by this bundle.If the resource filenames are for example like 'foo_en_US.txt', this method will return 'foo', and
getExtension
'txt'.- Returns:
- the base name.
-
toString
-