/* * This method find the appropriate Manifest Localization file inside the * bundle. If not found, return null. */ ResourceBundle getResourceBundle(String localeString, boolean isDefaultLocale) { BundleResourceBundle resourceBundle = lookupResourceBundle(localeString); if (isDefaultLocale) return (ResourceBundle) resourceBundle; // need to determine if this is resource bundle is an empty stem // if it is then the default locale should be used if (resourceBundle == null || resourceBundle.isStemEmpty()) return (ResourceBundle) lookupResourceBundle(Locale.getDefault().toString()); return (ResourceBundle) resourceBundle; }
Dictionary<String, String> getHeaders(String localeString) { if (localeString == null) localeString = Locale.getDefault().toString(); if (localeString.length() == 0) return rawHeaders; boolean isDefaultLocale = localeString.equals(Locale.getDefault().toString()); Dictionary<String, String> currentDefault = defaultLocaleHeaders; if (isDefaultLocale && currentDefault != null) { return currentDefault; } if (generation .getRevision() .getRevisions() .getModule() .getState() .equals(Module.State.UNINSTALLED)) { // defaultLocaleHeaders should have been initialized on uninstall if (currentDefault != null) return currentDefault; return rawHeaders; } ResourceBundle localeProperties = getResourceBundle(localeString, isDefaultLocale); Enumeration<String> eKeys = this.rawHeaders.keys(); Headers<String, String> localeHeaders = new Headers<String, String>(this.rawHeaders.size()); while (eKeys.hasMoreElements()) { String key = eKeys.nextElement(); String value = this.rawHeaders.get(key); if (value.startsWith("%") && (value.length() > 1)) { // $NON-NLS-1$ String propertiesKey = value.substring(1); try { value = localeProperties == null ? propertiesKey : (String) localeProperties.getObject(propertiesKey); } catch (MissingResourceException ex) { value = propertiesKey; } } localeHeaders.set(key, value); } localeHeaders.setReadOnly(); if (isDefaultLocale) { defaultLocaleHeaders = localeHeaders; } return (localeHeaders); }