List of usage examples for java.util Enumeration getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.paxle.core.io.impl.ResourceBundleTool.java
public ResourceBundle getLocalization(Bundle osgiBundle, String resourceBundleBase, Locale locale) { if (osgiBundle == null) throw new NullPointerException("The osgi-bundle was null"); else if (resourceBundleBase == null) throw new NullPointerException("The resource-bundle base-name was null"); // if locale is null we are using the default locale if (locale == null) locale = this.getDefaultLocale(); // calculating the directory to use // calculating the resource-bundle location String localizationLocation = IResourceBundleTool.LOCALIZATION_LOCATION_DEFAULT; if (resourceBundleBase.contains("/")) { localizationLocation = resourceBundleBase.substring(0, resourceBundleBase.lastIndexOf('/')); resourceBundleBase = resourceBundleBase.substring(resourceBundleBase.lastIndexOf('/') + 1); }// ww w . ja v a 2 s.co m ResourceBundle bundle = null; try { // loop through all variants to find a matching resourcebundle final Iterator<String> variants = this.getLocaleVariants(locale.toString()); while (variants.hasNext()) { final String variant = variants.next(); final String propFile = resourceBundleBase + (variant.equals("") ? variant : "_" + variant) + ".properties"; @SuppressWarnings("unchecked") final Enumeration<URL> e = osgiBundle.findEntries(localizationLocation, propFile, false); if (e != null && e.hasMoreElements()) { final InputStream in = e.nextElement().openStream(); try { bundle = new OsgiResourceBundle(in, variant); } finally { in.close(); } } // TODO: should we append parents next? if (bundle != null) break; } } catch (IOException e) { this.logger.error( String.format("Unexpected '%s' while loading the resource-bundle for '%s' and locale '%s'.", e.getClass().getName(), resourceBundleBase, locale), e); } return bundle; }