- All Implemented Interfaces:
Serializable
,Cloneable
,Map<Object,
Object>
Adds the notion of localization to the Properties class.
Allows property files to be loaded according to Locale information, and
provides a getLocale
method to retrieve the Locale
corresponding to this LocalProperties object.
- See Also:
-
Field Summary
Fields inherited from class java.util.Properties
defaults
-
Constructor Summary
ConstructorDescriptionLocalProperties
(Locale locale) Creates a LocalProperties for the given locale.LocalProperties
(Locale locale, Properties p) Creates a LocalProperties with a default set of properties. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Checks if the default locale file with baseFileName exists an can be read.Gets the locale.static LocalProperties
loadBestLocalProperties
(String baseName, String ext, Locale locale) Load the appropriate LocalProperties.static LocalProperties
loadLocalProperties
(String baseName, String ext) Load the appropriate LocalProperties for the given basename and extension.static LocalProperties
loadLocalProperties
(String baseName, String ext, Locale locale) Load the appropriate LocalProperties.Methods inherited from class java.util.Properties
clear, clone, compute, computeIfAbsent, computeIfPresent, contains, containsKey, containsValue, elements, entrySet, equals, forEach, get, getOrDefault, getProperty, getProperty, hashCode, isEmpty, keys, keySet, list, list, load, load, loadFromXML, merge, propertyNames, put, putAll, putIfAbsent, rehash, remove, remove, replace, replace, replaceAll, save, setProperty, size, store, store, storeToXML, storeToXML, storeToXML, stringPropertyNames, toString, values
-
Constructor Details
-
LocalProperties
Creates a LocalProperties for the given locale.- Parameters:
locale
- the locale
-
LocalProperties
Creates a LocalProperties with a default set of properties.- Parameters:
locale
- the locale.p
- properties
-
-
Method Details
-
getLocale
Gets the locale.- Returns:
- the real locale name of this object, which may be different from the locale by which was invoked at the factory.
-
loadLocalProperties
public static LocalProperties loadLocalProperties(String baseName, String ext) throws LocaleNotFoundException Load the appropriate LocalProperties for the given basename and extension.- Parameters:
baseName
- the base name for the propertiesext
- the file extension- Returns:
- the requested LocalProperties object, or the one for the default locale if the requested one could not be loaded.
- Throws:
LocaleNotFoundException
- if no LocalProperties could be loaded (this use of the exception is a bit bogus).
-
loadBestLocalProperties
public static LocalProperties loadBestLocalProperties(String baseName, String ext, Locale locale) throws LocaleNotFoundException Load the appropriate LocalProperties.First tries to return the LocalProperties for the given locale, and if not possible, returns the default.
- Parameters:
baseName
- see class description.ext
- the file extensionlocale
- see class description.- Returns:
- the requested LocalProperties object, or the one for the default locale if the requested one could not be loaded.
- Throws:
LocaleNotFoundException
- if no LocalProperties could be loaded (this use of the exception is a bit bogus).
-
loadLocalProperties
public static LocalProperties loadLocalProperties(String baseName, String ext, Locale locale) throws LocaleNotFoundException Load the appropriate LocalProperties.- Parameters:
baseName
- see class description.ext
- the file extensionlocale
- see class description.- Returns:
- the requested LocalProperties object, or null if no properties could be loaded.
- Throws:
LocaleNotFoundException
- if the LocalProperties could not be loaded (this use of the exception is a bit bogus).
-
check
Checks if the default locale file with baseFileName exists an can be read.- Parameters:
baseFileName
- see class description.ext
- the file extension- Returns:
true
if the default locale exists,false
otherwise
-