public class DefaultNlsResourceLocator extends AbstractComponent implements NlsResourceLocator
SEPARATOR
Constructor and Description |
---|
DefaultNlsResourceLocator()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
DataResource |
findResource(Class<?> type,
String extension,
Locale locale)
|
DataResource |
findResource(String pathAndBasicName,
String extension,
Locale locale)
This method finds a localized
resource . |
Locale |
getLocale(String locale)
Create a
Locale from a given String representation such as Locale.toString() or
Locale.forLanguageTag(String) . |
Locale |
getLocaleForInfix(String localeInfix)
This method gets the
Locale for the given locale-infix . |
String[] |
getLocaleInfixes(Locale locale)
This method determines the infix-strings for localization lookup ordered from most specific to least specific
(empty string representing
Locale.ROOT ). |
doInitialize, doInitialized, getInitializationState, initialize
public Locale getLocale(String locale)
NlsResourceLocator
Locale
from a given String
representation such as Locale.toString()
or
Locale.forLanguageTag(String)
.getLocale
in interface NlsResourceLocator
locale
- the String
representation of the Locale
.Locale
.public Locale getLocaleForInfix(String localeInfix)
NlsResourceLocator
Locale
for the given locale-infix
.getLocaleForInfix
in interface NlsResourceLocator
localeInfix
- is the locale-infix (e.g. "_en_US").localeInfix
. Locale.ROOT
if the given localeInfix
is
invalid.NlsResourceLocator.getLocale(String)
public String[] getLocaleInfixes(Locale locale)
NlsResourceLocator
Locale.ROOT
). Each infix is defined as:
[_<Please note that if a segment is empty but a following segment is present, multiple underscores ('_') will occur.language
>[_<country
>[_<variant
>]]]
locale | result |
---|---|
Locale.GERMANY |
{"_de_DE", "_de", ""} |
new |
{"__CM", ""} |
new |
{"___variant", ""} |
getLocaleInfixes
in interface NlsResourceLocator
locale
- is the Locale
.public DataResource findResource(Class<?> type, String extension, Locale locale)
NlsResourceLocator
findResource
in interface NlsResourceLocator
type
- is the Class
identifying the path of the resource including the filename without locale-part (
infix
) or extension
.extension
- is the final suffix of the requested DataResource
. Typically ".properties" or ".xml".locale
- is the locale for which the resource
is requested.resource
for the given Locale
.public DataResource findResource(String pathAndBasicName, String extension, Locale locale)
NlsResourceLocator
resource
. It returns the most specific resource for the given
path:
<pathAndBasicName><infix><extension>with
<infix> = [_<locale.getLanguage()>[_<locale.getCountry()>[_<locale.getVariant()>]]]If a locale-specific part is NOT defined, the according part of the path is omitted. E.g. for
Locale.GERMANY
the following values are tried for <infix>:"de_DE", "de", ""
findResource
in interface NlsResourceLocator
pathAndBasicName
- is the path of the resource including the filename without locale-part or extension
. Folders (or packages) need to be separated with '/' and NOT with '.'. E.g.
"net/sf/mmm/util/nls/text/Hypenator".extension
- is the suffix of the requested DataResource
. Typically ".properties" or ".xml". May be the
empty string.locale
- is the locale for which the resource
is requested.resource
for the given Locale
.Copyright © 2001–2016 mmm-Team. All rights reserved.