Package: ResourceBundleUtils

ResourceBundleUtils

nameinstructionbranchcomplexitylinemethod
ResourceBundleUtils()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
generateCandidatePropertiesFileNames(String, Locale)
M: 0 C: 45
100%
M: 1 C: 1
50%
M: 1 C: 1
50%
M: 0 C: 8
100%
M: 0 C: 1
100%
generateCandidatePropertiesFileNames(String, String, String, String)
M: 0 C: 72
100%
M: 0 C: 6
100%
M: 0 C: 4
100%
M: 0 C: 8
100%
M: 0 C: 1
100%
hasText(String)
M: 0 C: 9
100%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 0 C: 1
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.util.ArrayList;
15: import java.util.List;
16: import java.util.Locale;
17:
18: final class ResourceBundleUtils {
19:
20: private static final String PROPERTIES_SUFFIX = ".properties";
21:
22: static List<String> generateCandidatePropertiesFileNames(String baseName, Locale locale) {
23: List<String> candidateNames = new ArrayList<String>();
24:
25: candidateNames.addAll(generateCandidatePropertiesFileNames(baseName, locale.getLanguage(), locale.getCountry(), locale.getVariant()));
26:
27: Locale defaultLocale = Locale.getDefault();
28:
29:• if (!defaultLocale.equals(locale)) {
30: candidateNames.addAll(generateCandidatePropertiesFileNames(baseName, defaultLocale.getLanguage(), defaultLocale.getCountry(),
31: defaultLocale.getVariant()));
32: }
33:
34: candidateNames.add(baseName + PROPERTIES_SUFFIX);
35:
36: return candidateNames;
37: }
38:
39: private static List<String> generateCandidatePropertiesFileNames(String baseName, String language, String country, String variant) {
40: List<String> candidateNames = new ArrayList<String>();
41:
42:• if (hasText(language)) {
43:• if (hasText(country)) {
44:• if (hasText(variant)) {
45: candidateNames.add(baseName + "_" + language + "_" + country + "_" + variant + PROPERTIES_SUFFIX);
46: }
47: candidateNames.add(baseName + "_" + language + "_" + country + PROPERTIES_SUFFIX);
48: }
49: candidateNames.add(baseName + "_" + language + PROPERTIES_SUFFIX);
50: }
51:
52: return candidateNames;
53: }
54:
55: private static boolean hasText(String string) {
56:• return (string != null && string.length() > 0);
57: }
58: }