use of org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap in project rt.equinox.framework by eclipse.
the class StateResolverTest method loadManifest.
private Dictionary loadManifest(String manifest) {
URL url = getContext().getBundle().getEntry(MANIFEST_ROOT + manifest);
try {
CaseInsensitiveDictionaryMap<String, String> headers = new CaseInsensitiveDictionaryMap<String, String>();
ManifestElement.parseBundleManifest(url.openStream(), headers);
return headers.asUnmodifiableDictionary();
} catch (IOException e) {
fail("Unexpected error loading manifest: " + manifest, e);
} catch (BundleException e) {
fail("Unexpected error loading manifest: " + manifest, e);
}
return null;
}
use of org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap in project rt.equinox.framework by eclipse.
the class ManifestLocalization method getHeaders.
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);
CaseInsensitiveDictionaryMap<String, String> localeHeaders = new CaseInsensitiveDictionaryMap<>(this.rawHeaders);
for (Entry<String, String> entry : localeHeaders.entrySet()) {
String value = entry.getValue();
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;
}
entry.setValue(value);
}
}
Dictionary<String, String> result = localeHeaders.asUnmodifiableDictionary();
if (isDefaultLocale) {
defaultLocaleHeaders = result;
}
return result;
}
use of org.eclipse.osgi.framework.util.CaseInsensitiveDictionaryMap in project rt.equinox.framework by eclipse.
the class OSGiCapabilityTest method loadManifest.
private Dictionary loadManifest(String manifest) {
URL url = getContext().getBundle().getEntry(MANIFEST_ROOT + manifest);
try {
CaseInsensitiveDictionaryMap<String, String> headers = new CaseInsensitiveDictionaryMap<String, String>();
ManifestElement.parseBundleManifest(url.openStream(), headers);
return headers.asUnmodifiableDictionary();
} catch (IOException e) {
fail("Unexpected error loading manifest: " + manifest, e);
} catch (BundleException e) {
fail("Unexpected error loading manifest: " + manifest, e);
}
return null;
}
Aggregations