Package: BundleSearchingPropertyResourceBundleResolver

BundleSearchingPropertyResourceBundleResolver

nameinstructionbranchcomplexitylinemethod
BundleSearchingPropertyResourceBundleResolver()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getResourceBundles(Bundle, String)
M: 1 C: 41
98%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 13
100%
M: 0 C: 1
100%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2008, 2010 VMware Inc.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * VMware Inc. - initial contribution
10: *******************************************************************************/
11:
12: package org.eclipse.virgo.medic.eventlog.impl;
13:
14: import java.io.IOException;
15: import java.io.InputStream;
16: import java.net.URL;
17: import java.util.ArrayList;
18: import java.util.Enumeration;
19: import java.util.List;
20: import java.util.PropertyResourceBundle;
21:
22: import org.osgi.framework.Bundle;
23:
24: public final class BundleSearchingPropertyResourceBundleResolver implements PropertyResourceBundleResolver {
25:
26: public List<PropertyResourceBundle> getResourceBundles(Bundle bundle, String candidatePropertiesFileName) {
27: Enumeration<?> entries = bundle.findEntries("", candidatePropertiesFileName, false);
28: List<PropertyResourceBundle> propertyBundles = new ArrayList<PropertyResourceBundle>();
29:• if (entries != null) {
30:• while (entries.hasMoreElements()) {
31: URL propertiesFile = (URL) entries.nextElement();
32: InputStream input = null;
33: try {
34: input = propertiesFile.openStream();
35: propertyBundles.add(new PropertyResourceBundle(input));
36: } catch (IOException ioe) {
37: } finally {
38: try {
39:• if (input != null) {
40: input.close();
41: }
42: } catch (IOException e) {
43: }
44: }
45: }
46: }
47: return propertyBundles;
48: }
49: }