Methods Summary |
---|
private static native int | getDevLocaleIndex(java.lang.String locale)Get index of supported locales for device resources by its name.
|
private static native java.lang.String | getDevLocaleName(int index)Get one of supported device locales (by number).
|
private static native int | getDevLocalesCount()Get number of supported locales for device resources.
|
public ResourceManager | getManager(java.lang.String baseName)Returns an instance of ResourceManager class for the given
base name and system's default locale.
This method is never used - default system locale is handled in the
{@link javax.microedition.global.ResourceManager} class.
return null;
|
public ResourceManager | getManager(java.lang.String baseName, java.lang.String locale)Creates an instance of ResourceManager class for the given
base name and locale.
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR238,
classname + ": getManager (" +
baseName + ", " + locale + ")");
}
String[] supported_locales = getSupportedLocales(baseName);
Vector vlocales = new Vector(5);
Vector vreaders = new Vector(5);
if (locale == null) locale = "";
// go through all parent locales match them against supported locales
for (String alocale = locale; alocale != null;
alocale = LocaleHelpers.getParentLocale(alocale)) {
int index = LocaleHelpers.indexInSupportedLocales(alocale,
supported_locales);
if (index >= 0) {
ResourceBundleReader reader =
new DevResourceBundleReader(index);
if (null != reader) {
vlocales.addElement(alocale);
vreaders.addElement(reader);
} else {
throw new ResourceException(
ResourceException.NO_RESOURCES_FOR_BASE_NAME,
"Device resources for \"" + alocale +
"\" are missing.");
}
} else {
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR238,
classname + ": " + "locale \"" +
alocale + "\" not supported.");
}
}
}
if (vlocales.size() == 0) {
// base name not supported for locale nor for any parent locale
throw new UnsupportedLocaleException();
}
String[] drm_locales = new String[vlocales.size()];
ResourceBundleReader[] drm_readers =
new ResourceBundleReader[vreaders.size()];
vlocales.copyInto(drm_locales);
vreaders.copyInto(drm_readers);
// instantiate ResourceManager with supported locales
return new DevResourceManager(drm_locales, drm_readers, resourceCache);
|
public ResourceManager | getManager(java.lang.String baseName, java.lang.String[] locales)Creates an instance of ResourceManager class for the given
base name and the first matching locale in the supplied array.
String[] supported_locales = getSupportedLocales(baseName);
for (int i = 0; i < locales.length; i++) {
int index = LocaleHelpers.indexInSupportedLocales(locales[i],
supported_locales);
if (index >= 0) {
return getManager(baseName, locales[i]);
}
}
throw new UnsupportedLocaleException();
|
public java.lang.String[] | getSupportedLocales(java.lang.String baseName)Returns a list of locales supported by DevResourceManager .
Device resource manager can be constructed for each locale from the list.
int lcount = getDevLocalesCount();
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR238,
"Number of supported locales: " + lcount);
}
String[] locales = new String[lcount--];
for (; lcount >= 0; lcount--) {
locales[lcount] = getDevLocaleName(lcount);
if (Logging.REPORT_LEVEL <= Logging.INFORMATION) {
Logging.report(Logging.INFORMATION, LogChannels.LC_JSR238,
"Locale #" + lcount + ": " + locales[lcount]);
}
}
return locales;
|