Package de.aristaflow.adept2.util.i18n
Class Utf8ResourceBundleControl
- java.lang.Object
-
- java.util.ResourceBundle.Control
-
- de.aristaflow.adept2.util.i18n.Utf8ResourceBundleControl
-
public class Utf8ResourceBundleControl extends ResourceBundle.Control
This control loads a resource bundle with UTF-8. This is only required for Java < 9 since these JVMs use ISO-8859-1 as encoding for resource bundles. Java 9 changed this to UTF-8.
Optionally, this bundle control allows to prevent falling back to the default locale of the JVM thus combiningResourceBundle.Control
andResourceBundle.NoFallbackControl.NO_FALLBACK
. It also allows to define the resource bundle formats to be used.Due to the restrictive visibility and static methods, most of the content of this class has been copied from the superclass.
Only use this control if you are using Java 8!. Since code has been copied, this class may not be up-to-date to the latest JVMs.
-
-
Field Summary
Fields Modifier and Type Field Description protected List<String>
formats
The formats of the resource bundles to be used.protected boolean
noFallback
Whether to not fallback to the default locale.-
Fields inherited from class java.util.ResourceBundle.Control
FORMAT_CLASS, FORMAT_DEFAULT, FORMAT_PROPERTIES, TTL_DONT_CACHE, TTL_NO_EXPIRATION_CONTROL
-
-
Constructor Summary
Constructors Constructor Description Utf8ResourceBundleControl()
Creates a new bundle control reading a resource bundle with UTF-8 falling back to the default locale of the JVM.Utf8ResourceBundleControl(boolean noFallback)
Creates a new bundle control reading a resource bundle with UTF-8.Utf8ResourceBundleControl(List<String> formats)
Creates a new bundle control reading a resource bundle with UTF-8 falling back to the default locale of the JVM.Utf8ResourceBundleControl(List<String> formats, boolean noFallback)
Creates a new bundle control reading a resource bundle with UTF-8.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Locale
getFallbackLocale(String baseName, Locale locale)
List<String>
getFormats(String baseName)
ResourceBundle
newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
-
Methods inherited from class java.util.ResourceBundle.Control
getCandidateLocales, getControl, getNoFallbackControl, getTimeToLive, needsReload, toBundleName, toResourceName
-
-
-
-
Constructor Detail
-
Utf8ResourceBundleControl
public Utf8ResourceBundleControl()
Creates a new bundle control reading a resource bundle with UTF-8 falling back to the default locale of the JVM.
-
Utf8ResourceBundleControl
public Utf8ResourceBundleControl(boolean noFallback)
Creates a new bundle control reading a resource bundle with UTF-8.- Parameters:
noFallback
- Whether to not fallback to the default locale.
-
Utf8ResourceBundleControl
public Utf8ResourceBundleControl(List<String> formats)
Creates a new bundle control reading a resource bundle with UTF-8 falling back to the default locale of the JVM.
-
-
Method Detail
-
getFormats
public List<String> getFormats(String baseName)
- Overrides:
getFormats
in classResourceBundle.Control
-
getFallbackLocale
public Locale getFallbackLocale(String baseName, Locale locale)
- Overrides:
getFallbackLocale
in classResourceBundle.Control
-
newBundle
public ResourceBundle newBundle(String baseName, Locale locale, String format, ClassLoader loader, boolean reload) throws IllegalAccessException, InstantiationException, IOException
- Overrides:
newBundle
in classResourceBundle.Control
- Throws:
IllegalAccessException
InstantiationException
IOException
-
-